> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Enable navigation in the simulator with navigation2

`simulation_amr_navigation` is a simulated sample application that demonstrates how to run `navigation2` on Qualcomm robotics platforms within the simulator.

The [QRB ROS Simulation](https://github.com/qualcomm-qrb-ros/qrb_ros_simulation) is a ROS project designed to set up the Qualcomm robotic simulation environment.

<video
  autoPlay
  muted
  loop
  playsInline
  width={1280}
  height={720}
  src="https://mintcdn.com/qualcomm-prod/EDJV-hu6qJhZi4pm/SDKs/QIR-SDK-2.0/media/80-65220-2-qirp-sdk-qsg/simulation-amr-navigation-result.mp4?fit=max&auto=format&n=EDJV-hu6qJhZi4pm&q=85&s=302324afe85f89f4ef3789aec0a56e94"
  style={{
width: "100%",
display: "block",
margin: "0 auto" }}
  data-path="SDKs/QIR-SDK-2.0/media/80-65220-2-qirp-sdk-qsg/simulation-amr-navigation-result.mp4"
/>

<p style={{ textAlign: 'center', fontWeight: 'bold' }}>
  Figure: Sample results of `simulation_amr_navigation`
</p>

## Pipeline flow for `simulation_amr_navigation`

<img
  src="https://mintcdn.com/qualcomm-prod/IP0o0G5fE3MFmCJ8/SDKs/QIR-SDK-2.0/media/80-65220-2-qirp-sdk-qsg/simulation-amr-navigation-pipeline.svg?fit=max&auto=format&n=IP0o0G5fE3MFmCJ8&q=85&s=a28881244d2b5b86dbed059605cc7835"
  style={{
width: "90%",
display: "block",
margin: "0 auto" }}
  width="522"
  height="402"
  data-path="SDKs/QIR-SDK-2.0/media/80-65220-2-qirp-sdk-qsg/simulation-amr-navigation-pipeline.svg"
/>

<p style={{ textAlign: 'center', fontWeight: 'bold' }}>
  Figure: Pipeline flow for `simulation_amr_navigation`
</p>

## ROS nodes used in the `simulation_amr_navigation `pipeline

| **ROS node**         | **Description**                                                                                                                                                                                                                                 |
| :------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `qrb_ros_simulation` | `qrb ros simulation` is a ROS package that sets up the Qualcomm robotic simulation environment. For details, see [QRB ROS Simulation](https://github.com/qualcomm-qrb-ros/qrb_ros_simulation).                                                  |
| `navigation2 nodes`  | `navigation2` is the professionally-supported successor of the ROS Navigation Stack. It allows for mobile robots to navigate through complex environments to complete user-defined application tasks with nearly any class of robot kinematics. |

## ROS topics used in the `simulation_amr_navigation `pipeline

<table>
  <thead>
    <tr>
      <th style={{ width: '20%' }}>ROS topic</th>
      <th style={{ width: '30%' }}>Type</th>
      <th style={{ width: '20%' }}>Published by</th>
      <th style={{ width: '30%' }}>Description</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>`/map`</td>
      <td>`nav_msgs::msg::OccupancyGrid`</td>
      <td>`cartographer_occupancy_grid_node`</td>
      <td>The 2D occupancy grid map of the environment.</td>
    </tr>

    <tr>
      <td>`/tf`</td>
      <td>`tf2_msgs::msg::TFMessage`</td>
      <td>`cartographer_occupancy_grid_node`, `qrb_ros_simulation`</td>
      <td>Spatial relationships between different coordinate frames.</td>
    </tr>

    <tr>
      <td>`/scan`</td>
      <td>`sensor_msg::msg::LaserScan`</td>
      <td>`qrb_ros_simulation`</td>
      <td>2D laser scan data.</td>
    </tr>

    <tr>
      <td>`/goal_pose`</td>
      <td>`geometry_msgs::msg::PoseStamped`</td>
      <td>`Application to call navigation2`</td>
      <td>The target pose for navigation, including position and orientation in the map frame.</td>
    </tr>
  </tbody>
</table>

## Prerequisites

You have completed the following settings in [Set up the environment for running sample applications](./set-up-env-for-sample-app) (Skip the settings of **Set up host docker**).

* Set up the device
* Set up the host computer

<Note>
  **Note**

  Ensure that the board is connected to the simulation host using an Ethernet cable. Otherwise, the sample's performance may degrade due to data transmission issues.
</Note>

### Set up the simulation environment

1. On your host computer, complete the following actions to build the Qualcomm robotic simulation environment according to the **README** of [QRB ROS Simulation](https://github.com/qualcomm-qrb-ros/qrb_ros_simulation). Ensure that the device and the host are on the same local network and can communicate with each other through ROS communication.
   1. Set up development environment on Ubuntu24.04 host.
   2. Build from source.
2. Run the QRB Robot Base AMR Mini on the host.
   ```bash theme={null}
   # Set the ROS_DOMAIN_ID
   export ROS_DOMAIN_ID=123
   ros2 launch qrb_ros_sim_gazebo gazebo_robot_base_mini.launch.py world_model:=ionic
   ```

## Run out-of-the-box `navigation2`

<Accordion title="Try me">
  <Steps>
    <Step title="Configure navigation2 parameters">
      Configure `navigation2` parameters to use GracefulController.

      ```bash theme={null}
      sed -i.bak -E 's/^([[:space:]]*)plugin: "nav2_mppi_controller::MPPIController"/\1#plugin: "nav2_mppi_controller::MPPIController"\n\1plugin: "nav2_graceful_controller::GracefulController"/' /usr/ros/jazzy/share/nav2_bringup/params/nav2_params.yaml
      ```
    </Step>

    <Step title="Run the 2D lidar SLAM">
      ```bash theme={null}
      source /usr/share/qirp-setup.sh
      export ROS_DOMAIN_ID=123
      ros2 launch cartographer_ros qrb_2d_lidar_slam_gazebo_sim.launch.py
      ```
    </Step>

    <Step title="Run the qrb_slam_service_request script">
      In a new terminal, run the following commands.

      ```bash theme={null}
      ssh root@[IP address]
      source /usr/share/qirp-setup.sh
      export ROS_DOMAIN_ID=123
      chmod 777 /usr/ros/jazzy/share/cartographer_ros/scripts/qrb_slam_service_request.sh
      bash /usr/ros/jazzy/share/cartographer_ros/scripts/qrb_slam_service_request.sh
      ```
    </Step>

    <Step title="Start mapping">
      Use the keyboard to send `0` control commands to start mapping.
    </Step>

    <Step title="Run navigation2">
      In a new terminal, run the following commands.

      ```bash theme={null}
      source /usr/share/qirp-setup.sh
      export ROS_DOMAIN_ID=123
      ros2 launch nav2_bringup navigation_launch.py use_sim_time:=true
      ```
    </Step>

    <Step title="Send the navigation goal">
      In a new terminal, run the following commands to send the navigation goal and start navigation.

      ```bash theme={null}
      export ROS_DOMAIN_ID=123
      ros2 action send_goal /navigate_to_pose nav2_msgs/action/NavigateToPose "{pose: {header: {stamp: {sec: 0, nanosec: 0},frame_id: 'map'},pose: {position: {x: 1.0,y: 1.0,z: 0.0},orientation: {x: 0.0,y: 0.0,z: 0.0,w: 1.0}}}}"
      ```
    </Step>
  </Steps>
</Accordion>
