For the complete documentation index, see llms.txt. This page is also available as Markdown.

Creating a Map

The goal of this tutorial is to learn the process of creating a static map of the Stretch robot's environment so that it can "remember" where permanent obstacles are located.

Launching for Data Collection

Robot Launch

The primary launch file is:

ros2 launch stretch_nav2 offline_mapping.launch.py

This will start:

  • The Stretch driver

  • The nodes to construct an initial map (using slam_toolbox)

  • RViz for visualization

Simulated Launch

You will need to run two separate processes.

ros2 launch stretch_simulation simulated_mapping.launch.py

This will start:

  • The simulated Stretch robot and environment

  • The mapping nodes (using slam_toolbox)

  • RViz for visualization

You will also need to run teleop. If you have a physical joystick plugged in that you'd like to use, run:

Alternatively, use keyboard teleoperation:

Data Collection

It is recommended that you save the raw mapping data as a ROS bag so you can replay it later if needed.

In a new terminal, run:

Replace MyStretchMappingData with the name of the directory where the recorded data should be stored.

Collecting Data

Initially, RViz will display something similar to:

base

This is a top-down view of the robot with:

  • Red points representing current laser scan readings

  • A map visualized using three colors:

    • Black: Occupied space

    • Light Gray: Free space

    • Dark Bluish Gray: Unknown space

Now teleoperate the Stretch around the environment.

The goal is to visit all areas where the robot may eventually operate so that the sensors can observe and map those spaces.

As you move around, RViz will continuously update the map, allowing you to see which regions have already been mapped successfully.

Tips

  • Avoid very fast movements, especially rapid turns.

  • Revisit previously mapped areas to improve mapping accuracy.

Completion

When you have driven around to your satisfaction, there are two things to do.

First, press Ctrl+C in the terminal where you started recording your ROS bag to stop data collection.

Second, run the following commands to save the map to the stretch_user/ directory:

Replace MY_MAP_NAME with a descriptive name for the mapped environment.

Note

Do not include a file extension in MY_MAP_NAME.

The map_saver will automatically create:

  • MY_MAP_NAME.pgm

  • MY_MAP_NAME.yaml

Both files will be stored in ${HELLO_FLEET_PATH}/maps.

Rerunning Mapping with Bagged Data

If the initial map you saved is not to your liking, you can always rerun the mapping process after the fact using the bag file.

In one terminal, launch the slam_toolbox

In another, play back the bagged data.

(use_sim_time:=True and --clock ensure the proper timing data is communicated, otherwise the mapping software may get confused about data from the past showing up)

The parameters for the mapping are located in stretch_nav2/config/mapper_params_offline.yaml with some clues to the purpose of each listed in the slam_toolbox documentation.

Last updated

Was this helpful?