MAVLink: the protocol behind ArduPilot

MAVLink is the lightweight messaging protocol that links ArduPilot firmware to ground stations, companion computers and peripherals. It is a serial protocol that does not care what the serial link is: USB, a 900 MHz telemetry radio or a Wi-Fi bridge all carry the same bytes.

ArduPilot firmware does not talk to the world in plain text. This guide covers the packet format, the message flow at connection time, and the parts of the protocol that decide whether an integration works.

What MAVLink is

MAVLink packages telemetry, commands and mission data into small binary messages. Each message has a defined structure and a checksum, so a receiver can separate valid traffic from noise on a weak link. The message set is published as XML: common.xml holds the shared messages, and ardupilot.xml holds the ArduPilot-specific ones.

Two properties follow from that design and matter more than the format itself:

The packet on the wire

The MAVLink 1 packet layout is short enough to read in a hex dump:

Offset Field Meaning
0 Start marker 0xFE identifies a MAVLink 1 packet
1 Payload length 0 to 255 bytes
2 Packet sequence Increments per packet, used for loss detection
3 System ID Which vehicle or station sent it
4 Component ID Which component inside that system
5 Message ID Tells the receiver how to decode the payload
6 to 5+n Payload The message fields
n+6 to n+7 Checksum Two bytes, low then high

The identifiers are the part integrators get wrong. A vehicle defaults to system ID 1 and a ground station normally uses a high ID such as 255; the MAV_SYSID parameter changes the vehicle value. The flight controller and the ground station both use component ID 1, while other devices on the vehicle, such as a companion computer or a gimbal, keep the vehicle's system ID and take a different component ID.

What happens when a link opens

  1. Every system sends a HEARTBEAT, message ID 0, at 1 Hz. That heartbeat is how a ground station discovers a vehicle and how it knows the link is alive.
  2. The ground station requests the data it wants at the rate it wants. REQUEST_DATA_STREAM sets the rate for a group of messages; COMMAND_LONG carrying SET_MESSAGE_INTERVAL gives precise per-message control, and ArduPilot supports the latter from 4.0 onward.
  3. Commands flow the other way: change mode, arm, start a mission, move a servo.
  4. Telemetry streams continue until the rates are changed or the link drops.

This is why a link can look connected and still show nothing useful: the heartbeat arrives, but no stream was ever requested.

Message groups worth knowing

Group Examples Used for
Liveness HEARTBEAT Discovery, mode, armed state
Position and attitude Global position, attitude, velocity Displays, geofence logic, logging
Commands COMMAND_LONG, COMMAND_ACK Mode changes, one-off actions
Missions Mission item, mission request and ack Waypoint upload and readback
Parameters PARAM_REQUEST_READ, PARAM_SET, PARAM_VALUE Reading and writing configuration
Status System status, battery, sensor health Pre-flight checks, alerts

The parameter group explains why a ground station can rewrite vehicle behaviour without flashing firmware: configuration is a set of named values, and MAVLink has messages to read and write each one.

Wiring it together

A typical link runs from a controller serial port to a telemetry radio, then over the air to a receiver on the ground computer. A companion computer can sit on the same bus, read the traffic and add vision or logging without disturbing the main link.

Three rules for that layout:

Where MAVLink stops

MAVLink moves messages. It does not define missions as files, it does not encrypt anything by default, and it does not guarantee delivery. Signing exists as an extension and is worth enabling where a link leaves a controlled environment, but it is not a substitute for a private channel.

A common field failure is a link exposed to an untrusted network where any device that speaks MAVLink is trusted. Treat vehicle links as control networks: keep them on their own channel, and do not route them through a shared LAN without a reason.

Related reading