Heading in dataflash logs

Hi, trying to work out some heading issues - from dataflash I can get four different yaw values - listed below with what I THINK they represent:

Can anyone confirm or correct?

NKF1.Yaw - EKF2 yaw estimation
XKF1.Yaw - EKF3 yaw estimation (AHRS_EKF_USE = 3)
GPS.GCrs - GPS heading
AHR2.Yaw - ???

I’ve been having a lot of problems with compass variance and getting the heading correct, but it does seem to come good while I’m moving - you can see the GPS and EKF3 headings line up once it’s moving.

MRoberts,

Personally i look at the ATT (attitude) message. So the “Yaw” field will be the main AHRS/EKF’s heading. The AHRS2.Yaw will be the backup AHRS/EKF’s heading. That might be the older DCM by default.

I think you’re right about the NKF1.Yaw and XKF1.Yaw values being for the EKF2 and EKF3 respectively. In my latest log, the NKF1.Yaw is exactly equal to the ATT.Yaw which makes sense 'cuz I’m using the EKF2 as my main EKF. I’m not using the EKF3 and I don’t see XKFx messages.

Yup, ATT matches the XKF value for me and I’m using EKF3 so that sounds right. I find it interesting that the EKF2 yaw doesn’t track the GPS heading as well as the EKF3. I’m running a HERE+ so would have through my GPS heading should be “truth” once I’m moving.

Any reason you’re not using EKF3?

I’m getting a lot of “compass variance” errors and the EKF is often unhappy with the compass, even when the heading is “correct” (based on ground truth).

I think the EKF2 is more stable for regular use, the EKF3 more for the advanced cases where we want to merge in non-GPS position sources (visual odometry, beacons, etc). Either should work I would think though and I haven’t spent much time comparing their performance.

The compass variance is almost undoubtedly going to come from interference from the vehicle frame or the motors. It may be best to disable the internal compasses (COMPASS_USE2 = 0, COMPASS_USE3=0) although this may not help if the interference on the main compass is still very bad.

Does the HERE+ have one or two compasses inside? I’m already using only Compass #1, but MP shows #2 as being external as well. Is there a benefit to having two compasses enabled?

The magfield is varying between about 280 and 400 throughout missions.

Is there a simple algorithm to calculate theoretical heading from the magx and magy? That would let me compare the compass contribution to the heading to the GPS (or is there another way to see which way the compass thinks it’s pointing?)

I’m not sure how many compasses the Here+ has but it’s certainly possible that it has more than one. If you haven’t changed the COMPASSx_EXTERNAL parameter manually then it could certainly be detecting a second external compass correctly.

There really isn’t much benefit to having more than one external compass. ArduPilot (at the moment at least) only makes use of one compass at a time.

If you’re using the MP to view the dataflash log there’s a drop-down in the middle below the graph. If “Sensors/Compass/Compass vs Yaw all” is selected you can see how each compass’s heading compares to the vehicle’s heading. Here’s an example from a log I was looking at from another beta tester.

If you want to do the calculation yourself in excel (or similar) then ATAN2(x,y) can be used (sometimes it’s ATAN2(y,x). The results will come out in radians but they can be converted to degrees by multiplying but 57 (or something close to that).

Brilliant! Thanks a bunch.