-
Notifications
You must be signed in to change notification settings - Fork 97
World Creation Tutorial
This tutorial explains how to create an underground world using the SubT Simulator's graphical interface and few shell scripts.
A SubT Challenge world has three main components:
- An SDF file (
world.sdf
), which is an XML file that Ignition uses to load assets. - A graphviz dot file (
world.dot
), which describes the connectivity of the environment. - A visibility
dat
file (world.dat
), which describes the communication model of the environment.
All three files must be present for the SubT Simulator to simulate the world.
In order to maximize compatibility, it is necessary for the SDF world to follow certain guidelines.
- The staging area must be located at the world origin, which may require offsetting the remainder of the world tiles. The base station and artifact origin fiducial should be placed based on the staging area at the origin.
<!-- The staging area -->
<include>
<static>true</static>
<name>staging_area</name>
<pose>0 0 0 0 0 0</pose>
<uri>https://fuel.ignitionrobotics.org/1.0/openrobotics/models/Cave Starting Area Type B</uri>
</include>
<!-- The base station -->
<include>
<static>true</static>
<name>base_station</name>
<pose>-8 0 0 0 0 -1.5708</pose>
<uri>https://fuel.ignitionrobotics.org/1.0/openrobotics/models/Base Station</uri>
</include>
<!-- Fiducial marking the origin for artifacts reports -->
<include>
<name>artifact_origin</name>
<pose>10.0 0.0 0.0 0 0 0</pose>
<uri>https://fuel.ignitionrobotics.org/1.0/openrobotics/models/Fiducial</uri>
</include>
- The world name in the
.sdf
file should match the filename. - World tiles follow the naming convention
tile_N
, starting at index 1. - World tile caps follow the naming convention
cap_N
, starting at index 1.
Familiarize yourself with the graphical interface by reading up on the various options and plugins. Experimentation is also highly encouraged.
You can start creating a world from scratch by running ign gazebo -v 4
, and then inserting models from the SubT Tech Repo. Click on a model you'd like to insert and use the drag to simulator
button on the model's detail page. More information about model insertion can be found here.
Alternatively, you can launch an existing world and make modifications. Try launching a simple cave world to get started, such as ign launch cave_circuit.ign worldName:=simple_cave_01
. Use the model manipulation tools to alter the configuration of the cave.
When you are happy with your world, use the hamburger button in the upper left to access the "Save World" option. Save your world into your catkin workspace in the subt/subt_ign/worlds
directory. World files in this directory will be automatically installed when catkin_make install
is run.
The first step is to generate the connectivity data for the .sdf
file.
This is accomplished by using the included dot_generator
tool:
source ~/subt_ws/install/setup.bash
rosrun subt_ign dot_generator ~/subt_ws/src/subt/subt_ign/worlds/my_new_world.sdf
The corresponding connections will be output to the console, where they can be visually inspected and then copied into a corresponding .dot
file.
The output can also be redirected to write the .dot
file directly via:
source ~/subt_ws/install/setup.bash
rosrun subt_ign dot_generator ~/subt_ws/src/subt/subt_ign/worlds/my_new_world.sdf > \
~/subt_ws/src/subt/subt_ign/worlds/my_new_world.dot
In the world, each tile should either be connected to an adjacent tile, or have a cap placed on it. Tile connectivity can be verified by utilizing the Connections Validator Tool. Tile connectivity can also be verified without starting the simulator by using:
cd ~/subt_ws/
catkin_make tests
source ~/subt_ws/install/setup.bash
# Run a non-GUI version of the connection validator
./devel/lib/subt_ign/TEST_ConnectionValidator my_new_world_without_sdf_extension
For example:
./devel/lib/subt_ign/TEST_ConnectionValidator simple_cave_01
If there are any issues in the world, they will be reported as follows:
[ConnectionValidatorPrivate.cc:105] Parsing [/home/developer/subt_ws/install/share/subt_ign/worlds/my_new_world.sdf]
[Dbg] [ConnectionValidatorPrivate.cc:127] Parsing [/home/developer/subt_ws/install/share/subt_ign/worlds/my_new_world.dot]
[Wrn] [ConnectionHelper.cc:289] Failed to connect: Cave 4 Way 01 Type A Cave U Turn 01 Type A
[Wrn] [ConnectionHelper.cc:289] Failed to connect: Cave 4 Way 01 Type A Cave 3 Way 01 Type A
[Wrn] [ConnectionHelper.cc:289] Failed to connect: Cave 4 Way 01 Type A Cave Corner 02 Type A
[Dbg] [ConnectionValidatorPrivate.cc:315] Populated 64/67
[Dbg] [ConnectionValidatorPrivate.cc:340] tile_21 1/2 (Cave U Turn 01 Type A)
[Dbg] [ConnectionValidatorPrivate.cc:340] tile_22 2/3 (Cave 3 Way 01 Type A)
[Dbg] [ConnectionValidatorPrivate.cc:340] tile_28 1/2 (Cave Corner 02 Type A)
[Dbg] [ConnectionValidatorPrivate.cc:332] Found cap!
[Dbg] [ConnectionValidatorPrivate.cc:340] tile_5 0/4 (Cave 4 Way 01 Type A)
[Dbg] [ConnectionValidatorPrivate.cc:332] Found cap!
[Dbg] [ConnectionValidatorPrivate.cc:332] Found cap!
In the above example, we can see several tiles that have failed to connect, along with the corresponding types and number of valid connections. These need to be resolved before we can move forward in the generation process.
In general, these errors will appear in the cases where:
- There is a tile that is not connected to anything.
- There is a tile that is incorrectly rotated, so it no longer makes connection.
- There is a failure to account for elevation change between tiles.
- There are tile connection points that do not have caps on them.
This process may be iterative and require adjusting the .sdf
and .dot
files and inspecting the results with both the command line and GUI applications until the world is corrected.
Once the .sdf
and .dot
files are generated with correct connectivity, the visibility tables can be generated.
This is accomplished by utilizing the visibility.ign
launch file:
ign launch visibility.ign worldName:=my_new_world
The visibility table may take several minutes to generate, so grab a warm beverage.
Once it is completed, move the output .dat
file to ~/subt_ws/src/subt/subt_ign/worlds/
.
The results may also be verified by following the Breadcrumbs and communication visualization tutorial.
In order to improve simulator performance in large worlds, it may be necessary to generate
levels, which allow parts of the environment to be loaded and unloaded based on the location
of the robots. This is accomplished via a separate generation stage, which adds levels to the .sdf
file:
cd ~/subt_ws/
source ~/subt_ws/install/setup.bash
./devel/lib/subt_ign/level_generator \
~/subt_ws/src/subt/subt_ign/worlds/my_new_world.sdf \
50 50 50 10 \
~/subt_ws/src/subt/subt_ign/worlds/my_new_world.sdf
The arguments to the level generator define the size in x, y, z of the level bounding boxes, as well as the size of the buffer for loading and unloading levels. These may vary based on the size of the environment and the size of the tiles used. You can check out the other worlds in ~/subt_ws/src/subt/subt_ign/worlds
for examples.
Now, to launch your world, you only have to rebuild your workspace and launch it using the worldName
argument:
cd ~/subt_ws/
catkin_make install
source ~/subt_ws/install/setup.bash
ign launch -v 4 cave_circuit.ign worldName:=my_new_world
Now you can test your autonomous robots in a custom underground world!