Random compass initialization problem causes unexpected loss of control

We have a mission involving a particular payload we run regularly, and we have done so perhaps hundreds of times. Today, on the fourth flight of the day, the compass malfunctioned, initialized with a bogus value, and starting the mission in Auto mode resulted in severe toilet bowling, a flip upon landing, and (minor) damage to the vehicle. After repairs, four further flights were completed without any incident.

We would appreciate any insight into why the compass malfunctioned and if there’s any thing we need to keep watch for in the future. We recognize the pilot should have been alarmed by the initial yaw being grossly incorrect (approx. 100 degrees off, the vehicle should have been placed ~90 degrees each time) and that the flip likely could have been avoided had we switched to and landed in AltHold mode.

But the incorrect yaw was the only symptom of any impending problem and we want to be sure there’s not any hardware or software glitch that needs correcting or addressing.

Logs available here: compass_problem_2023-10-31.zip (note that the shakedown flight does not have the payload mounted)

Vehicle description:

  • 1000mm hexcopter, 6x 420kV motors with 18 inch propellers
  • Cube Orange Plus flight controller (internal compasses disabled due to interference)
  • 6S 25Ah LiHv battery
  • Here+ GPS+Compass module (only enabled compass)
  • Very slightly modified 4.4.1 firmware (available here)

Provide your hardware installation diagram. Your aircraft must at least use a bracket to install the GPS to a high point, otherwise there will be serious magnetic field interference. For your aircraft, using the GPS for yaw module instead of compass is a good solution to the problem.

The GPS/compass module is mounted on a bracket and is the highest point on the vehicle.

Can you help me understand why there was serious magnetic field interference for only one out of eight flights? Each flight started from the same place (within a few feet), had the same payload, was pointing the same direction, and ran the same mission.

It appears the compass somehow initialized with a bogus rotation value. The used compass should be MAG[0] and MAG[1], one of the unused compasses is MAG[2].

Pre-crash, offsets applied to MAG[2] so they line up with the others.

During crash, offsets applied to MAG[0] and MAG[1] so that they line up with the MAG[2] from before (i.e. with the same offsets). Note that axis X and Y have swapped, and axis Z is inverted!

Isn’t that of of the bug fixes in ArduCopter 4.4.2 ?

Could you point me to that? The changelog does not mention anything relevant vs 4.4.1.

I checked the change log, it is not there. I’m not sure if that got into 4.4.2 or if it only got fixed in 4.5.0-DEV.

If there is a commit that fixes this I would love to pull it into my tree and better understand the problem. Please let me know if you find it.