# PX4 mavlink flight modes

Source: https://forum.modalai.com/topic/812/px4-mavlink-flight-modes
Category: General Questions (https://forum.modalai.com/category/2/general-questions)
Posted: 2022-03-21 12:12:21 UTC by relevinsky
Replies: 1 · Views: 829

## relevinsky · 2022-03-21 12:12:21 UTC

Hi,

I have two questions:
1) Could you help to point me to mavlink px4 dialect c files, specifically I'm looking for Enum of copter flight modes like in Arducopter (like in ardupilotmega mavlink cfiles)?

2) c mavlink function/command that set px4 to offboard flight mode.

Thanks.

## Reply by Cliff Wong (ModalAI staff) · 2022-03-21 17:24:41 UTC

Mavlink messages for setting flight mode use the ```MAVLINK_MSG_ID_SET_MODE``` message type (same as APM). 

Modes are defined in the uOrb layer under the ```vehicle_status.msg``` fie, which C headers are auto-generated at build time. The auto-generated file is under the build directory as ```vehicle_status.h``` via the ```NAVIGATION_STATE_*``` variables. 

And example of using modes in runtime code are in the mavlink_messages.cpp file 
(search for ```vehicle_status_s::NAVIGATION_STATE_AUTO_MISSION```) and modes are processed in the ```Commander.cpp``` file. Both files under the src/modules directory of PX4.
