# DroneKit

**DroneKit** 是一套开源应用程序编程接口，用于编写通过 MAVLink 协议与无人载具通信的无人机应用。其 Python 实现 DroneKit-Python（原 DroneAPI-Python）让开发者能够以编程方式访问所连接载具的遥测、状态与参数信息，并同时支持任务管理与对载具运动和操作的直接控制。<sup>[1](https://github.com/dronekit/dronekit-python)</sup> 它由无人机制造商 3D Robotics 于 2015 年 3 月 26 日推出。<sup>[2](https://techcrunch.com/2015/03/26/3d-robotics-launches-dronekit-its-api-for-building-drone-apps/)</sup>

| 关键事实 | 详情 |
|---|---|
| 它是什么 | 用于通过 MAVLink 与无人机通信的开源 Python API；原名 DroneAPI-Python<sup>[1](https://github.com/dronekit/dronekit-python)</sup> |
| 推出时间 | 2015 年 3 月 26 日，由当时美国最大的无人机制造商 3D Robotics 推出<sup>[2](https://techcrunch.com/2015/03/26/3d-robotics-launches-dronekit-its-api-for-building-drone-apps/)</sup> |
| 兼容载具 | 使用 APM（ArduPilot）自动驾驶仪的无人机，包括四旋翼、固定翼和地面车；不兼容大疆（DJI）无人机<sup>[2](https://techcrunch.com/2015/03/26/3d-robotics-launches-dronekit-its-api-for-building-drone-apps/)</sup> |
| 预期用途 | 主要用于机载伴随计算机（计算机视觉、路径规划、三维建模）；也用于通过较高延迟射频链路通信的地面站应用<sup>[1](https://github.com/dronekit/dronekit-python)</sup> |
| 许可证 | Apache 2.0<sup>[1](https://github.com/dronekit/dronekit-python)</sup> |
| 最终版本 | GitHub 发布版 2.9.1（2017 年 4 月 21 日）；PyPI 包 dronekit 2.9.2（2019 年 3 月 18 日）<sup>[3](https://github.com/dronekit/dronekit-python/releases)</sup><sup> • </sup><sup>[4](https://pypi.org/project/dronekit/)</sup> |
| 当前状态 | 已停止维护；代码库带有“需要维护者”的告示，另有一个仍在维护的分支 dronekit2<sup>[1](https://github.com/dronekit/dronekit-python)</sup><sup> • </sup><sup>[5](https://pypi.org/project/dronekit2/)</sup> |

## 用途与能力

DroneKit 将底层 MAVLink 消息协议封装在 Python 对象模型之后——MAVLink 是 [ArduPilot](https://www.edgepedia.org/zh/ardupilot)、PX4 等自动驾驶仪所使用的标准遥测与指令协议。借助该 API，开发者可以编写程序让载具沿路径飞行、跟随 GPS 目标、控制相机云台、获取遥测数据，并记录无人机的全部运动以供日后分析。<sup>[2](https://techcrunch.com/2015/03/26/3d-robotics-launches-dronekit-its-api-for-building-drone-apps/)</sup> 3D Robotics 将该库定位为一种让开发者无需自行编写飞控软件、即可编写单一用途应用（如农业测绘、搜救或航拍）的途径。<sup>[2](https://techcrunch.com/2015/03/26/3d-robotics-launches-dronekit-its-api-for-building-drone-apps/)</sup>

该 API 主要面向机载伴随计算机——即由无人机自身携带的小型计算机——以支持计算机视觉、路径规划和三维建模等用例。它也可用于通过较高延迟射频链路与载具通信的地面站应用。<sup>[1](https://github.com/dronekit/dronekit-python)</sup> 一个基础脚本会连接到载具端点，并从返回的 Vehicle 对象读取状态，例如打印当前飞行模式。<sup>[1](https://github.com/dronekit/dronekit-python)</sup>

## 载具状态与参数

Vehicle 类通过属性对外暴露大部分状态信息，包括位置、速度、姿态、电池、GPS 及类似数据。DroneKit-Python 定义了一组标准属性，包括 `Vehicle.location`（分别位于全局坐标系、全局相对坐标系与局部坐标系）、`Vehicle.attitude`、`Vehicle.velocity`、`Vehicle.gps_0`、`Vehicle.gimbal`、`Vehicle.battery`、`Vehicle.rangefinder`、`Vehicle.ekf_ok`、`Vehicle.last_heartbeat`、`Vehicle.home_location`、`Vehicle.system_status`、`Vehicle.heading`、`Vehicle.is_armable`、`Vehicle.airspeed`、`Vehicle.groundspeed`、`Vehicle.armed` 和 `Vehicle.mode`。<sup>[6](https://github.com/dronekit/dronekit-python/blob/master/docs/guide/vehicle_state_and_parameters.rst)</sup>

属性在创建时值为 `None`，随着载具发来的 MAVLink 消息到达而填充。所有属性均可读取，但只有一部分可以设置：`home_location`、`gimbal`、`airspeed`、`groundspeed`、`mode` 和 `armed`。几乎所有属性都可被观察，也就是说可以注册回调监听器，使代码无需轮询即可对变化作出反应。表示传感器数值流的属性会在每条消息到达时触发监听器，而 `system_status`、`armed` 和 `mode` 等状态属性只在取值发生变化时才发出通知。<sup>[6](https://github.com/dronekit/dronekit-python/blob/master/docs/guide/vehicle_state_and_parameters.rst)</sup>

载具参数——即针对载具硬件与能力配置自动驾驶仪的各项设置——通过 `Vehicle.parameters` 属性访问。DroneKit 在首次连接无人机时会下载全部参数，强制参数读取等待下载完成，此后通过监视载具消息中的单个参数变化来保持数值更新。因此，随时读取受支持的参数都是安全的，读到的值与载具上的值一致。<sup>[6](https://github.com/dronekit/dronekit-python/blob/master/docs/guide/vehicle_state_and_parameters.rst)</sup>

## 版本历史

DroneKit-Python 1.x 最初是 [MAVProxy](https://www.edgepedia.org/zh/mavproxy) 的一个扩展；2.0 版于 2015 年 11 月 23 日发布，将其改写为独立的 Python 模块。<sup>[3](https://github.com/dronekit/dronekit-python/releases)</sup><sup> • </sup><sup>[7](https://dronekit-python.readthedocs.io/en/latest/about/migrating.html)</sup> DKPY 2 以 `Vehicle.on_message()` 装饰器取代了 1.x 的 `set_mavlink_callback()` 机制——后者会为每条 MAVLink 消息调用一次回调，而前者可为单一消息类型注册回调，也可使用通配符 `*` 为所有消息注册回调，此外还提供 `add_message_listener()` 和 `remove_message_listener()` 用于可移除的监听器。它还用 `add_attribute_listener()` 和 `on_attribute()` 装饰器取代了属性观察器，并新增了 `system_status`、`heading`、`mount_status`、`ekf_ok`、`is_armable` 和 `last_heartbeat` 等属性。<sup>[7](https://dronekit-python.readthedocs.io/en/latest/about/migrating.html)</sup>

此后直至 2.9.1 的各版本增加了对 Python 3 的支持、对 PX4 飞行模式的正确支持，并将 pymavlink 依赖从 v1 迁移到 v2。<sup>[3](https://github.com/dronekit/dronekit-python/releases)</sup> 最后一个 PyPI 发布版 dronekit 2.9.2 于 2019 年 3 月 18 日面世。<sup>[4](https://pypi.org/project/dronekit/)</sup> 同系列的另一产品 DroneKit-Cloud 已于 2016 年 3 月 31 日关停。<sup>[8](https://robo4you.at/publications/BreakdownDrone.pdf)</sup>

## 维护状态与替代方案

DroneKit-Python 代码库带有一则题为“需要维护者”（MAINTAINERS NEEDED）的告示，声明该项目活跃度不高，并征集贡献者来处理持续集成（CI）和拉取请求。<sup>[1](https://github.com/dronekit/dronekit-python)</sup> 社区关于一个抢救项目的讨论指出，若无资金支持，该库将与 ArduPilot 主代码的能力差距越拉越大。<sup>[9](https://discuss.ardupilot.org/t/dronekit-python-rescue-project/48505)</sup> 由于它仍使用标准 MAVLink 通信，该库的许多部分仍可正常工作，但它并未针对当前的 PX4 或 ArduPilot 版本进行测试，兼容性问题也不太可能被迅速修复。<sup>[10](https://www.devpebble.com/blog/drone-programming/)</sup>

仍在维护的分支 dronekit2 称原包自 2019 年以来再无发布，且无法在现代 Python 上导入；该分支的目标是 Python 3.9 至 3.13。<sup>[5](https://pypi.org/project/dronekit2/)</sup> 对于新项目，目前的建议指向 [MAVSDK](https://www.edgepedia.org/zh/mavsdk)（高层次多语言 SDK）、pymavlink（仍在维护的底层 MAVLink 库）以及 [ROS 2](https://www.edgepedia.org/zh/ros-2) 配合 MAVROS，作为支持更好的起点。<sup>[10](https://www.devpebble.com/blog/drone-programming/)</sup> ArduPilot 社区的维护者也同样建议新工作使用 pymavlink 而非 DroneKit。<sup>[11](https://discuss.ardupilot.org/t/connection-error-problem-using-dronekit/94165)</sup>

## References

1. [DroneKit-Python GitHub repository](https://github.com/dronekit/dronekit-python)
2. [3D Robotics Launches DroneKit, Its API For Building Drone Apps, TechCrunch (March 26, 2015)](https://techcrunch.com/2015/03/26/3d-robotics-launches-dronekit-its-api-for-building-drone-apps/)
3. [Releases, dronekit/dronekit-python, GitHub](https://github.com/dronekit/dronekit-python/releases)
4. [dronekit, PyPI](https://pypi.org/project/dronekit/)
5. [dronekit2, PyPI](https://pypi.org/project/dronekit2/)
6. [Vehicle State and Settings, DroneKit Python documentation](https://github.com/dronekit/dronekit-python/blob/master/docs/guide/vehicle_state_and_parameters.rst)
7. [Migrating to DKPY 2.0, DroneKit Python documentation](https://dronekit-python.readthedocs.io/en/latest/about/migrating.html)
8. [BreakdownDrone (thesis, 2016)](https://robo4you.at/publications/BreakdownDrone.pdf)
9. [DroneKit-Python Rescue Project, ArduPilot Discourse](https://discuss.ardupilot.org/t/dronekit-python-rescue-project/48505)
10. [Drone programming: how to code, simulate, and control drones, DevPebble](https://www.devpebble.com/blog/drone-programming/)
11. [Connection error problem using dronekit, ArduPilot Discourse](https://discuss.ardupilot.org/t/connection-error-problem-using-dronekit/94165)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 工程与制造 › 机器人技术与自动化 › Aerial robots and drones › Autopilots and open-source flight software

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/dronekit

English original: https://www.edgepedia.org/dronekit
