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

Navigating with Stretch

Use this workflow to create a 2D map and navigate with ROS 2 Nav2.

This guide walks through creating a 2D map and running autonomous navigation on Stretch using ROS 2 Nav2. It covers the basic workflow for mapping and navigation on the robot. If you are new to Nav2, first follow the official Nav2 Getting Started guide to learn the concepts in simulation. You can also explore Navigation University for more advanced topics and tuning.

Phase 1: Generating a Map

Video: Mapping workflow

30MB
Open

1. Home the robot: Home the joints before any mobile operation.

stretch_robot_home

2. Stow the robot: Stow the arm so it stays within the base footprint.

stretch_robot_stow

Alternatively, you can use the gamepad to move the wrist and arm, or press runstop and move the arm manually. The images below show the homed position (left) and stowed position (right).

3. Launch the mapping node: In a terminal, start the offline mapping launch file.

Optional: Enable the camera view if you want a live feed while driving.

Mapping tips

  • Move slowly, especially during turns. This gives the sensors time to capture clean data.

  • Watch the laser scan in RViz. If the red scan stops aligning with obstacles, the map is drifting.

4. Start teleoperation: In a second terminal, start the gamepad node and drive the robot through the area you want to map. See the gamepad teleop primer for setup and controls.

5. Save the map: After you cover the full area, leave the mapping node running. Open a new terminal and save the map to your fleet directory. Replace <map_name> with a name such as hq_upstairs.

6. Close the mapping node: Before starting navigation, stop the mapping launch file with Ctrl+C in its terminal.

Phase 2: Navigating the Generated Map

With the map saved, you can navigate autonomously.

Video: Navigation workflow

25MB
Open

1. Launch navigation: Start Nav2 and pass the YAML file for the map you just created.

2. Set the initial pose: Set the robot's initial pose so it matches the robot's actual position and orientation on the map.

You can set the pose interactively in RViz2 using 2D Pose Estimate:

  1. Click at the robot's current location on the map.

  2. Hold and drag in the direction the robot is facing.

  3. Release to set the robot's orientation.

Alternatively, you can configure a fixed initial pose in the AMCL parameters so Nav2 initializes at the same location each time it starts. Add the following to your AMCL configuration file:

The values above are examples only. Replace x, y, and yaw with the robot's actual starting position and orientation in your map.

Video: Setting the initial pose in RViz2

3. Send a goal: Use Nav2 Goal in RViz2 (as shown in the navigation video), or send a goal from the terminal. Make sure the position is inside the map bounds and clear of obstacles.

Tip: Find coordinates in RViz2

To find exact coordinates, open a terminal and run ros2 topic echo /clicked_point. With that running, use the Publish Point tool in RViz2 to click anywhere on the map. The X and Y position for that location will appear in your terminal. Make sure the robot is localized first.

Troubleshooting and Debugging

  1. Isolate node errors: If navigation fails at startup, add use_composition:=false to the navigation launch command. This starts nodes outside a shared container, which makes errors easier to spot.

  2. Remote operation: If you use a remote desktop session, plug in a dummy HDMI adapter so the display server starts correctly.

  3. Navigation does not start after setting the pose: If too much time passes before you set the robot's initial pose, the navigation stack may need to be reset. A common symptom is that the local costmap appears in RViz2, but the global costmap does not.

To recover:

  1. In the Navigation panel in RViz2, click Startup.

  2. Click Reset.

  3. Set the robot's initial pose again.

Once the global costmap appears, the robot is ready to accept navigation goals.

Video: Resetting the Nav2 stack in RViz2

Last updated

Was this helpful?