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

# 使用 rplidar-ros2 启用基本的 RPLIDAR 处理

`rplidar-ros2` 示例应用程序为 2D 激光扫描仪 RPLIDAR A1/A2/A3/S1/S2/S3 提供基本的设备处理功能。

## `rplidar-ros2` 的管道流程

下图展示了 rplidar-ros2 示例的管道。该示例应用程序从 `rplidar` SDK 获取驱动数据，然后发布 `/scan` 话题。

<img
  src="https://mintcdn.com/qualcomm-staging/qMmE1ZLNeBAcOAi4/SDKs/QIR-SDK-2.0/media/80-65220-2-qirp-sdk-qsg/rplidar-ros2-pipeline.svg?fit=max&auto=format&n=qMmE1ZLNeBAcOAi4&q=85&s=26a0edc19602a53043c9c79741b844b4"
  style={{
width: "50%",
display: "block",
margin: "0 auto" }}
  width="362"
  height="402"
  data-path="SDKs/QIR-SDK-2.0/media/80-65220-2-qirp-sdk-qsg/rplidar-ros2-pipeline.svg"
/>

<p style={{ textAlign: 'center', fontWeight: 'bold' }}>
  图：rplidar-ros2 管道
</p>

## `rplidar-ros2 ` 管道中使用的 ROS 话题

<table>
  <thead>
    <tr>
      <th style={{ width: '15%' }}>ROS 话题</th>
      <th style={{ width: '25%' }}>消息类型</th>
      <th style={{ width: '25%' }}>发布/订阅者</th>
      <th style={{ width: '40%' }}>描述</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>`/scan`</td>
      <td>`sensor_msgs::msg::LaserScan`</td>
      <td>由 `rplidar-ros2` 发布</td>
      <td>`/scan` 话题发布来自 RPLIDAR 的激光扫描数据。</td>
    </tr>
  </tbody>
</table>

## 前提条件

* 您已按照[为运行示例应用程序设置环境](./set-up-env-for-sample-app)完成 **Set up the device**。

* 连接 RPLIDAR A3M1 的电源和 USB 端口。

## 运行开箱即用的 `rplidar-ros2`

1. 要在设备上设置 QIR SDK 和 ROS2 环境并运行 `rplidar-ros2`，请启动终端并运行以下命令：

<Accordion title="试一试">
  ```bash theme={null}
  ssh root@[ip-addr]
  ```

  ```shell SSH Terminal theme={null}
  source /usr/share/qirp-setup.sh
  ros2 launch rplidar_ros rplidar_a3_launch.py
  ```

  显示节点成功启动的终端日志示例

  ```bash theme={null}
  [INFO] [launch]: All log files can be found below /home/ubuntu/.ros/log/2026-08-12-02-11-07-846867-ubuntu-3237
  [INFO] [launch]: Default logging verbosity is set to INFO
  [INFO] [rplidar_node-1]: process started with pid [3241]
  [rplidar_node-1] [INFO] [1786500668.361267056] [rplidar_node]: RPLidar running on ROS2 package rplidar_ros. RPLIDAR SDK Version:2.0.0
  [rplidar_node-1] [INFO] [1786500668.407724891] [rplidar_node]: RPLidar S/N: FBE59AF2C1EA9FC0BEEB9CF374363200
  [rplidar_node-1] [INFO] [1786500668.407786032] [rplidar_node]: Firmware Ver: 1.26
  [rplidar_node-1] [INFO] [1786500668.407803166] [rplidar_node]: Hardware Rev: 6
  [rplidar_node-1] [INFO] [1786500668.459542330] [rplidar_node]: RPLidar health status : 0
  [rplidar_node-1] [INFO] [1786500668.459631645] [rplidar_node]: RPLidar health status : OK.
  [rplidar_node-1] [INFO] [1786500668.759812227] [rplidar_node]: current scan mode: Sensitivity, sample rate: 16 Khz, max_distance: 25.0 m, scan frequency:10.0 Hz,
  ```
</Accordion>

2. 要查看话题输出，请运行以下命令：

```bash theme={null}
ros2 topic echo /scan
```

**结果：**

```bash theme={null}
header:
  stamp:
    sec: 1786520383
    nanosec: 374856817
  frame_id: laser
angle_min: -3.1241390705108643
angle_max: 3.1415927410125732
angle_increment: 0.0034828970674425364
time_increment: 0.0009069791412912309
scan_time: 1.6316554546356201
range_min: 0.15000000596046448
range_max: 25.0
ranges:
- 0.37400001287460327
- 0.375
- 0.375
- 0.375
- 0.37400001287460327
- 0.37400001287460327
- 0.37400001287460327
- 0.375
- 0.375
- 0.375
- 0.375
- 0.375
- 0.375
- 0.375
- 0.375
- 0.375
- 0.375
- 0.375
- 0.375
- 0.375
- 0.375
- 0.375
- 0.375
- 0.375
- 0.37599998712539673
- 0.37599998712539673
- 0.375
- 0.37599998712539673
...
```

3. RViz 可视化截图如下

<img
  src="https://mintcdn.com/qualcomm-staging/qMmE1ZLNeBAcOAi4/SDKs/QIR-SDK-2.0/media/80-65220-2-qirp-sdk-qsg/rviz_laser.png?fit=max&auto=format&n=qMmE1ZLNeBAcOAi4&q=85&s=5dd1ff3d703b53922a65c5f655f72cba"
  style={{
width: "60%",
display: "block",
margin: "0 auto" }}
  width="1920"
  height="1080"
  data-path="SDKs/QIR-SDK-2.0/media/80-65220-2-qirp-sdk-qsg/rviz_laser.png"
/>

<p style={{ textAlign: 'center', fontWeight: 'bold' }}>
  图：RViz 上的可视化
</p>
