> For the complete documentation index, see [llms.txt](https://docs.hello-robot.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hello-robot.com/stretch4_docs/working-with-stretch/navigation/navigating_with_stretch.md).

# Navigating with Stretch

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

### **Phase 1: Generating a Map**

**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
```

{% hint style="info" %}
*Alternatively, you can either use the gamepad to move the wrist and arm, or hit runstop and manually move it.* *(Images: Homed position on the left; stowed position on the right).*
{% endhint %}

<div><figure><img src="/files/I1z9lzSRrBPgKIqaIuuz" alt=""><figcaption></figcaption></figure> <figure><img src="/files/kVuQ9UsXG6ncc9IlaSqX" alt=""><figcaption></figcaption></figure></div>

**3. Launch the mapping node:** Start the offline mapping sequence in a terminal.ros2 launch&#x20;

```
stretch_nav2 offline_mapping.launch.py
```

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

```
stretch_camera_show --opencv --right
```

{% file src="/files/asskn3R7300r0BVq20go" %}

{% hint style="info" %}
**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.
  {% endhint %}

**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](https://hello-robot.gitbook.io/hello-robot-docs/tcZROZbQzCb20tjbv5qq/stretch4-body-repo/teleoperation/primer_gamepad_teleop) for setup and controls.

```
stretch_gamepad_teleop
```

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

```
ros2 run nav2_map_server map_saver_cli -f ${HELLO_FLEET_PATH}/maps/<map_name>
```

### Phase 2: Navigating the Generated Map

With the map saved, you can now navigate autonomously.

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

```
ros2 launch stretch_nav2 navigation_mppi.launch.py map:=${HELLO_FLEET_PATH}/maps/<map_name>.yaml
```

{% file src="/files/aekOMQj1ytrITJBvcKyR" %}

2\. **Set the initial pose**: You can set the robot pose in RViz2 with **2D Pose Estimate** (like the video). You can also set it in the config under the AMCL section.

```yaml
set_initial_pose: true
initial_pose:
  x: 0.06
  y: -0.12
  z: 0.0
  yaw: 0.12
```

3\. **Send a goal**: You can use **Nav2 Goal** in RViz2 (like the video), or send a goal from the terminal. Make sure the position is inside the map bounds and clear of obstacles.

```
ros2 action send_goal /navigate_to_pose nav2_msgs/action/NavigateToPose "{pose: {header: {frame_id: 'map'}, pose: {position: {x: 1.0, y: 1.0, z: 0.0}, orientation: {w: 1.0}}}}"
```

{% hint style="info" %}
Tip: Find coordinates in RViz2To 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 data for that location will immediately show in your terminal.. Make sure the robot is localized first!
{% endhint %}

### Troubleshooting and Debugging

1. **Isolate node errors:** If navigation is failing 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.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hello-robot.com/stretch4_docs/working-with-stretch/navigation/navigating_with_stretch.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
