The compass was disturbed on the ground; the heading was corrected during the climb
What ArduPilot says:
- EKF2 IMUN MAGN ground mag anomaly, yaw re-aligned
- EKF3 IMUN MAGN ground mag anomaly, yaw re-aligned
Right after take-off the EKF, ArduPilot's position and attitude estimator, saw its heading error grow as the aircraft rose: the mark of a magnetic disturbance on the ground that fades with height. Having climbed more than 0.5 m, with the error grown by more than 0.25 rad (about 14°), it set the heading again from the compass. This can happen twice per take-off, before the regular in-flight alignment at 2.5 m. IMU and MAG number the EKF copy and the compass, from 0.
What to do, most likely first
The take-off spot is magnetic: reinforced concrete, a car roof, a manhole cover, a steel table, rebar under tarmac.
CheckIt happens at one take-off spot and not at another.
FixTake off from soil or grass, a few metres from metal. The correction is automatic, but the first metres are flown with a wrong heading: climb straight up to 3 m before moving away.
It happens everywhere: the aircraft itself disturbs the compass as the throttle comes up.
CheckIn the log the compass readings move together with the battery current.
FixMove the compass away from the battery leads and ESC wires, then run the compass-motor calibration.
Parameters to look at
| Parameter | What it is |
|---|---|
EK3_MAG_CAL | Magnetometer default fusion mode |
COMPASS_USE | Use compass for yaw |
Where to do it:Setup & Tuning GuideSetup & Tuning Guide
The code that sends it
EKF2 IMUN MAGN ground mag anomaly, yaw re-aligned
libraries/AP_NavEKF2/AP_NavEKF2_MagFusion.cpp NavEKF2_core::controlMagYawReset() · Open in ArduPilot Copter-4.7.1
EKF3 IMUN MAGN ground mag anomaly, yaw re-aligned
libraries/AP_NavEKF3/AP_NavEKF3_MagFusion.cpp NavEKF3_core::controlMagYawReset() · Open in ArduPilot Copter-4.7.1