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 it

Description: 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

Overview

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

First, bring up the TurtleBot simulation as described in the Quick Start Guide, but this time we will load a slightly funnier world:

$ source /opt/ros/hydro/setup.bash
$ roslaunch turtlebot_gazebo turtlebot_playground.launch

The playground world with a TurtleBot2 looks like this:

turtlebot_playground.png

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.

Caution: Gazebo plugins for Create and Roomba bases don't work perfectly on Hydro, so expect strange behaviors when using them.

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.

turtlebot_playground_rviz.png

Finally, save the map to disk:

$ rosrun map_server map_saver -f <your map name>

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 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.

Wiki: turtlebot_simulator/Tutorials/hydro/Make a map and navigate with it (last edited 2014-02-06 14:29:37 by YoshimaruTanaka)