MAVLink

Last updated

MAVLink or Micro Air Vehicle Link is a protocol for communicating with small unmanned vehicle. It is designed as a header-only message marshaling library. MAVLink was first released early 2009 [1] by Lorenz Meier under the LGPL license. [2]

Contents

Applications

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

In version 1.0 the packet structure is the following:

Field nameIndex (Bytes)Purpose
Start-of-frame0Denotes the start of frame transmission (v1.0: 0xFE)
Payload-length1length of payload (n)
Packet sequence2Each component counts up their send sequence. Allows for detection of packet loss.
System ID3Identification of the SENDING system. Allows to differentiate different systems on the same network.
Component ID4Identification of the SENDING component. Allows to differentiate different components of the same system, e.g. the IMU and the autopilot.
Message ID5Identification of the message - the id defines what the payload “means” and how it should be correctly decoded.
Payload6 to (n+6)The data into the message, depends on the message id.
CRC (n+7) to (n+8)Check-sum 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 nameIndex (Bytes)Purpose
Start-of-frame0Denotes the start of frame transmission (v2: 0xFD)
Payload-length1length of payload (n)
incompatibility flags2Flags that must be understood for MAVLink compatibility
compatibility flags3Flags that can be ignored if not understood
Packet sequence4Each component counts up their send sequence. Allows for detection of packet loss.
System ID5Identification of the SENDING system. Allows to differentiate different systems on the same network.
Component ID6Identification of the SENDING component. Allows to differentiate different components of the same system, e.g. the IMU and the autopilot.
Message ID7 to 9Identification of the message - the id defines what the payload “means” and how it should be correctly decoded.
Payload10 to (n+10)The data into the message, depends on the message id.
CRC (n+11) to (n+12)Check-sum 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

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

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

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

<messageid="24"name="GPS_RAW_INT"><description>Theglobalposition,asreturnedbytheGlobalPositioningSystem(GPS).ThisisNOTtheglobalpositionestimateofthesystem,butratheraRAWsensorvalue.SeemessageGLOBAL_POSITIONfortheglobalpositionestimate.Coordinateframeisright-handed,Z-axisup(GPSframe).</description><fieldtype="uint64_t"name="time_usec">Timestamp(microsecondssinceUNIXepochormicrosecondssincesystemboot)</field><fieldtype="uint8_t"name="fix_type">0-1:nofix,2:2Dfix,3:3Dfix.Someapplicationswillnotusethevalueofthisfieldunlessitisatleasttwo,soalwayscorrectlyfillinthefix.</field><fieldtype="int32_t"name="lat">Latitude(WGS84),indegrees*1E7</field><fieldtype="int32_t"name="lon">Longitude(WGS84),indegrees*1E7</field><fieldtype="int32_t"name="alt">Altitude(WGS84),inmeters*1000(positiveforup)</field><fieldtype="uint16_t"name="eph">GPSHDOPhorizontaldilutionofpositionincm(m*100).Ifunknown,setto:UINT16_MAX</field><fieldtype="uint16_t"name="epv">GPSVDOPverticaldilutionofpositionincm(m*100).Ifunknown,setto:UINT16_MAX</field><fieldtype="uint16_t"name="vel">GPSgroundspeed(m/s*100).Ifunknown,setto:UINT16_MAX</field><fieldtype="uint16_t"name="cog">Courseoverground(NOTheading,butdirectionofmovement)indegrees*100,0.0..359.99degrees.Ifunknown,setto:UINT16_MAX</field><fieldtype="uint8_t"name="satellites_visible">Numberofsatellitesvisible.Ifunknown,setto255</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.

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]

Related Research Articles

ping (networking utility) Network utility used to test the reachability of a host

ping is a computer network administration software utility used to test the reachability of a host on an Internet Protocol (IP) network. It is available for virtually all operating systems that have networking capability, including most embedded network administration software.

The Real-time Transport Protocol (RTP) is a network protocol for delivering audio and video over IP networks. RTP is used in communication and entertainment systems that involve streaming media, such as telephony, video teleconference applications including WebRTC, television services and web-based push-to-talk features.

The Transmission Control Protocol (TCP) is one of the main protocols of the Internet protocol suite. It originated in the initial network implementation in which it complemented the Internet Protocol (IP). Therefore, the entire suite is commonly referred to as TCP/IP. TCP provides reliable, ordered, and error-checked delivery of a stream of octets (bytes) between applications running on hosts communicating via an IP network. Major internet applications such as the World Wide Web, email, remote administration, and file transfer rely on TCP, which is part of the Transport layer of the TCP/IP suite. SSL/TLS often runs on top of TCP.

In computer networking, the User Datagram Protocol (UDP) is one of the core communication protocols of the Internet protocol suite used to send messages to other hosts on an Internet Protocol (IP) network. Within an IP network, UDP does not require prior communication to set up communication channels or data paths.

