How to create a new world in Gazebo and record its map. - ovgu-FINken/driving_swarm_infrastructure GitHub Wiki
A gazebo world contains one or many models. By default there are already other things included (physics, light, ...). You'll need to create a model first and then save your world.
-
Open the terminal and start gazebo:
$ gazebo -
Create your models / world:
- inserting the simple building blocks on the top bar
- inserting models from your computer or the gazebo database
- build walls etc. using the Building Editor (see menu/Edit/Building Editor)
- editing models using the Edit/Model Editor (see menu/Edit/Model Editor)
See this tutorial for further information. If you created a new model, save the model with a descriptive Model Name and use the following path for the Location:
~/.../driving_swarm_infrastructure/src/driving_swarm_bringup/models/and exit the Building or Model Editor. -
Save your world as <my_world>.world in
~/.../driving_swarm_infrastructure/src/driving_swarm_bringup/worlds/. -
You'll need a robot to move around to record a map: Reopen the world file in a text editor, insert the following lines (before ), save and close:
<include>
<pose>-0.001 0.0 0 0 -0 0</pose>
<uri>model://turtlebot3_burger</uri>
</include>
Note: If you use another position for the robot, you'll need to adjust the origin accordingly in the map's yaml file by adding up the x-values, and then the y-values respectively.
-
Build the driving_swarm_bringup package or your whole workspace.
-
Run
$ ros2 launch map_creation_pkg any_world_single_robot.launch.py model_file:=<absolute path to your .world file>
- As described in this tutorial run the following commands in different terminals:
$ ros2 launch turtlebot3_cartographer cartographer.launch.py
$ ros2 run turtlebot3_teleop teleop_keyboard
Make sure to observe the simulation and the cartographer's output while steering the robot with your keyboard (you need to click into the terminal where the teleop node is running!).
- After the map is complete save your map by running
$ ros2 run nav2_map_server map_saver_cli -f ~/.../driving_swarm_infrastructure/src/driving_swarm_bringup/maps/my_world
with the world's absolute directory and name.
- Reopen your world-file (see 3.) and delete the lines you added in step 4.