Basic documentation:

MAVLink is a communication protocol between autonomous aircraft and vehicle systems (drones, planes, vehicles). The MAVLink protocol lies at the base of interaction between Pixhawk and Raspberry Pi.

Clover contains two wrappers for this protocol: MAVROS and simple_offboard.

The code for sending an arbitrary MAVLink message may be found in the examples.

The main concerts

Communication channel

The MAVLink protocol may be used on top of the following communication channels:

  • connection in series (UART, USB, etc.);
  • UDP (Wi-Fi, Ethernet, 3G, LTE);
  • TCP (Wi-Fi, Ethernet, 3G, LTE).


A MAVLink message is an individual "portion" of data transmitted between devices. An individual MAVLink message contains information about the state of the drone (or another device) or a command for the drone.

Examples of MAVLink messages:

  • ATTITUDE, ATTITUDE_QUATERNION – the quadcopter orientation in the space;
  • LOCAL_POSITION_NED – local position of the quadcopter;
  • GLOBAL_POSITION_INT – global position of the quadcopter (latitude/longitude/altitude);
  • COMMAND_LONG – a command to the quadcopter (take off, land, toggle modes, etc).

A complete list of MAVLink messages is available in MAVLink documentation.

System, system component

Each device (a drone, a base station, etc.) has an ID in the MAVLink network. In PX4 MAVLink, ID is changed using parameter MAV_SYS_ID. Each MAVLink message contains a field with the ID of the originating system. Besides, some messages (for example, COMMAND_LONG) also contain the ID of the target system.

In addition to IDs of the systems, the messages may contain IDs of the originating component and the target component. Examples of the system components: a flight controller, an external camera, a controlling onboard computer (Raspberry Pi in case of Clover), etc.

An example of a package

An example of a MAVLink package structure with message COMMAND_LONG:

Field Length Name Comment
magic 1 byte Start tag 0xFD for MAVLink 2.0
len 1 byte Data size
incompat_flags 1 byte Reversely incompatible flags Currently unused
compat_flags 1 byte Reversely compatible flags Currently unused
seq 1 byte Message sequence number
sysid 1 byte Originating system ID
compid 1 byte Originating component ID
msgid 3 bytes Message ID
Data (example)
target_system 1 byte Target system ID
target_component 1 byte Target component ID
command 2 bytes Command ID
confirmation 1 byte Number for confirmation
param1 4 bytes Parameter 1 A single-precision floating point number
param2 4 bytes Parameter 2
param3 4 bytes Parameter 3
param4 4 bytes Parameter 4
param5 4 bytes Parameter 5
param6 4 bytes Parameter 6
param7 4 bytes Parameter 7
checksum 2 bytes Checksum
signature 13 bytes Signature (optional) Allows checking that the package has not been compromised. Usually unused.

Yellow is used for highlighting the data fields(payload). An individual set of such fields exists for every message type.

results matching ""

    No results matching ""