CSCI 250: Simulator Lab


Simulators are an essential tool in modern robotics, allowing you to try out new algorithms and robot designs on simulations of equipment that would otherwise be prohibitively expensive to purchase and repair. V-REP, from Coppelia Robotics, is probably the most sophisticated simulator available today, and it is free for academic use. In this lab you will get some experience with V-REP, and – depending on what kind of final project you have proposed – you may even be able to build a simple prototype of your actual robot. You will also have an opportunity to program in Lua, a Python-like scripting language that is popular in some parts of the robotics and embedded-computing communities.

Part 1: Download and launch V-REP

Unlike most of the software packages we’re using in this course, V-REP does not use an installer that must be run by a system administrator. Instead, you simply download your own copy of the program and put it in a convenient place, like your desktop. Since the download is so large, however, I suggest that only one member of your group download it at first. Clicking on this link should start the download. Once it’s done, you can drag the .gz file onto your desktop, and right-click to uncompress the V-REP folder. Once that’s done, make sure to drag the .gz file into the trash and empty the trash, to conserve disk space.

As you would do when launching IDLE3, open the folder containing V-REP, and right click to launch a terminal window. Entering the following command will launch V-REP:


The basic file type that you load, modify and save in V-REP is called a scene, which for some reason ends in the extension .ttt. Like Arduino with its example sketches, V-REP comes with many scenes already written for you. Although I encourage you to explore as many scenes as you like, the one we will be working with in this lab is the controlTypeExamples scene, which you can load via the File/Open Scene … menu item. Once this scene is loaded, you should see five copies of “BubbleRob”, the little V-REP mascot. Hitting the play button at the top of the V-REP console will start the simulation. After a few seconds, each little BubbleRob will pop up a self-descriptive message banner and start moving, and all but the red ROS-controlled bot will start moving. Once you’ve seen them do their thing, hit the stop button to halt the simulation.

Part 2: Culling the herd

With all those different bots running around, it’s going to be difficult to focus on an interesting task to simulate. So, once you’ve stopped the simulation, go back to the File menu and do Save as … to save a copy of the scene with a new name. Since we’re going to work with an embedded script, I recommend scriptControlledBubbleRob.ttt, but you can use whatever name you like. I also recommend saving the script outside the V-REP folder, so that you can keep the V-REP application separate from your own work.

Next, using the Scene Hierarchy pane in the middle of the display, remove (highlight/delete) all but the orange scriptControlledBubbleRob robot from the scene. Hitting play should now give you a faster simulation, since V-REP only has one robot to simulate.

Part 3: Adding interesting behaviors

Looking back at the Scene hierarchy panel, you’ll see a little script icon (it looks like a tiny document) right next to the little cube representing the scriptControlledBubbleRob object. Double-clicking this script icon will launch an editor that you can use to edit the Lua script that controls BubbleRob. Since it’s only 35 lines or so, take a few moments to read through it. As you’ll see, there’s an initialization phase at the bottom (like Python’s main function), which creates handles to the scene objects, and at the top is the threaded infinite-loop function that allows BubbleRob to interact with his environment. (Why is it threaded? Because each robot must be able to run independently of the others!) Clicking on the + widget next to BubbleRob’s icon will show you the contents of the robot, whose names are used as strings in simGetObjectHandle().

One thing you might do immediately is remove the simBanner line (29) that puts up the annoying banner, which is no longer needed. After that, you might try moving the cubic barriers around the scene (via the little move-the-cube icon at the top) to make a wall, resizing them, and/or adding additional barriers by copy/pasting the existing barriers. One challenge would be to make a simple maze, and then see if you can modify the code in the script to help BubbleRob exit the maze in a reasonable amount of time. This is an open-ended exercise, so there’s no particular goal, other than having fun and learning how to use a popular robotics simulator. If you’re feeling really ambitious, you could drag-and-drop one of the many other kinds of robots from the Model browser (upper-left) and see what kind of behaviors it supports. I think you’ll agree that V-REP is truly the “Swiss Army Knife” of robot simulators!

Finishing Up

Once you’ve modified your scene to make Bubble Rob do something interesting, please give me a demo, and have each of your team members sign the sign-out sheet to receive full credit for the lab.