Crash avoided, MAG0 GROUND MAG ANOMALY, YAW-REALIGNED

Hi,

As the title suggests, I nearly crashed my drone following a MAG0 GROUND MAG ANOMALY, YAW-REALIGNED warning, or more specifically, following this sequence of messages:

The setup I’m using is a nearly stock Aurelia X6 Standard with the stock Cube Orange+ as the flight controller. I swapped out the original GPS module for an RTK compatible GPS module and modified a few parameters accordingly. The new GPS mast is about 2 inches shorter than the original which was 7 inches tall. I should also mention that I performed a compass calibration with QGroundControl since I was getting a warning from the FC.

Here is the log of my last flight where I nearly avoided a crash. The log contains 2 flights. The first is a somewhat normal flight where the FC performs an in-flight yaw alignment followed by an EKF lane switch, where I temporarily lose control of the drone in Loiter mode while it performs a small spiral for a few seconds, before flying normally again. The second is the near miss where the EMERGENCY YAW RESET messages are issued, and the drone pitches and rolls hard at full throttle before regaining control barely above ground.

After this incident, I studied my previous logs, and I saw that the MAG0 IN-FLIGHT YAW ALIGNMENT COMPLETE messages would also appear in my flights before my GPS swap as shown in this log. I couldn’t find any logs, but I do know that even before the GPS swap, the out-of-control spiral that happens in the first flight of my previously shown near miss log would intermittently happen.

I also studied the previous log with the new RTK GPS module. We can see that the MAG0 GROUND MAG ANOMALY, YAW-REALIGNED and MAG0 IN-FLIGHT YAW ALIGNMENT COMPLETE messages appear. Despite no EKF lane switch or EMERGENCY YAW RESET messages appearing, the drone still performed the uncontrollable spiral after takeoff before flying normally for the rest of the flight.

I have read through similar threads [1][2][3][4], which led me to investigate the effect of my current draw on my compasses. Here are a few samples:

Near miss with new RTK GPS:

EKF lane switch with new RTK GPS:

Normal flight with new RTK GPS:

Normal flight with original GPS:

That’s also when I realized that my external GPS compass used to be COMPASS_PRIO1_ID, and my internal FC compass was set on COMPASS_PRIO2_ID. So for the last graph, the internal compass is actually MAG[1]. As we can see, the internal compass is basically measuring the current draw instead of the magnetic field, while the external compass, with both the original and new GPS seems to be fairly immuned to the current draw.

After this analysis, while I am pretty sure that my issues are due to the current draw’s impact on the compass measurements, I wanted to be 100% certain that my fixes will avoid any future crash before flying this drone again.

Fixes:

  1. Switch COMPASS_PRIO1_ID and COMPASS_PRIO2_ID to prioritize the external compass.
  2. Use MAGFit to get compass params using this log from 164s to 274s.
  3. Use offsets and current compensation to set the internal compass (Mag 1) params.
  4. Use offsets compensation to set the external compass (Mag 2) params.

Questions:

  1. After these fixes, should I still disable my internal compass? COMPASS_USE2=Disable
  2. Is the MAG0 IN-FLIGHT YAW ALIGNMENT COMPLETE message normal? Does it have anything to do with the uncontrollable spiral? Should I set EK3_MAG_CAL to Always instead of After first climb yaw reset which it is currently set to?
  3. Should I set FS_EKF_THRESH to Relaxed?
  4. Should I take off in AltHold and switch to Loiter in flight to avoid issues?
  5. How is COMPASS_ORIENTX set? It seems to change by itself when I play around with the COMPASS_PRIOX_ID.
  6. Why is the drone almost crashing following the EMERGENCY YAW RESET message? This behavior seems extremely dangerous. Even in the event of a total compass failure, couldn’t the drone simply switch to AltHold while performing this action to avoid controllability issues? Could this behavior be related to this issue?

Thank you in advance for your help!

Use these values for your compass settings. Do a test flight watching for compass errors. Make sure the flight has some 360 degree turns and changes in throttle setting/speed. If the internal compass is still bad after that then consider disabling it.

MAGFit.param (702 Bytes)

Looks to me like Compass 1 is the internal, so don’t disable number 2.

Leave the other settings alone for now.

1 Like

is a standard informational message and not necessarily a warning or error.
You should only get it once after launching, when the EKF is able to sort out all the sensor inputs and work out what your most likely true heading is.
Repeats of that message usually indicate compass cal problems, or for example something magnetic shifted, like Li-Ion batteries.

1 Like