JOURNAL OF L
A
T
E
X CLASS FILES, VOL. 14, NO. 8, AUGUST 2015 5
Vehicle. According to the latest specification in [10],
there are 33 pre-defined types defined in the MAV_TYPE,
including quadrotor (MAV_TYPE_QUADROTOR = 2),
helicopter (MAV_TYPE_HELICOPTER = 4), fixed wing
(MAV_TYPE_FIXED_WING = 1), and several others. The
autopilot field indicates the type of autopilot. There are several
types defined in the MAV_AUTOPILOT enumeration structure.
For example, MAV_AUTOPILOT_GENERIC = 0 indicates
a generic autopilot, MAV_AUTOPILOT_ARDUPILOTMEGA
= 3 indicates ArduPilot autopilot, MAV_AUTOPILOT_PX4
= 12 for PX4 autopilots.
The base_mode field indicates different operation modes.
Understanding the base_mode is crucially important to cor-
rectly parse the heartbeat message and extract useful informa-
tion out of it. It is encoded in 8 bits. There are 8 pre-defined
flags, from 2
0
to 2
7
. Here are the eight different modes:
• Flag = 1 is reserved for future use
• Flag = 2 means that the test mode is enabled. This
mode is used for temporary tests and not used for regular
flights.
• Flag = 4 means that the autonomous mode (AUTO) is
enabled. This means that the unmanned system is oper-
ating autonomously by navigating to the goal waypoints
sent to it from the ground station. In AUTO mode, a
mission is loaded to the autopilot. A mission consists of
a set of several waypoints that the system has to navigate.
• Flag = 8 means that the GUIDED mode is enabled. In
GUIDED mode, a mission consists of a single waypoint
sent to the system. The system then navigates to the
specified location autonomously.
• Flag = 16 means that the system stabilizes its attitude
(orientation and altitude), and possibly its position, by
automatic control. This requires external sensors like GPS
in an indoor environment, altitude sensors (barometer,
LIDAR) or motion capture for indoor positioning to be
able to hover in a stable state. The system needs external
control inputs to make it move around.
• Flag = 32 means that the hardware in the loop sim-
ulator is activated, i.e., all motors and actuators of the
motors are blocked while the internal autopilot is fully
operational.
• Flag = 64 means that manual mode is enabled, which
requires that the pilot manually control the system using
a remote control input. In manual control, there is no
automatic control made by the autopilot.
• Flag = 128 the system is in armed state, which means
that motors are enabled/running and can start the fly.
The custom mode is also essential. It indicates autopilot
specific flags that are interpreted in addition to the base mode.
It is used in heartbeat message parsing to determine the flight
modes of the autopilot system. There are pre-defined values
for the custom mode including 0 for manual flight mode,
4 for guided mode, 10 for auto mode, 11 for RTL mode,
9 for LAND mode, 2 for ALT
HOLD, and 5 for LOITER.
In the next section, we provide a comprehensive overview of
the different flight modes in ArduPilot systems supported by
MAVLink.
The system_status field represents a flag that indicates
the system state. There are night states defined as of the latest
specification [10]:
• system_status = 0 refers to a system that is not
initialized system or an unknown state.
• system_status = 1 indicates that the system is
booting.
• system_status = 2 means that the system is per-
forming a a calibration. In fact, the sensor calibration is a
very important phase to make sure that flight sensors such
as Inertial Measurement Units (IMU), and Compasses are
consistent and run as expected.
• system_status = 3 it means that the system is in
standby mode and can be started at any time.
• system_status = 4 indicates that the motors are
engaged and that the system is active and might be
airborne.
• system_status = 5 indicate potential errors and
that the system is in critical state, although it can still
navigate. This can happen for example during temporary
interference or battery level starting to be low, etc.
• system_status = 6 this means an emergency situa-
tion where the unmanned system lost control over some
parts and is in distress situation. The system may have
already been crashed.
• system_status = 7 indicates that the system has
started its power-off process and is now shutting down.
• system_status = 8 indicates that the system is ter-
minating itself and ending its flight.
Finally, mavlink_version field indicates the MAVLink
version. It is not editable by the user and is set by the protocol.
System Status message: The system status message has
a Message ID equal to 1 and is composed of data about the
onboard control sensors embedded into the unmanned system
and specifies which of these sensors are enabled/disabled and
which sensors are operating or having errors. It also carries out
data about the battery status and the remaining voltage, which
is useful to track the battery level of the unmanned system.
Besides, it provides information about the communication
errors and the ratio of dropped packets in the communication
link. The information about battery and communication link
are crucial to take appropriate failsafe action when the battery
level goes down, or the communication quality deteriorates.
In this case, the unmanned system can be pre-programmed to
execute a failsafe operation in case of low battery level or bad
communication quality such as landing and going back home
for an unmanned aerial system.
Global Position message: The global positioning message
has an id equal to 33 and represents the filtered GPS coordinate
provided by the Global Positioning sensor. It is illustrated in
Fig. 4. This message carries out important information of the
unmanned system related to its global positions, namely, the
GPS latitude (lat), longitude (lon) and also absolute altitude
(alt). These three values are encoded into four bytes (32 bits).
The values of (lat) and (lon) must be divided by 10
7
, to
get the real floating GPS value, it is needed to divide them by
10
7
. The altitude is expressed in millimeters. The message also