I am confused about the representation of APM modes in the heartbeat and uplink messages. This is what I am doing:
APM<--->MAVProxy<---->A python program using pymavlink.
For setting the APM in AUTO and GUIDED modes, I had used the following encoding in my python program:
AUTO: base_mode: 1, custom_mode: 3
GUIDED: base_mode: 1, custom_mode: 4
I figured them out by using Mission planner and checking the contents that MAVProxy sends to APM and used likewise in my program. Since the base_mode is set to 1, are we using "MAV_MODE_FLAG_CUSTOM_MODE_ENABLED" in "MAV_MODE_FLAG" enum and using custom mode to distinguish the modes for APM? If that is the case, can some one point me where these custom modes for APM are defined.
Currently, I am trying to interpret the modes in python program by looking at the heartbeat message. By printing out the received heartbeats for each of the different modes, I observe that the following values are used:
STABILIZE - base mode: 81, custom mode: 0
AUTO - base mode - 89, custom mode - 3
GUIDED - based mode - 89, custom mode - 4
The values are different for the downlink and this is confusing. I checked message definitions (common.xml and ardupilotmega.xml) and mavlink_types.h to make sense of this, but it does not add up. I can proceed with my program as I am printing the message contents using Mission Planner, but I would like to know the correct reference for these definitions. If some one can point me to that, it will be great.