Mavlink Protocol
Introduction
MAVLink (Micro Air Vehicle Link) is a lightweight, open-source messaging protocol designed for communication between unmanned vehicles (such as drones, rovers, and underwater vehicles) and Ground Control Stations (GCS), as well as between onboard vehicle subsystems like autopilots, cameras, and gimbals.
Built as a header-only message marshalling library, MAVLink serializes structured system states and commands into compact binary byte streams. Because it adds very low overhead—just 8 bytes per packet in MAVLink 1 and 12 bytes in MAVLink 2—it works reliably over low-bandwidth, high-latency wireless telemetry links such as radio modems, LoRa, Wi-Fi, and serial connections.
Who Developed MAVLink and When?
-
Creator: MAVLink was created by Lorenz Meier at ETH Zurich.
-
Initial Release: It was first released in early 2009 under the GNU Lesser General Public License (LGPL).
-
Major Evolution: MAVLink 2.0 was introduced in early 2017 as the modern standard. It expanded the message ID space from 8 bits to 24 bits, added support for optional cryptographic packet signing for authentication, and introduced payload zero-trimming for better efficiency.
-
Current Governance: Today, the protocol is maintained as an open-source project under the Dronecode Project (a Linux Foundation collaborative project), with its message definitions and generated C libraries licensed under the permissive MIT License.
How MAVLink Works
MAVLink uses an XML-based message definition system combined with code generation:
-
XML Message Definitions: Every message type is defined inside XML dialect files (such as common.xml for universal messages or ardupilotmega.xml for platform-specific extensions). Each definition specifies a unique Message ID and the exact data fields inside the payload.
-
Code Generation (mavgen): Developers run a code generator (mavgen) against the XML files to auto-generate ready-to-use libraries in C, C++, Python (pymavlink), Java, Dart, Rust, Go, and JavaScript.
-
Packet Framing and Integrity: When a sender transmits a message, MAVLink wraps the payload with a Start-of-Frame marker (0xFE for v1, 0xFD for v2), payload length, packet sequence number (to detect dropped packets), System ID, Component ID, Message ID, and a 2-byte ITU X.25 CRC checksum to detect data corruption in transit.
-
Multi-System Addressing: Each node on a MAVLink network is identified by a System ID (up to 255 systems, such as individual drones or ground stations) and a Component ID (such as the flight controller, GPS module, or onboard companion computer), enabling seamless routing across complex multi-vehicle setups.
Where MAVLink Is Used
MAVLink is the de facto communication standard across open-source and commercial unmanned systems:
-
Autopilot Firmware: Powers telemetry and command exchange in PX4 and ArduPilot flight stacks.
-
Ground Control Stations (GCS): Used by desktop and mobile GCS applications—including QGroundControl, Mission Planner, and custom Flutter/mobile GCS apps—to display live attitude, battery, and GPS telemetry and upload flight plans.
-
Companion Computers and Robotics: Connects flight controllers to onboard Linux computers (running ROS / ROS 2 via MAVROS or MAVSDK) for computer vision, obstacle avoidance, and autonomous navigation.
-
Onboard Peripherals: Links autopilots directly with smart cameras, gimbals, ADS-B transponders, and payload controllers.
MAVLink Microservices
Beyond simple telemetry streaming, MAVLink defines higher-level Microservices—standardized request/response state-machine protocols built on top of core MAVLink messages. Most microservices follow a client-server pattern where the GCS (client) initiates an operation and the vehicle (server) acknowledges or returns data:
-
Heartbeat / Connection Protocol: Broadcasts HEARTBEAT messages (typically at 1 Hz) so systems and components can discover one another, identify vehicle types, and monitor connection health.
-
Mission Protocol: Handles uploading, downloading, and clearing autonomous waypoint missions, geofences, and rally points reliably with sequence handshakes.
-
Parameter Protocol: Allows a GCS or companion computer to read, modify, and synchronize autopilot configuration parameters (PARAM_REQUEST_LIST, PARAM_SET, PARAM_VALUE).
-
Command Protocol: Executes immediate actions (such as arming, takeoff, landing, or changing flight modes) via COMMAND_LONG or COMMAND_INT and confirms execution with COMMAND_ACK.
-
MAVLink FTP (File Transfer Protocol): Supports browsing directories, uploading, and downloading files (such as flight logs, parameters, or mission files) directly over the MAVLink link.
-
Camera and Gimbal Protocols: Standardizes camera triggering, video stream configuration, zoom/focus control, and gimbal orientation tracking.
-
Offboard Control and Telemetry Protocols: Enables external companion computers to stream real-time position, velocity, or attitude setpoints to the autopilot while receiving high-rate sensor and state telemetry.
Summary
By combining a compact binary packet format with XML-based extensibility and structured microservices, MAVLink provides a fast, reliable, and hardware-agnostic communication backbone for modern drones and autonomous robotics.
References
1. MAVLink Developer Guide — Official Documentation: https://mavlink.io/en/
2. MAVLink Microservices Overview — MAVLink Guide: https://mavlink.io/en/services/
3. PX4 Autopilot User Guide — MAVLink Messaging & Architecture: https://docs.px4.io/
4. ArduPilot Documentation — MAVLink Protocol Integration: https://ardupilot.org/dev/docs/mavlink-basics.html