> ## 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.

# 使用 simulation_sample_amr_simple_motion 在仿真器中控制 AMR

> AMR simple motion 是一个仿真示例应用，使用基于 Python 的 ROS 节点在仿真器内控制 QRB 自主移动机器人 (AMR) 的运动。

[qrb\_ros\_simulation](https://github.com/qualcomm-qrb-ros/qrb_ros_simulation) 包提供仿真环境。它允许您通过向 `/qrb_robot_base/cmd_vel` topic 发布 ROS 消息来控制 QRB 自主移动机器人 (AMR) 的运动。

> [!NOTE]
>
> 有关更多信息，请参见 GitHub 上的 [Simulation Sample AMR Simple Motion](https://github.com/qualcomm-qrb-ros/qrb_ros_samples/tree/main/robotics/simulation_sample_amr_simple_motion) 仓库。

下图展示了运动控制终端与 QRB AMR 仿真器视图并排显示的情况：

![Terminal accepting AMR motion control commands beside a simulator view of the robot base moving across the floor.](https://mintlify.s3.us-west-1.amazonaws.com/qualcomm-prod/zh/SDKs/QIR-SDK-Ubuntu/images/image23.gif)

## `simulation_sample_amr_simple_motion` 的管线流程

下图展示了 `simulation_sample_amr_simple_motion` 的管线：

![Device-side AMR simple motion node publishing ROS messages on the cmd\_vel topic to the QRB ROS simulation running on the host.](https://mintlify.s3.us-west-1.amazonaws.com/qualcomm-prod/zh/SDKs/QIR-SDK-Ubuntu/images/image24.png)

simulation\_sample\_amr\_simple\_motion 管线。

## `simulation_sample_amr_simple_motion` 管线中使用的 ROS 节点

下表描述了 AMR simple motion 管线中使用的 ROS 节点。

| ROS 节点 | 说明 |
| - | - |
| `qrb_ros_simulation` | `qrb_ros_simulation` 是一个 ROS 包，用于搭建 Qualcomm 机器人仿真环境。详情请参见 GitHub 上的 [QRB ROS Simulation](https://github.com/qualcomm-qrb-ros/qrb_ros_simulation)。 |

## `simulation_sample_amr_simple_motion` 管线中使用的 ROS topic

下表描述了 `simulation_sample_amr_simple_motion` 管线中使用的 ROS topic。

| ROS topic | 类型 | 发布者 |
| - | - | - |
| `/qrb_robot_base/cmd_vel` | `geometry_msgs::msg::Twist` | `simulation_sample_amr_simple_motion` |

## 前提条件

您已根据 [安装 QIR SDK](https://dragonwingdocs.qualcomm.com/zh/SDKs/QIR-SDK-Ubuntu/install-the-qir-sdk.md) 在设备上完成设备设置、安装 ROS2 Jazzy 和 Qualcomm Intelligent Robotics (QIR) SDK。

## 运行 `simulation_sample_amr_simple_motion`

**1. 在主机上构建 Qualcomm 机器人仿真环境**

在您的主机上，根据 [QRB ROS Simulation](https://github.com/qualcomm-qrb-ros/qrb_ros_simulation) 的 README 完成以下操作，构建 Qualcomm 机器人仿真环境。

1. 在 Ubuntu24.04 主机或 Docker 上设置开发环境。

2. 从源代码构建。

**2. 在主机上运行 QRB Robot Base AMR**

```bash theme={null}
source /opt/ros/jazzy/setup.bash
ros2 launch qrb_ros_sim_gazebo gazebo_robot_base.launch.py namespace:=qrb_robot_base enable_laser:=false
```

**3. 在开发套件上运行 AMR simple motion**

在开发套件上，运行以下命令以运行 AMR simple motion。

```bash theme={null}
source /opt/ros/jazzy/setup.bash
ros2 run simulation_sample_amr_simple_motion simple_motion
```

### 结果

如果 ROS 节点成功启动，日志中会出现以 `=== AMR Simple Motion Control Usage: ===` 开头的内容。

然后，您可以输入运动控制命令，并在主机上通过仿真器查看 QRB AMR 的移动状态。
