MAVLink or Micro Air Vehicle Link is a protocol for communicating with small
unmanned vehicle
An uncrewed vehicle or unmanned vehicle is a vehicle without a person on board. Uncrewed vehicles can either be under telerobotic control—remote controlled or remote guided vehicles—or they can be autonomously controlled—autonomous vehicl ...
. It is designed as a header-only message marshaling library. MAVLink was first released early 2009 by Lorenz Meier under the
LGPL license.
Applications
It is used mostly for communication between a
Ground Control Station (GCS) and
Unmanned vehicle
An uncrewed vehicle or unmanned vehicle is a vehicle without a person on board. Uncrewed vehicles can either be under telerobotic control—remote controlled or remote guided vehicles—or they can be autonomously controlled—autonomous vehicl ...
s, and in the inter-communication of the subsystem of the vehicle. It can be used to transmit the orientation of the vehicle, its GPS location and speed.
Packet Structure
In version 1.0 the packet structure is the following:
After Version 2, the packet structure was expanded into the following:
CRC field
To ensure message integrity a cyclic redundancy check (CRC) is calculated to every message into the last two bytes. Another function of the CRC field is to ensure the sender and receiver both agree in the message that is being transferred. It is computed using an ITU X.25/SAE AS-4 hash of the bytes in the packet, excluding the Start-of-Frame indicator (so 6+n+1 bytes are evaluated, the extra +1 is the seed value).
Additionally a seed value is appended to the end of the data when computing the CRC. The seed is generated with every new message set of the protocol, and it is hashed in a similar way as the packets from each message specifications. Systems using the MAVLink protocol can use a precomputed array to this purpose.
The CRC algorithm of MAVLink has been implemented in many languages, like Python and Java.
Messages
The payload from the packets described above are MAVLink messages. Every message is identifiable by the ID field on the packet, and the payload contains the data from the message. An
XML
Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. ...
document in the MAVlink source has the definition of the data stored in this payload.
Below is the message with ID 24 extracted from the XML document.
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).
Timestamp (microseconds since UNIX epoch or microseconds since system boot)
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.
Latitude (WGS84), in degrees * 1E7
Longitude (WGS84), in degrees * 1E7
Altitude (WGS84), in meters * 1000 (positive for up)
GPS HDOP horizontal dilution of position in cm (m*100). If unknown, set to: UINT16_MAX
GPS VDOP vertical dilution of position in cm (m*100). If unknown, set to: UINT16_MAX
GPS ground speed (m/s * 100). If unknown, set to: UINT16_MAX
Course over ground (NOT heading, but direction of movement) in degrees * 100, 0.0..359.99 degrees. If unknown, set to: UINT16_MAX
Number of satellites visible. If unknown, set to 255
Note: The XML document describes the logical ordering of the fields for the protocol. The actual wire format (and typical in-memory representation) has the fields reordered to reduce
Data structure alignment
Data structure alignment is the way data is arranged and accessed in computer memory. It consists of three separate but related issues: data alignment, data structure padding, and packing.
The CPU in modern computer hardware performs reads and ...
issues. This can be a source of confusion when reading the code generated from the message definitions.
MAVLink Ecosystem
MAVLink is used as the communication protocol in many projects, which may mean there is some compatibility between them. A tutorial explaining basics of MAVLink has been written.
References
{{Authority control
Serial buses
Unmanned aerial vehicles
Wireless
Avionics
Robotics
Emerging technologies
Application layer protocols