Though ROS can work in unknown environments, it helps to start with a map of the environment that we’re working in.

In this tutorial we’ll drive TurtleBot once around our office using teleoperation to create a map. This will give us a map we can reference in other scripts, giving TurtleBot completely autonomous navigation.

Create a Map Via Teleoperation

On TurtleBot, open a terminal window and run:

roslaunch turtlebot_bringup minimal.launch
roslaunch turtlebot_navigation gmapping_demo.launch

On the workstation, open a terminal window and run:

roslaunch turtlebot_rviz_launchers view_navigation.launch
roslaunch turtlebot_teleop keyboard_teleop.launch

TIP: Instead of using the keyboard, the joystick may be more convenient.

Now using teleoperation, navigate TurtleBot around the entire area you wish to map.

Building Your First Map

On TurtleBot, open a terminal window and run:

rosrun map_server map_saver -f /tmp/my_map
ls /tmp/

You will now see two files in the /tmp/ directory my_map.pgm and my_map.yaml. As you create maps in the future, you can save them with different names (e.g. /tmp/my_office).

TIP: Ubuntu’s /tmp/ directory is automatically cleaned (deleted) on every boot. You may want to use a different directory if you need want to keep the maps.

Learn more at wiki.ros.org