# 带距离传感器的 ROS

## ROS 距离传感器使用[¶](https://ardupilot.org/dev/docs/ros-distance-sensors.html#ros-distance-sensor-usage)

### 距离传感器消息[¶](https://ardupilot.org/dev/docs/ros-distance-sensors.html#distance-sensor-message)

ArduPilot支持[距离传感器消息](https://mavlink.io/en/messages/common.html#DISTANCE_SENSOR)作为输入和输出。 以下章节将解释如何将距离传感器与ROS一起使用：

* 测距仪：如何从FCU中的测距器插头（例如pixhawk）接收数据以及如何将数据从ROS发送到FCU
* 邻近：如何从FCU从邻近度库接收数据以及如何将360度激光雷达数据发送到FCU

### 测距[¶](https://ardupilot.org/dev/docs/ros-distance-sensors.html#rangefinder)

#### 从金融情报局接收[¶](https://ardupilot.org/dev/docs/ros-distance-sensors.html#receive-from-fcu)

警告

距离传感器消息当前支持：

* ArduPilot Master
* 直升机>= 3.5.1（计划）
* 漫游车>= 3.2.0（计划）
* 平面>= 3.8.0（计划）

默认情况下，ArduPilot将为Rover上FCU上连接的每个测距仪发送距离传感器消息，并且仅在直升机和飞机上向下（PITCH\_270）。 示例：启动 SITL 并添加模拟测距仪，[请参阅此处的 SITL 说明](https://ardupilot.org/dev/docs/using-sitl-for-ardupilot-testing.html#adding-a-virtual-rangefinder)。 使用默认配置启动 MAVROS。您应该在 /mavros/distance\_sensor/rangefinder\_pub 中拥有测距仪数据。

```
Configuration in apm_config.yaml:
distance_sensor:    <== plugin name
  rangefinder_pub:  <== ROS publisher name
    id: 0             <== sensor instance number starting at 0
    frame_id: "lidar" <== frame name for TF
    #orientation: PITCH_270 # sended by FCU
    field_of_view: 0.0  <== sensor FOV see `ROS instructions here <http://docs.ros.org/api/sensor_msgs/html/msg/Range.html>`__
```

#### 发送到金融情报局[¶](https://ardupilot.org/dev/docs/ros-distance-sensors.html#send-to-fcu)

例如，ArduPilot支持接收来自Companion Computer的测距仪数据。 为此，请在ArduPilot端设置一个MAVLink测距仪，只需在MAVROS插件中设置一个订户：

```
Configuration in apm_config.yaml:
distance_sensor:       <== plugin name
  rangefinder_sub:     <== ROS subscriber name
    subscriber: true   <== set subscriber type
    id: 1              <== sensor instance number must match the one set on ArduPilot side
    orientation: PITCH_270  <== only that orientation are supported by Copter 3.4+
```

现在，在 /mavros/distance\_sensor/rangefinder\_sub 上发布 sensor\_msgs/Range 消息。 使用 GCS，您可以在测距仪测量中查看数据。

### 接近[¶](https://ardupilot.org/dev/docs/ros-distance-sensors.html#proximity)

警告

进行中的工作

我们热衷于改进ArduPilot对ROS的支持，因此如果您发现问题（例如似乎不支持的命令），请在[ArduPilot问题列表中](https://github.com/ArduPilot/ardupilot/issues)报告它们，标题包含“ROS”，我们将尝试尽快解决这些问题。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://yuelan-icus-organization.gitbook.io/pei-tao-ji-suan-ji/ros/dai-ju-li-chuan-gan-qi-de-ros.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
