Compass Interference Causing EKF Crash on copter

Hello everyone,

I’m having a recurring issue with my copter where compass interference seems to be causing the EKF to crash, leading to vehicle instability and even flyaways/crashes. I’ve experienced this multiple times, and I’m hoping to get some advice on how to resolve it, as well as clarity on a key question about why this happens.

First, let me describe the problem: Sometimes, while flying, the compass-related EKF status displayed in Mission Planner rises sharply.. I’ve checked the flight logs afterward, and I can see that the ErrSc (error score) spikes above 1.0, SM (magnetometer TestRatio) exceeds 1, and the yaw angle drifts uncontrollably—all signs of compass interference. Eventually, the EKF crashes, and the copter loses stability (not just yaw, but full attitude control).

I’ve done some research and found two potential fixes mentioned:

1.Set EK3_MAG_CAL = 2 (use heading fusion only, no 3-axis magnetometer fusion).

2.Increase the value of EK3_YAW_M_NSE.

My biggest confusion, though, is why compass interference causes the entire EKF to crash. From my understanding, the compass is only responsible for yaw (heading) estimation. Why does a problem with yaw lead to a complete loss of attitude control (roll/pitch) and EKF failure? It seems like the compass issue is “spreading” to other parts of the EKF’s state estimation, but I don’t fully grasp the mechanism behind this.

I’ve calibrated the compass multiple times (both on the ground and use magfit calibration when possible), but the issue still occurs in certain environments.

Any advice, explanations, or shared experiences would be greatly appreciated!

However, DJI also uses a compass—why doesn’t DJI have this kind of issue, and can we follow DJI’s approach to solve it?

Thank you in advance for your help.

1 Like

Can you post a bin log where you’ve experienced this?

I accidentally deleted the flight log.Previously, I used a Beitian GPS/COMPASS module. With this module, I often got warnings like ekf lane change and ekf primary change. I used to think these EKF switches were normal, so I just ignored them as long as it switched to another lane.Later, I switched to a better OneZero GPS module. After testing, the ekf lane change warnings have rarely appeared.

That’s all you had to say!