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

# 使用 follow_me 启用人员跟踪

> follow_me 是一个轻量级应用，可让机器人实时跟踪目标。目前，它仅支持跟踪人员。

<Frame>
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/qualcomm-prod/zh/SDKs/QIR-SDK-Ubuntu/images/follow_me.gif" alt="Robot running the follow_me application as it detects a person and drives to keep pace behind them." />
</Frame>

## `follow_me` 的管道流程

下图展示了 `follow_me` 的管道流程。

<Frame caption="follow_me 管道。">
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/qualcomm-prod/zh/SDKs/QIR-SDK-Ubuntu/images/follow-me-pipeline.svg" alt="The follow_me pipeline from Orbbec camera color and depth streams through detection to velocity commands on the cmd_vel topic." />
</Frame>

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

下表列出了 `follow_me` 管道中使用的 ROS 节点，并说明了每个节点的功能。

| ROS 节点          | 说明                                                                           |
| --------------- | ---------------------------------------------------------------------------- |
| `follow_me`     | `follow_me` 是一个自定义 ROS2 节点，支持人员检测和姿态更新。它还可以为机器人计算必要的控制命令，并以标准 ROS2 格式发送这些命令。 |
| `orbbec_camera` | `orbbec_camera` 是 `OrbbecSDK` ROS2 wrapper，它在 ROS2 环境中提供 Orbbec 摄像头的集成。      |

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

下表列出了 `follow_me` 管道中使用的 ROS 话题，以及每个话题的消息类型和发布者。

| ROS 话题                      | 类型                             | 发布者             |
| --------------------------- | ------------------------------ | --------------- |
| `/camera/color/image_raw`   | `sensor_msgs::msg::Image`      | `orbbec-camera` |
| `/camera/depth/image_raw`   | `sensor_msgs::msg::Image`      | `orbbec-camera` |
| `/camera/color/camera_info` | `sensor_msgs::msg::CameraInfo` | `orbbec-camera` |
| `/cmd_vel`                  | `geometry_msgs::msg::Twist`    | Controller      |

## 前提条件

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

* 设置设备
* 设置主机

## 开箱即用运行 `follow_me`

<Steps>
  <Step title="安装依赖">
    ```bash Add the package repositories theme={null}
    sudo add-apt-repository ppa:ubuntu-qcom-iot/qcom-ppa
    sudo add-apt-repository ppa:ubuntu-qcom-iot/qirp
    sudo apt update
    ```
  </Step>

  <Step title="安装 sample_apriltag 包">
    ```bash Install the packages theme={null}
    sudo apt install ros-jazzy-orbbec-camera
    sudo apt install ros-jazzy-ncnn
    sudo apt install ros-jazzy-follow-me
    ```
  </Step>

  <Step title="下载模型文件">
    ```bash Download and install the model files theme={null}
    # Download label file
    wget https://raw.githubusercontent.com/amikelive/coco-labels/master/coco-labels-2014_2017.txt -O labels.txt
    # Download model weights
    wget https://raw.githubusercontent.com/dog-qiuqiu/FastestDet/main/example/ncnn/FastestDet.bin -O FastestDet.bin
    wget https://raw.githubusercontent.com/dog-qiuqiu/FastestDet/main/example/ncnn/FastestDet.param -O FastestDet.param
    # copy model files
    sudo mkdir -p /usr/share/follow-me/model/
    sudo cp FastestDet.bin FastestDet.param labels.txt /usr/share/follow-me/model/
    ```
  </Step>

  <Step title="设置机器人底座">
    * 如果你使用 Qualcomm 的机器人底座，请对其进行设置。

    * 如果你使用自定义或第三方机器人底座，请应用适合你自己机器人底座的配置。确保机器人底座能够在 `/odom` 话题上发布类型为 `nav_msgs.msg.Odometry2` 的里程计数据。
  </Step>

  <Step title="在新终端中设置 Orbbec 摄像头">
    ```bash Launch the Orbbec camera theme={null}
    # color & depth image
    export ROS_DOMAIN_ID=100
    source /opt/ros/jazzy/setup.sh
    ros2 launch orbbec_camera gemini_330_series.launch.py depth_registration:=true enable_depth:=true
    ```
  </Step>

  <Step title="运行 follow_me 二进制文件">
    ```bash Run follow_me theme={null}
    #run follow me
    export ROS_DOMAIN_ID=100
    source /opt/ros/jazzy/setup.sh
    follow_me
    ```
  </Step>
</Steps>

## 构建并运行 `follow_me`

<Warning>
  此示例应用仅供 `已授权` 用户使用。如果你想获取源代码，请参阅 [Working with Qualcomm](https://www.qualcomm.com/support/working-with-qualcomm)。
</Warning>

<Steps>
  <Step title="安装依赖">
    ```bash Install the dependencies theme={null}
    sudo add-apt-repository ppa:ubuntu-qcom-iot/qcom-ppa
    sudo add-apt-repository ppa:ubuntu-qcom-iot/qirp
    sudo apt update
    sudo apt install ncnn-dev
    ```
  </Step>

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

  <Step title="从源码构建示例">
    ```bash Build the sample theme={null}
    cd ~/qrb_ros_sample_ws/src/qrb_ros_samples/robotics/sample_followme/
    colcon build
    source install/setup.bash
    ```
  </Step>

  <Step title="运行并测试">
    根据[开箱即用运行 follow\_me](./followme#run-out-of-the-box-follow_me) 的步骤 4-6 运行并测试。
  </Step>
</Steps>
