Get and Set FlightMode

This page explains how MAVLink can be used by a ground station or companion computer to get or set the vehicle’s flightmode. The user wiki pages for flightmodes and links to the parameter with the flightmode’s numbers are listed below

Get the Flightmode with HEATBEAT

The vehicle’s current flight mode is sent once per second within the HEARTBEAT message’s custom_mode field. The flightmode number varies by vehicle type (e.g. Copter, Plane, Rover, etc) so please refer to the links above to convert the custom_mode number to a human readable flightmode name.

Set the Flightmode with MAV_CMD_DO_SET_MODE

Attempt to set the vehicle’s flightmode by sending a COMMAND_LONG with the command and param2 fields set as specified for the MAV_CMD_DO_SET_MODE command.

Command Field Type Description
target_system uint8_t System ID of flight controller or just 0
target_component uint8_t Component ID of flight controller or just 0
command uint16_t MAV_CMD_DO_SET_MODE=176
confirmation uint8_t 0
param2 float flightmode number
param3 float not used
param4 float not used
param5 float not used
param6 float not used
param7 float not used


The example commands below can be copy-pasted into MAVProxy (aka SITL) to test this command. Before running these commands enter, “module load message”

Example MAVProxy/SITL Command Description
message COMMAND_LONG 0 0 176 0 1 6 0 0 0 0 0 Copter: change to RTL mode (6) Plane: change to FBWB mode (6) Rover: change to Follow mode (6)