The measured field does not match the Earth's field at this place
What ArduPilot says:
- PreArm: Check mag field (z diff:N.N>N)
- PreArm: Check mag field (xy diff:N.N>N)
Once it has a position, ArduPilot looks up in a built-in world map what the Earth's magnetic field should be there, turns the first compass's reading into north, east and down using its attitude estimate, and compares. North or east off by more than ARMING_MAGTHRESH (100 milligauss by default) gives “xy diff”, with the difference and the limit. The vertical part is meant to get twice the limit (“z diff”), but in this version a slip in the code keeps that test from ever failing. The check starts only after the GPS has a fix, so arming can work indoors and fail outside.
What to do, most likely first
Steel or a magnet nearby bends the field: a car, a metal table, reinforced concrete.
CheckThe difference in the message changes as you carry the aircraft a few metres.
FixMove into the open before arming.
The calibration was made in a disturbed place, or before something magnetic was added to the aircraft.
FixCalibrate again outdoors with everything fitted and a GPS fix, then reboot.
The compass is mounted upside down or tilted, and
COMPASS_ORIENTdoes not say so.CheckIn the northern hemisphere, tilting the nose down must raise the compass's X value and rolling the aircraft upside down must lower Z; in the southern hemisphere the other way round.
FixRun the calibration with
COMPASS_AUTO_ROT2 (the default): it finds the orientation of an external compass and saves it toCOMPASS_ORIENT. For a compass on the board, correctAHRS_ORIENTATION.
4.7 corrects the vertical test. A compass that arms on this version can therefore be refused after an upgrade with “z diff”: the error was there before, it was only not looked at.
Parameters to look at
| Parameter | What it is |
|---|---|
ARMING_MAGTHRESH | Compass magnetic field strength error threshold vs earth magnetic model |
COMPASS_ORIENT | Compass orientation |
COMPASS_EXTERNAL | Compass is attached via an external cable |
AHRS_ORIENTATION | Board Orientation |
COMPASS_AUTO_ROT | Automatically check orientation |
COMPASS_SCALE | Compass1 scale factor |
Where to do it:Setup & Tuning GuideSetup & Tuning Guide
The code that sends it
PreArm: Check mag field (z diff:N.N>N)
libraries/AP_Arming/AP_Arming.cpp AP_Arming::compass_checks() · Open in ArduPilot Copter-4.7.1
PreArm: Check mag field (xy diff:N.N>N)
libraries/AP_Arming/AP_Arming.cpp AP_Arming::compass_checks() · Open in ArduPilot Copter-4.7.1