Lab: Mirage and Virtual Worlds

From Tekkotsu Wiki

Jump to: navigation, search

Learning objective: In this lab you will learn to use the Mirage virtual environment simulator with Tekkotsu to get a simulated robot to run around in a virtual world. This is useful for debugging code when a real robot isn't available. You will also learn how to make your own virtual worlds.

Create/ASUS robot in the tic-tac-toe world.


Exploring A Mirage World

  1. Start up Tekkotsu and Mirage by following the instructions for Running Mirage. Use the tic-tac-toe world.
  2. Use keyboard commands (a,w,s,d, etc.) to move through the virtual world; see the Mirage Command Summary for the full list of keyboard commands.
  3. Turn on the RawCam viewer in the ControllerGUI to see the robot's view of the world.
  4. Click on the W button in the ControllerGUI to start a Walk Controller and drive your robot around in the world.
  5. On the Create or Calliope robot: Use the Sensor Observer to monitor the left and right bump sensors. (See Lab: Teleoperation and Sensor Observer for directions.) Try running the robot into one of the cylinders in the tic-tac-toe world and watch how the state of the bump sensor changes.

Modifying A Mirage World

1. Make a private copy of the gridcubes WorldBuilder example in your project/worlds directory. Note that WorldBuilder source files have extension ian; the output of the WorldBuilder is a Mirage world with extension .mirage.

cp /usr/local/Tekkotsu/tools/mirage/worldbuilder/examples/gridcube.ian ~/project/worlds/mycubes.ian

2. Edit the mycubes.ian file and change the vertical scale of the middle cube to 40 and the material to Blue.

cd ~/project/worlds
gedit mycubes.ian
  Edit the line to read: gridcube location=(-40,40,0) scale=(20,20,40) material=Blue

3. Generate the mycubes.mirage file (assumes /usr/local/Tekkotsu/tools/bin is on your search path):

WorldBuilder mycubes.ian

4. Run Mirage using your new world:

cd /usr/local/Tekkotsu/tools/mirage
./mirage ~/project/worlds/gridcubes.mirage

Creating A New Mirage World

1. Start by sketching a design for your world. What do you want it to look like? You can make many different shapes from cubes, cylinders, and spheres. For example, you can make a tree by placing a green sphere on top of a brown cylinder. You can make an inclined ramp or a pyramid by stretching a cube and rotating and translating it so that part of it is buried in the ground.

2. Calculate the coordinates for the objects in your world. The scale is in millimeters. How big do you want each object to be? Where should it be placed?

3. Create a file ~/project/worlds/myworld.ian and use WorldBuilder commands to construct the shapes that make up your world. See the Mirage WorldBuilder syntax page for a summary of the WorldBuilder language. Documentation for an older version of the tool is available at the WorldBuilder shapes page and the WorldBuilder examples page.

4. Generate your Mirage world:

cd ~/project/worlds
WorldBuilder myworld.ian

5. Run Mirage using your new world.

Mirage myworld.mirage

Additional Information