MAVLink or Micro Air Vehicle Link is a protocol for communicating with small unmanned vehicle. It is designed as a header-only message marshalling library. MAVLink was first released early 2009[1] by Lorenz Meier under the terms of the GNU Lesser General Public License (LGPL).[2]

Applications

edit

It is used mostly for communication between a Ground Control Station (GCS) and unmanned vehicles, 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

edit

In version 1.0 the packet structure is the following:

Field name Index (Bytes) Purpose
Start-of-frame 0 Denotes the start of frame transmission (v1.0: 0xFE)
Payload length 1 Length of payload (n)
Packet sequence 2 Each component counts up their send sequence. Allows for detection of packet loss.
System ID 3 Identification of the SENDING system. Allows differentiating different systems on the same network.
Component ID 4 Identification of the SENDING component. Allows differentiating different components of the same system, e.g. the IMU and the autopilot.
Message ID 5 Identification of the message - the ID defines what the payload "means" and how it should be correctly decoded.
Payload 6 to (n+6) The message data, depends on the message ID.
CRC (n+7) to (n+8) Checksum of the entire packet, excluding the packet start sign (LSB to MSB)

After Version 2, the packet structure was expanded into the following:[3]

Field name Index (Bytes) Purpose
Start-of-frame 0 Denotes the start of frame transmission (v2: 0xFD)
Payload length 1 Length of payload (n)
incompatibility flags 2 Flags that must be understood for MAVLink compatibility
compatibility flags 3 Flags that can be ignored if not understood
Packet sequence 4 Each component counts up their send sequence. Allows for detection of packet loss.
System ID 5 Identification of the SENDING system. Allows differentiating different systems on the same network.
Component ID 6 Identification of the SENDING component. Allows differentiating different components of the same system, e.g. the IMU and the autopilot.
Message ID 7 to 9 Identification of the message - the ID defines what the payload "means" and how it should be correctly decoded.
Payload 10 to (n+10) The message data, depends on the message ID.
CRC (n+11) to (n+12) Checksum of the entire packet, excluding the packet start sign (LSB to MSB)
Signature (n+13) to (n+25) Signature to verify that messages originate from a trusted source. (optional)

CRC field

edit

To ensure message integrity, a cyclic redundancy check (CRC) is calculated for each message up to the last two bytes. Another function of the CRC field is to ensure the sender and receiver both agree on 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, and 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 each new message set of the protocol, and it is hashed in a similar way as the packets from each message specification. Systems using the MAVLink protocol can use a precomputed array for this purpose.[4]

The CRC algorithm of MAVLink has been implemented in many languages, including Python[5] and Java.[6][7][8]

Messages

edit

The payloads from the packets described above are MAVLink messages. Each message is identifiable by the ID field on the packet, and the payload contains the data from the message. An XML document in the MAVlink source[9] has the definition of the data stored in this payload.

Below is the message with ID 24 extracted from the XML document.

<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 vertical 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>

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[10] to reduce Data structure alignment issues. This can be a source of confusion when reading the code generated from the message definitions.

edit

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.[11]

See also

edit

References

edit
  1. ^ "Initial commit · mavlink/mavlink@a087528". GitHub.
  2. ^ "MAVLink Micro Air Vehicle Communication Protocol - QGroundControl GCS". Archived from the original on 2018-08-18. Retrieved 2013-07-31.
  3. ^ "Serialization · MAVLink Developer Guide". mavlink.io. Retrieved 2019-08-22.
  4. ^ "Field Reordering and CRC Extra Calculation - QGroundControl GCS". qgroundcontrol.org. Archived from the original on 2013-06-15.
  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. ^ "Field Reordering and CRC Extra Calculation - QGroundControl GCS". qgroundcontrol.org. Archived from the original on 2013-06-15.
  11. ^ Balasubramanian, Shyam (15 November 2013). "MAVLink Tutorial for Absolute Dummies (Part –I)". diydrones.com.

📚 Artikel Terkait di Wikipedia

ExpressLRS

telemetry, around 100bps-20kbps dependent on settings Telemetry support: MAVLink telemetry can be carried over ExpressLRS from Ardupilot or PX4 vehicles

Auterion

Unit (DIU), made the decision to standardize on the PX4 autopilot and MAVLink communication protocol for its Blue sUAS architecture. Auterion was contracted

Pixhawk

allowed the team to interface with the drone while it was in flight, the MAVLink communication protocol that was custom developed for streaming telemetry

List of TCP and UDP port numbers

VERITAS) 13786 Yes Symantec nomdb (formerly VERITAS) 14550 Unofficial MAVLink Ground Station Port 14567 Unofficial Battlefield 1942 and mods 14652 Unofficial

PX4 autopilot

software, such as the QGroundControl ground control station software, via the MAVLink protocol (though they provide limited px4 -> Unity documentation). PX4

Remote ID

transmission rate of 5 Hz is required. EP patent 3369083B1  MAVLink Development Team. "Open Drone ID". MAVLink Developer Guide. Retrieved 2025-01-04. Malinen, Jouni

ThunderFly TF-G2

additional equipment. TF-G2 autogyro uses a radio transmission with a MAVLink protocol to communicate with a ground station. At the same time, the data

ArduPilot

automatic testing and simulation capabilities for Ardupilot, along with PyMavlink and Mavproxy. Hickey was instrumental in bringing the AP_HAL library to