> ## 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_remote_assistant 体验远程助手

> simulation_remote_assistant 示例应用是一个 ROS 包，它在虚拟办公环境中使用 AMR 作为远程助手。

用户可以通过输入自然语言命令与机器人交互，例如 "Go to the office to check the person."。然后机器人会自动前往指定位置并按照指示执行目标检测任务。

下图展示了运行远程助手示例的自主移动机器人（AMR）：

<Frame caption="模拟办公环境中的远程助手运行结果。">
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/qualcomm-prod/zh/SDKs/QIR-SDK-Ubuntu/images/image28.gif" alt="Simulated office in Gazebo where the robot navigates to a desk area while a terminal logs the navigation goal and the detection task." />
</Frame>

## 管道流程

下图展示了 `simulation_remote_assistant` 的管道：

<Frame caption="simulation-remote-assistant 管道。">
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/qualcomm-prod/zh/SDKs/QIR-SDK-Ubuntu/images/image30.svg" alt="Pipeline in three stages: build map, navigation preparation, and task execution with the YOLO object detection nodes." />
</Frame>

## `simulation_remote_assistant` 管道中使用的 ROS 节点

下表描述了 `simulation_remote_assistant` 管道中使用的 ROS 节点。

| 节点名                                | 说明                                                                                                                              |
| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| `qrb_ros_simulation`               | 设置 Qualcomm® Robotics 仿真环境。参见 `qrb_ros_simulation`。                                                                             |
| `nn_inference_node`                | 加载已训练的 AI 模型，接收预处理后的图像，执行推理，并发布结果。参见 GitHub 上的 [nn\_inference\_node](https://github.com/qualcomm-qrb-ros/qrb_ros_nn_inference)。 |
| `yolo_preprocess_node`             | 对 Yolo 模型执行预处理和后处理。参见 GitHub 上的 [qrb\_ros\_tensor\_process](https://github.com/qualcomm-qrb-ros/qrb_ros_tensor_process)。        |
| `yolo_detection_postprocess_node`  | 对 Yolo 模型执行预处理和后处理。参见 GitHub 上的 [qrb\_ros\_tensor\_process](https://github.com/qualcomm-qrb-ros/qrb_ros_tensor_process)。        |
| `yolo_detection_overlay_node`      | 对 Yolo 模型执行预处理和后处理。参见 GitHub 上的 [qrb\_ros\_tensor\_process](https://github.com/qualcomm-qrb-ros/qrb_ros_tensor_process)。        |
| `cartographer_node`                | 处理传感器数据以执行同步定位与建图 (SLAM)。                                                                                                       |
| `cartographer_occupancy_grid_node` | 发布 ROS 占用栅格地图。                                                                                                                  |
| `nav2_bringup`                     | 用于机器人导航的 Navigation2 栈。                                                                                                         |
| `build_map_node`                   | 构建办公环境的地图。                                                                                                                      |
| `nav_preparation_node`             | 重定位并启动导航节点。                                                                                                                     |
| `task_manager_node`                | 解析输入命令并运行动作。                                                                                                                    |

## `simulation_remote_assistant` 管道中使用的 ROS 话题

下表描述了 `simulation_remote_assistant` 管道中使用的 ROS 话题。

| ROS 话题                        | 类型                                            | 说明                                        |
| ----------------------------- | --------------------------------------------- | ----------------------------------------- |
| `/scan`                       | `<sensor_msgs::msg::LaserScan>`               | 用于 SLAM 和建图的 2D 激光雷达数据。                   |
| `/map`                        | `<nav_msgs::msg::OccupancyGrid>`              | 用于导航的占用栅格地图。                              |
| `/tf`                         | `<tf2_msgs::msg::TFMessage>`                  | 坐标系之间的变换。                                 |
| `/odom`                       | `<nav_msgs::msg::Odometry>`                   | 用于姿态估计的里程计数据。                             |
| `/cmd_vel`                    | `<geometry_msgs::msg::Twist>`                 | 机器人运动的速度命令。                               |
| `/goal_pose`                  | `<geometry_msgs::msg::PoseStamped>`           | 导航的目标位姿。                                  |
| `/camera/color/image_raw`     | `<sensor_msgs::msg::Image>`                   | 来自仿真摄像头的 RGB 图像。                          |
| `/qrb_inference_input_tensor` | `<qrb_ros_tensor_list_msgs::msg::TensorList>` | `yolo_preprocess_node` 预处理后的张量。           |
| `/yolo_detect_result`         | `<vision_msgs::msg::Detection2DArray>`        | `nn_inference_node` 发布检测结果。               |
| `/yolo_detect_tensor_output`  | `<qrb_ros_tensor_list_msgs::msg::TensorList>` | `yolo_detection_postprocess_node` 后处理的张量。 |
| `/yolo_detect_overlay`        | `<sensor_msgs::msg::Image>`                   | 带有边界框的检测结果。                               |

## 前提条件

你已根据[安装 QIR SDK](./install-the-qir-sdk)完成设备设置，并在设备上安装了 ROS2 Jazzy 和 Qualcomm Intelligent Robotics (QIR) SDK。

## 开箱即用运行 `simulation_remote_assistant`

<Steps>
  <Step title="在主机上设置仿真示例环境">
    a. 根据 [qrb\_ros\_simulation](https://github.com/qualcomm-qrb-ros/qrb_ros_simulation/tree/main) 的 README 准备仿真环境。

    b. 设置仿真办公环境。

    ```bash Set up environment theme={null}
    source /opt/ros/jazzy/setup.bash
    export ROS_DOMAIN_ID=78       
    ```

    ```bash Launch the simulation office world        theme={null}
    ros2 launch qrb_ros_sim_gazebo gazebo_robot_base_mini.launch.py \
       world_model:=office \
       initial_x:=1.0 \
       initial_y:=6.0 \
       enable_depth_camera:=false
    ```
  </Step>

  <Step title="安装 simulation-remote-assistant 包">
    ```bash theme={null}
    sudo apt install ros-jazzy-simulation-remote-assistant
    ```
  </Step>

  <Step title="下载 yolo 目标检测模型">
    a. 根据 [qrb\_ros\_tensor\_process](https://github.com/qualcomm-qrb-ros/qrb_ros_tensor_process/tree/main/cv_tensor_process/yolo_v8_process) 的 README 构建并下载 yolo 模型。

    b. 运行以下命令：

    ```bash Prepare the model and move to the default model path        theme={null}
    sudo chmod -R 777 /opt/
    mkdir /opt/model/
    mv coco8.yaml yolov8_det_qcs9075.bin yolov8_det_qcs8275.bin /opt/model/
    ```
  </Step>

  <Step title="在设备上运行远程助手示例">
    a. 设置环境并运行 `map_nav_setup.launch.py` 脚本进行自动建图。

    ```bash Set up the environment theme={null}
    source /opt/ros/jazzy/setup.bash
    export ROS_DOMAIN_ID=78
    ```

    ```bash title="Launch the map_nav_setup.launch.py scripts" theme={null}
    ros2 launch simulation_remote_assistant map_nav_setup.launch.py     
    ```

    b. 启动 yolo 目标检测脚本。

    <CodeGroup title="Launch the yolo object detection script">
      ```bash VentunoQ (IQ-8275 series) theme={null}
      ros2 launch simulation_remote_assistant yolo_detectcion.launch.py model:=/opt/model/yolov8_det_qcs8275.bin backend_option:=libQnnHtp.so label_file:=/opt/model/coco8.yaml    
      ```

      ```bash Qualcomm Dragonwing™ IQ-9075 EVK theme={null}
      ros2 launch simulation_remote_assistant yolo_detectcion.launch.py model:=/opt/model/yolov8_det_qcs9075.bin backend_option:=libQnnHtp.so label_file:=/opt/model/coco8.yaml       
      ```
    </CodeGroup>

    c. 运行 task manager 以解析位置和目标。

    ```bash theme={null}
    ros2 run simulation_remote_assistant task_manager_node
    ```

    d. 在终端中输入任务命令。

    ```bash theme={null}
    go to office to check person
    ```
  </Step>
</Steps>

## 从源码构建 `simulation_remote_assistant`

当你需要修改示例代码时，可以从源码构建 `simulation_remote_assistant`。设备端步骤包括安装依赖、克隆源码仓库和构建包。

### 设备步骤

<Steps>
  <Step title="安装依赖">
    ```bash theme={null}
    sudo apt install ros-dev-tools
    ```
  </Step>

  <Step title="从 qrb-ros-sample 仓库下载源码">
    ```bash theme={null}
    mkdir -p ~/qrb_ros_sample_ws/src && cd ~/qrb_ros_sample_ws/src
    git clone -b jazzy-rel https://github.com/qualcomm-qrb-ros/qrb_ros_samples.git
    ```
  </Step>

  <Step title="从源码构建示例">
    ```bash theme={null}
    cd ~/qrb_ros_sample_ws/src/qrb_ros_samples/robotics/simulation_remote_assistant
    rosdep install -i --from-path ./ --rosdistro jazzy -y
    colcon build
    source install/setup.bash
    ```
  </Step>

  <Step title="运行并测试示例">
    根据[开箱即用运行 simulation\_remote\_assistant](./experience-remote-assistant-in-the-simulator-with-simulation_remote_assistant#run-out-of-the-box-simulation_remote_assistant) 的步骤 2-4 运行并测试。
  </Step>
</Steps>