In telecommunications and computer networking, a network packet is a formatted unit of data carried by a packet-switched network. A packet consists of control information and user data; the latter is also known as the payload. Control information provides data for delivering the payload. Typically, control information is found in packet headers and trailers.

SOCKS is an Internet protocol that exchanges network packets between a client and server through a proxy server. SOCKS5 optionally provides authentication so only authorized users may access a server. Practically, a SOCKS server proxies TCP connections to an arbitrary IP address, and provides a means for UDP packets to be forwarded. A SOCKS server accepts incoming client connection on TCP port 1080, as defined in RFC 1928.

In computer programming, volatile means that a value is prone to change over time, outside the control of some code. Volatility has implications within function calling conventions, and also impacts how variables are stored, accessed and cached.

Datagram Transport Layer Security (DTLS) is a communications protocol providing security to datagram-based applications by allowing them to communicate in a way designed to prevent eavesdropping, tampering, or message forgery. The DTLS protocol is based on the stream-oriented Transport Layer Security (TLS) protocol and is intended to provide similar security guarantees. The DTLS protocol datagram preserves the semantics of the underlying transport—the application does not suffer from the delays associated with stream protocols, but because it uses UDP or SCTP, the application has to deal with packet reordering, loss of datagram and data larger than the size of a datagram network packet. Because DTLS uses UDP or SCTP rather than TCP, it avoids the "TCP meltdown problem", when being used to create a VPN tunnel.

<span class="mw-page-title-main">JSON</span> Open standard file format and data interchange

JSON is an open standard file format and data interchange format that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and arrays. It is a commonly used data format with diverse uses in electronic data interchange, including that of web applications with servers.

CRC-based framing is a kind of frame synchronization used in Asynchronous Transfer Mode (ATM) and other similar protocols.

Real-Time Messaging Protocol (RTMP) is a communication protocol for streaming audio, video, and data over the Internet. Originally developed as a proprietary protocol by Macromedia for streaming between Flash Player and the Flash Communication Server, Adobe has released an incomplete version of the specification of the protocol for public use.

Within communication protocols, TLV is an encoding scheme used for informational elements. A TLV-encoded data stream contains code related to the record type, the record value's length, and finally the value itself.

Action Message Format (AMF) is a binary format used to serialize object graphs such as ActionScript objects and XML, or send messages between an Adobe Flash client and a remote service, usually a Flash Media Server or third party alternatives. The Actionscript 3 language provides classes for encoding and decoding from the AMF format.

Protocol Buffers (Protobuf) is a free and open-source cross-platform data format used to serialize structured data. It is useful in developing programs that communicate with each other over a network or for storing data. The method involves an interface description language that describes the structure of some data and a program that generates source code from that description for generating or parsing a stream of bytes that represents the structured data.

Generic Stream Encapsulation, or GSE for short, is a Data link layer protocol defined by DVB. GSE provides means to carry packet oriented protocols such as IP on top of uni-directional physical layers such as DVB-S2, DVB-T2 and DVB-C2.

ISO 15765-2, or ISO-TP (Transport Layer), is an international standard for sending data packets over a CAN-Bus. The protocol allows for the transport of messages that exceed the eight byte maximum payload of CAN frames. ISO-TP segments longer messages into multiple frames, adding metadata (CAN-TP Header) that allows the interpretation of individual frames and reassembly into a complete message packet by the recipient. It can carry up to 232-1 (4294967295) bytes of payload per message packet starting from the 2016 version. Prior version were limited to a maximum payload size of 4095 bytes.

The Stream Control Transmission Protocol (SCTP) is a computer networking communications protocol in the transport layer of the Internet protocol suite. Originally intended for Signaling System 7 (SS7) message transport in telecommunication, the protocol provides the message-oriented feature of the User Datagram Protocol (UDP), while ensuring reliable, in-sequence transport of messages with congestion control like the Transmission Control Protocol (TCP). Unlike UDP and TCP, the protocol supports multihoming and redundant paths to increase resilience and reliability.

Universal Binary JSON (UBJSON) is a computer data interchange format. It is a binary form directly imitating JSON, but requiring fewer bytes of data. It aims to achieve the generality of JSON, combined with being much easier to process than JSON.

This article provides information about the communications aspects of Universal Serial Bus (USB): Signaling, Protocols, Transactions. USB is an industry-standard used to specify cables, connectors, and protocols that are used for communication between electronic devices. USB ports and cables are used to connect hardware such as printers, scanners, keyboards, mice, flash drives, external hard drives, joysticks, cameras, monitors, and more to computers of all kinds. USB also supports signaling rates from 1.5 Mbit/s to 80 Gbit/s depending on the version of the standard. The article explains how USB devices transmit and receive data using electrical signals over the physical layer, how they identify themselves and negotiate parameters such as speed and power with the host or other devices using standard protocols such as USB Device Framework and USB Power Delivery, and how they exchange data using packets of different types and formats such as token, data, handshake, and special packets.

References

  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.