# 从ROS连接到ArduPilot

## 与 ROS 连接[¶](https://ardupilot.org/dev/docs/ros-connecting.html#connecting-with-ros)

在尝试连接 ROS 之前，请确保已按照相应的配套计算机页面（[RPi3、](https://ardupilot.org/dev/docs/raspberry-pi-via-mavlink.html#raspberry-pi-via-mavlink)[NVidia TX1、NVidia TX2](https://ardupilot.org/dev/docs/companion-computer-nvidia-tx1.html#companion-computer-nvidia-tx1) 或[英特尔爱迪生](https://ardupilot.org/dev/docs/intel-edison.html#intel-edison)）上的说明设置了物理串行电缆连接和 ArduPilot 侧参数。

在飞行控制器上运行的ArduPilot和ROS/MAVROS之间的连接可以通过配套计算机上的以下命令建立：

* 打开一个终端并输入“roscore”
* 打开另一个终端并启动 Mavros，如 [Ros/Mavros wiki 上的描述](http://wiki.ros.org/mavros#Usage)。例如，以下说明适用于打开端口 2 的 TX14855/APSync 安装（请参阅[本页](https://ardupilot.org/dev/docs/apsync-intro.html#apsync-intro)底部的“如何将飞行控制器数据路由到各种程序”）：

```
roslaunch mavros apm.launch fcu_url:=udp://:14855@
```

测试飞行控制器是否响应mavros命令，如mavsys（可以设置飞行模式）和[mavsafety](http://wiki.ros.org/mavros#Utility_commands)（可以布防/撤防飞行器）：

```
rosrun mavros mavsys mode -c 0 (sets the vehicle to mode "0")
rosrun mavros mavsafety arm (to arm the vehicle)
```

注意

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

[以前](https://ardupilot.org/dev/docs/ros-install.html)[下一个](https://ardupilot.org/dev/docs/ros-slam.html)<br>


---

# 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/cong-ros-lian-jie-dao-ardupilot.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.
