MAVLink笔记 #01# 维基百科翻(译)

本文内容翻译自维基百科,仅供学习交流。

MAVLink(Micro Air Vehicle Link)是一种用于与小型无人机通信的协议。它被设计为一个header-only消息封送处理库。MAVLink由Lorenz Meier在LGPL许可下[2]于2009[1]年初发布。

PS. header-only库是一种“无需编译,包含头文件就可以用”的库。

MAVLink的应用

MAVLink主要用于地面控制站(GCS, Ground Control Station)与无人机之间的通信,以及载具内部子系统间的通信。它可以用来传输载具的方位、GPS位置以及速度。

MAVLink包结构

在1.0版本中包的结构如下:

PS. 0xFE = 254,即一个十进制值为254的字节标识着一个新的MAVLink消息包的开始。

版本2之后,包结构扩展为以下[3]:

PS. 0xFD = 253

CRC字段

详见原文。[4][5][6][7][8]

该字段主要用于确保消息包的完整性。MAVLink的循环冗余检查算法已经在Python和Java等多种语言中实现。

MAVLink消息

上述数据包中的有效负载就是MAVLink消息。每条消息都由包上的ID字段进行标识,有效负载包含来自消息的数据。MAVlink源码[9]中的XML文档定义了存储在此有效负载中的数据。

下面是从XML文档中提取的ID为24的消息。

<message id="24" name="GPS_RAW_INT">
        <description>The global position, as returned by the Global Positioning System (GPS). This is NOT the global position estimate of the system, but rather a RAW sensor value. See message GLOBAL_POSITION for the global position estimate. Coordinate frame is right-handed, Z-axis up (GPS frame).</description>
        <field type="uint64_t" name="time_usec">Timestamp (microseconds since UNIX epoch or microseconds since system boot)</field>
        <field type="uint8_t" name="fix_type">0-1: no fix, 2: 2D fix, 3: 3D fix. Some applications will not use the value of this field unless it is at least two, so always correctly fill in the fix.</field>
        <field type="int32_t" name="lat">Latitude (WGS84), in degrees * 1E7</field>
        <field type="int32_t" name="lon">Longitude (WGS84), in degrees * 1E7</field>
        <field type="int32_t" name="alt">Altitude (WGS84), in meters * 1000 (positive for up)</field>
        <field type="uint16_t" name="eph">GPS HDOP horizontal dilution of position in cm (m*100). If unknown, set to: UINT16_MAX</field>
        <field type="uint16_t" name="epv">GPS VDOP horizontal dilution of position in cm (m*100). If unknown, set to: UINT16_MAX</field>
        <field type="uint16_t" name="vel">GPS ground speed (m/s * 100). If unknown, set to: UINT16_MAX</field>
        <field type="uint16_t" name="cog">Course over ground (NOT heading, but direction of movement) in degrees * 100, 0.0..359.99 degrees. If unknown, set to: UINT16_MAX</field>
        <field type="uint8_t" name="satellites_visible">Number of satellites visible. If unknown, set to 255</field>
</message>

注意:XML文档描述了协议字段的逻辑顺序。实际的连线格式(以及典型的内存表示)对字段重新排序[10],以减少数据结构对齐问题。在阅读从消息定义生成的代码时,这可能会造成混淆。

MAVLink生态圈

MAVLink在很多项目中作为通信协议使用,这可能意味着它们之间存在一定的兼容性。有人已经编写了一个有趣的教程[11]来解释MAVLink的基础知识。

参考

  1.  "Initial commit · mavlink/mavlink@a087528"GitHub.

  2. ^ http://qgroundcontrol.org/mavlink/start

  3. ^ "Serialization · MAVLink Developer Guide"mavlink.io. Retrieved 2019-08-22.

  4. ^ http://qgroundcontrol.org/mavlink/crc_extra_calculation

  5. ^ "GitHub - ArduPilot/pymavlink: python MAVLink interface and utilities". August 18, 2019 – via GitHub.

  6. ^ "GitHub - arthurbenemann/droidplanner: Ground Control Station for Android Devices". July 2, 2019 – via GitHub.

  7. ^ "A Java code generator and a Java library for MAVLink: ghelle/MAVLinkJava". August 4, 2019 – via GitHub.

  8.  "GitHub - dronefleet/mavlink: A Java API for MAVLink communication". August 2, 2019 – via GitHub.

  9. ^ "GitHub - mavlink/mavlink: Marshalling / communication library for drones". August 20, 2019 – via GitHub.

  10. ^http://qgroundcontrol.org/mavlink/crc_extra_calculation#field_reordering

  11. ^ Posted by Shyam Balasubramanian on November 15, 2013 at 2:36pm in ArduCopter User Group; Discussions, Back to ArduCopter User Group. "MAVLink Tutorial for Absolute Dummies (Part –I)"diydrones.com.

原文地址:https://www.cnblogs.com/xkxf/p/12240346.html