PS. header-only库是一种“无需编译,包含头文件就可以用”的库。
MAVLink的应用
MAVLink主要用于地面控制站(GCS, Ground Control Station)与无人机之间的通信,以及载具内部子系统间的通信。它可以用来传输载具的方位、GPS位置以及速度。
MAVLink包结构
在1.0版本中包的结构如下:
版本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>
MAVLink生态圈
MAVLink在很多项目中作为通信协议使用,这可能意味着它们之间存在一定的兼容性。有人已经编写了一个有趣的教程[11]来解释MAVLink的基础知识。
参考
-
^ "Serialization · MAVLink Developer Guide". mavlink.io. Retrieved 2019-08-22.
-
^ "GitHub - ArduPilot/pymavlink: python MAVLink interface and utilities". August 18, 2019 – via GitHub.
-
^ "GitHub - arthurbenemann/droidplanner: Ground Control Station for Android Devices". July 2, 2019 – via GitHub.
-
^ "A Java code generator and a Java library for MAVLink: ghelle/MAVLinkJava". August 4, 2019 – via GitHub.
-
"GitHub - dronefleet/mavlink: A Java API for MAVLink communication". August 2, 2019 – via GitHub.
-
^ "GitHub - mavlink/mavlink: Marshalling / communication library for drones". August 20, 2019 – via GitHub.
-
^http://qgroundcontrol.org/mavlink/crc_extra_calculation#field_reordering
-
^ 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.