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

# Control AMR in the simulator with simulation_sample_amr_simple_motion

> This sample application demonstrates AMR control in the simulator.

`simulation_sample_amr_simple_motion` is a simulated sample application that uses a Python-based ROS node to control the movements of QRB autonomous moving robots (AMRs) within the simulator.

The [QRB ROS Simulation](https://github.com/qualcomm-qrb-ros/qrb_ros_simulation) package provides the simulation environment. It allows you to control the movement of QRB AMRs through publishing the ROS messages to the `/qrb_robot_base/cmd_vel` topic.

<Note>
  **Note**

  For more information, see [simulation\_sample\_amr\_simple\_motion](https://github.com/qualcomm-qrb-ros/qrb_ros_samples/tree/main/robotics/simulation_sample_amr_simple_motion) on GitHub.
</Note>

<video
  autoPlay
  muted
  loop
  playsInline
  width={1200}
  height={480}
  src="https://mintcdn.com/qualcomm-staging/blZpKs_b9On5nj-y/archives/2.1/SDKs/QIR-SDK-2.0/media/80-65220-2-qirp-sdk-qsg/simulation_sample_amr_simple_motion_result.mp4?fit=max&auto=format&n=blZpKs_b9On5nj-y&q=85&s=99a3e5789d4a0586d4733001d957d153"
  style={{
width: "80%",
display: "block",
margin: "0 auto" }}
  data-path="archives/2.1/SDKs/QIR-SDK-2.0/media/80-65220-2-qirp-sdk-qsg/simulation_sample_amr_simple_motion_result.mp4"
/>

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

## Pipeline flow for `simulation_sample_amr_simple_motion`

<img
  src="https://mintcdn.com/qualcomm-staging/blZpKs_b9On5nj-y/archives/2.1/SDKs/QIR-SDK-2.0/media/80-65220-2-qirp-sdk-qsg/simulation-amr-simple-motion-pipeline.svg?fit=max&auto=format&n=blZpKs_b9On5nj-y&q=85&s=e0860bfb9e960bea36d51d4a5fbeba38"
  style={{
width: "100%",
display: "block",
margin: "0 auto" }}
  width="690"
  height="138"
  data-path="archives/2.1/SDKs/QIR-SDK-2.0/media/80-65220-2-qirp-sdk-qsg/simulation-amr-simple-motion-pipeline.svg"
/>

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

## ROS nodes used in the `simulation_sample_amr_simple_motion `pipeline

<table>
  <thead>
    <tr>
      <th style={{ width: '30%' }}>ROS node</th>
      <th style={{ width: '70%' }}>Description</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>`qrb_ros_simulation`</td>
      <td>`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). </td>
    </tr>
  </tbody>
</table>

## ROS topics used in the `simulation_sample_amr_simple_motion `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>`/qrb_robot_base/cmd_vel`</td>
      <td>`geometry_msgs::msg::Twist` </td>
      <td>`simulation_sample_amr_simple_motion`</td>
      <td>Indicates the velocity commands for robot movement. </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**).

<Accordion title="Try me">
  * Set up the device
  * Set up the host computer

  ### Set up the simulation environment

  <Steps>
    <Step title="Build the simulation environment on your host computer">
      Complete the following 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 or Docker.
      2. Build from source.
    </Step>

    <Step title="Run the QRB Robot Base AMR 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.launch.py namespace:=qrb_robot_base enable_laser:=false
      ```
    </Step>
  </Steps>
</Accordion>

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

On the development kit, run the following commands:

<Accordion title="Try me">
  ```bash theme={null}
  # setup runtime environment
  source /usr/share/qirp-setup.sh

  # Set the ROS_DOMAIN_ID
  export ROS_DOMAIN_ID=123

  ros2 run simulation_sample_amr_simple_motion simple_motion
  ```
</Accordion>

**Result**

If the ROS node launches successfully, the log starting from `=== AMR Simple Motion Control Usage: ===` appears.

Then, you can input the motion control commands and check the movement status of the QRB AMR within the simulator on the host computer.

## Build and run `simulation_sample_amr_simple_motion`

<Accordion title="Try me">
  <Note>
    **Note**

    * `<qir_version>`: Version of the QIR SDK, see [QIR SDK 2.0 Release Notes](./release-notes).
    * `<qir_decompressed_path>`: The path where the QIR SDK is decompressed.
  </Note>

  <Steps>
    <Step title="Build and package on the host computer">
      1. Build the sample application project.
         ```bash theme={null}
         # Set up the QIR SDK  environment
         cd <decompressed_workspace>/images/iq-9075-evk/qirpsdk_artifacts/iq-9075-evk
         tar -zxf qirp-sdk_<qir_version>.tar.gz
         cd <qir_decompressed_path>/qirp-sdk
         source setup.sh
         # build sample
         cd <qir_decompressed_path>/qirp-sdk/qirp-samples/robotics/simulation_sample_amr_simple_motion
         colcon build
         ```
      2. Package and push the sample application to the device.
         ```bash theme={null}
         # package and push build result of sample
         cd <qir_decompressed_path>/qirp-sdk/qirp-samples/robotics/simulation_sample_amr_simple_motion/install/simulation_sample_amr_simple_motion
         tar -czf simulation_sample_amr_simple_motion.tar.gz lib share
         scp simulation_sample_amr_simple_motion.tar.gz root@[ip-addr]:/opt/
         ```
    </Step>

    <Step title="Install and run on the development kit">
      1. Install the sample application.
         ```bash title="SSH Session" theme={null}
         # Install sample package
         tar --no-overwrite-dir --no-same-owner -zxf /opt/simulation_sample_amr_simple_motion.tar.gz -C /usr/ros/jazzy/
         ```
      2. Run the sample application with the steps in [Run out-of-the-box simulation\_sample\_amr\_simple\_motion](#run-out-of-the-box-simulation_sample_amr_simple_motion).
    </Step>
  </Steps>
</Accordion>
