|Note: This tutorial assumes that you have completed the previous tutorials: Explore the Gazebo world.|
|Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.|
Make a map and navigate with itDescription: Use the navigation stack to create a map of the Gazebo world and start navigation based on it.
Keywords: simulation, gazebo, map building, navigation
Tutorial Level: INTERMEDIATE
Make a map and Navigation in Gazebo simulation .
In this tutorial we will create a map of a virtual world and then use it to navigate around. Basically we will reproduce build a map and navigate a map TurtleBot tutorials in a simulated world. So if you have doubts about using the navigation stack with TurtleBot those tutorials will probably help you.
Make a map
$ source /opt/ros/indigo/setup.bash $ roslaunch turtlebot_gazebo turtlebot_world.launch
The playground world with a TurtleBot2 looks like this:
Alternatively you can use another existing world file like this:
$ roslaunch turtlebot_gazebo turtlebot_world.launch world_file:=worlds/willowgarage.world
Tip: of course you can also make your own world! With Gazebo it's not difficult, but is beyond the scope of this tutorial.
You can customize your simulated TurtleBot by setting TURTLEBOT_XXX environment variables; for example:
$ export TURTLEBOT_BASE=create $ export TURTLEBOT_STACKS=circles $ export TURTLEBOT_3D_SENSOR=asus_xtion_pro $ roslaunch turtlebot_gazebo turtlebot_playground.launch
will simulate a TurtleBot 1 with an Asus Xtion Pro camera.
To start map building, type:
roslaunch turtlebot_gazebo gmapping_demo.launch
Use RViz to visualize the map building process:
$ roslaunch turtlebot_rviz_launchers view_navigation.launch
Then, as explained in the previous tutorial, use your favorite teleoperation tool to drive the TurtleBot around the world, until you get satisfied with your map. This capture shows the mapping process after turning 360 degrees.
Finally, save the map to disk:
$ rosrun map_server map_saver -f <your map name>
Navigate the playground
To be sure that all will run as expected, kill all you launched in the previous section and repeat all steps except the map building. Instead, type:
roslaunch turtlebot_gazebo amcl_demo.launch map_file:=<full path to your map YAML file>
Or if you prefer to use an already created map, just omit the map_file argument.
Now you can send the robot anywhere in the playground with RViz, same way as explained on navigate a map tutorial.
You are done with Simulation section. The next tutorials are Development Corner.