MAVLink (Micro Air Vehicle Link) is the lightweight binary messaging protocol used by ArduPilot to communicate with ground control stations, companion computers, and other autopilots. ArduPilot implements MAVLink 2 by default, with automatic fallback to MAVLink 1 for legacy systems. The protocol defines a fixed message framing structure, a system/component addressing scheme, and a large set of pre-defined message types covering everything from attitude telemetry to mission upload. All MAVLink handling in ArduPilot lives underDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Ardupilot/ardupilot/llms.txt
Use this file to discover all available pages before exploring further.
libraries/GCS_MAVLink/, with the primary class being GCS_MAVLINK in GCS.h. Vehicle-specific subclasses (e.g. GCS_MAVLINK_Copter) override the send and receive methods to handle vehicle-specific messages.
Connection methods
ArduPilot exposes MAVLink on any serial port configured with theSERIALn_PROTOCOL parameter set to 1 (MAVLink 1) or 2 (MAVLink 2). Typical configurations:
| Transport | Typical use |
|---|---|
| Hardware UART | Telemetry radios (SiK, RFD900) on SERIAL1 |
| USB (SERIAL0) | Direct connection to Mission Planner or MAVProxy |
| UDP | SITL, companion computers, networking |
| TCP | Long-range GCS links, Wi-Fi |
SERIALn_BAUD. Telemetry radios typically operate at 57600 baud; USB connections run at native USB speed (negotiated by the OS).
Up to 8 simultaneous MAVLink channels are supported on boards with sufficient memory (
MAVLINK_COMM_NUM_BUFFERS). Each channel maintains its own send buffer, stream rates, and routing state.Heartbeat messages
Every MAVLink participant must emit aHEARTBEAT message at 1 Hz to announce its presence on the bus. ArduPilot sends a heartbeat containing:
type— the MAV_TYPE of the vehicle (e.g.MAV_TYPE_QUADROTOR)autopilot— alwaysMAV_AUTOPILOT_ARDUPILOTMEGAbase_mode— bitmask includingMAV_MODE_FLAG_CUSTOM_MODE_ENABLEDand the armed statecustom_mode— the numeric flight mode from the vehicle’s mode enumsystem_status— currentMAV_STATE(e.g.MAV_STATE_ACTIVEwhen flying)
SYSID_MYGCS). If no heartbeat is received for longer than FS_GCS_TIMEOUT seconds the GCS failsafe triggers.
Common message types
| Message | Direction | Purpose |
|---|---|---|
HEARTBEAT | Both | System presence and status |
STATUSTEXT | Vehicle → GCS | Human-readable status and warning text |
COMMAND_LONG | GCS → Vehicle | Send a MAV_CMD_* command with up to 7 float parameters |
COMMAND_ACK | Vehicle → GCS | Acknowledge a received command and report result |
PARAM_REQUEST_LIST | GCS → Vehicle | Request the full parameter list |
PARAM_VALUE | Vehicle → GCS | Send one parameter value (response to request or set) |
PARAM_SET | GCS → Vehicle | Write a parameter value |
MISSION_COUNT | GCS → Vehicle | Begin a mission upload with item count |
MISSION_ITEM_INT | GCS → Vehicle | One mission waypoint or command (integer lat/lon) |
MISSION_ACK | Both | Acknowledge mission operation result |
ATTITUDE | Vehicle → GCS | Roll, pitch, yaw angles and rates |
GLOBAL_POSITION_INT | Vehicle → GCS | Latitude, longitude, altitude, velocity |
VFR_HUD | Vehicle → GCS | Airspeed, groundspeed, heading, throttle, altitude |
RC_CHANNELS | Vehicle → GCS | Raw RC channel input values |
BATTERY_STATUS | Vehicle → GCS | Battery voltage, current, and remaining capacity |
SYS_STATUS | Vehicle → GCS | Sensor health bitmask and load |
SET_MODE | GCS → Vehicle | Change the active flight mode |
SET_POSITION_TARGET_GLOBAL_INT | GCS → Vehicle | Guided mode position/velocity target |
Parameter protocol
ArduPilot implements the full MAVLink parameter protocol:Stream
ArduPilot sends successive
PARAM_VALUE messages, each containing the parameter name (up to 16 characters, null-padded), its float value, its type, the total count, and an index.Set
To write a value the GCS sends
PARAM_SET. ArduPilot validates the name and range, writes the value to EEPROM if valid, and replies with PARAM_VALUE showing the accepted value.Mission protocol
Mission upload uses a request-response handshake:MISSION_ITEM_INT encodes latitude and longitude as integers (degrees × 10⁷) to avoid floating-point rounding errors in position-critical waypoints.
Command protocol
One-shot commands useCOMMAND_LONG:
MAVLink streams and rates
ArduPilot sends telemetry messages in named stream groups. Each group has a rate parameterSRn_* where n is the channel number (0 = primary GCS link):
| Stream group | Parameter | Typical messages |
|---|---|---|
STREAM_RAW_SENSORS | SR0_RAW_SENS | RAW_IMU, SCALED_PRESSURE |
STREAM_EXTENDED_STATUS | SR0_EXT_STAT | SYS_STATUS, MEMINFO |
STREAM_RC_CHANNELS | SR0_RC_CHAN | RC_CHANNELS, SERVO_OUTPUT_RAW |
STREAM_POSITION | SR0_POSITION | GLOBAL_POSITION_INT, LOCAL_POSITION_NED |
STREAM_EXTRA1 | SR0_EXTRA1 | ATTITUDE, SIMSTATE |
STREAM_EXTRA2 | SR0_EXTRA2 | VFR_HUD |
STREAM_EXTRA3 | SR0_EXTRA3 | AHRS, HWSTATUS, WIND |
0 disables the stream group. The maximum rate is capped internally to 0.8 × SCHED_LOOP_RATE to prevent overloading the scheduler.
Sending status text from C++
ArduPilot uses theGCS_SEND_TEXT() macro to emit STATUSTEXT messages to all connected GCS channels. These messages appear as console output in Mission Planner and MAVProxy:
MAV_SEVERITY enum: EMERGENCY, ALERT, CRITICAL, ERROR, WARNING, NOTICE, INFO, DEBUG.
MAVLink routing
MAVLink_routing (libraries/GCS_MAVLink/MAVLink_routing.h) implements the forwarding table that allows messages received on one channel to be relayed to other channels. This supports multi-GCS setups and companion-computer-to-GCS bridging. A routing entry maps a (sysid, compid) pair to the channel on which that component was last seen.
MAVLink signing
MAVLink 2 supports optional HMAC-SHA256 message signing to authenticate traffic and prevent injection attacks. When signing is enabled:- Each outbound message includes a 6-byte timestamp and a 6-byte signature derived from the session key.
- Incoming messages are rejected if the signature does not match.
- The signing key is exchanged out-of-band (typically by uploading a key file through the GCS).
GCS_MAVLINK parameters and is disabled by default. It is recommended when the telemetry link is exposed to an untrusted network.