Multiple compass readings

I am trying to monitor and/or utilize the vehicle heading that the autopilot is incorporating in its control algorithms. Currently, I am having great success getting lots of values from the autopilot by parsing the Mavlink2rest data, i.e. the 6040 webpage json data.
In these pages/json strings, I see 2 or maybe 3 difference values for heading/yaw. One seems to correspond (in radians) to one compass on my NavHat. The other seems to correspond (in hundreths of degree) to the other.
My question is a) which is which? b) where in the Mavlink2Rest pages can I get the EKF heading, c) which one is being used by the autopilot itself, i.e. in Guided mode d) which one is being used by QGC in its compass?

Hi @MikeFair -
All the compass readings are output from the same EKF, but as you’ve found they may be in different units.
It’s also worth noting that the rate you can poll this information is typically insufficient to run additional control loops on top of - hence it’s typically better to send commands to the autopilot that it carries out, rather than emulation of pilot input…

Yaw (heading) is available in AHRS2, Attitude, as well as VFR_HUD messages.
You can see the units and information on these messages here and here.

So -
a) they are all the same
b) You can get EKF heading from AHRS2 ( float rad Yaw angle), Attitude ( float rad Yaw angle (-pi..+pi)), and VFR_HUD (heading int16_t deg Current heading in compass units (0-360, 0=north))
c) The autopilot uses the calculated EKF heading - there is only one, but values are expressed in different formats (i.e. radians vs. degrees) in those messages.
d) QGC is likely displaying the heading from VFR_HUD as this is a message intended to inform HUD interfaces typically.

Another tip - if you navigate to Available Services in BlueOS, and click the link under API documentation, you can then expand the

GET
​/helper​/mavlink
Returns a MAVLink message matching the given message name

section, click “try it out” and then enter in the name of a message - like VFR_HUD. Click Execute, and you’ll see some helpful information on that message!

The raw compass values used to calculate the EKF heading can be found in the SCALED_IMU and RAW_IMU messages.