Failsafe for compas/mag field?

Just crashed a copter in loiter mode. It went out of control. I believe it was because of compass/mag.
Is there a way to enable or setup a Failsafe mode with Land if compass malfunction is detected?
Below some info from the log file:

Test: Compass = FAIL - WARN: Large compass offset params (X:186.81, Y:-99.69, Z:-332.44)
WARN: Large compass offset in MAG data (X:186.00, Y:-99.00, Z:-332.00)
Large change in mag_field (344.63%)
Max mag field length (1313.50) > recommended (550.00)

As I know, copter land by default when compass fail, I learned in the worse manner but I didn’t check if latest firms change that failsafe.

I’d be asking why the local magnetic field jumped by over 300%.

  1. Where did you do the initial compass calibrations?
  2. Did you run Compass Motor Calibration (CompasMot)?
  3. Did you recalibrate the compass in the field? HINT: You can use stick commands to run On Board Calibration…


  1. I calibrated everything at home.
  2. I did not run CompasMot. Need to learn how to do it.
  3. I did not recalibrate compass in the field. I go to different fields usually without computer so it would be hard to do. Currently I have no telemetry installed.

What’s strange is that it flew really nice several times before the crash. All I did I changed the battery, the same very place and time, but it would not arm.
I took it to my truck and hooked it up to Mission Planner and I was getting a message about the compass and mag field. Since I did not change anything since my flight half an hour ago I went back and tried to arm. After half an hour it finally armed but I had very little control over the copter. Crashed in less than a minute.
What bothers me, why compass failsafe did not land it automatically?

First, you should pay attention to the warnings that Mision Planner gives you.

Second, since you fly in different locations you should calibrate the compass when you change flying locations. Arducopter has an On Board Compass Calibration routine that can be started using your RC transmitter. On Board Calibration. Read the section titled “Onboard Calibration using Stick Gestures (no GCS)”. When you do this Pixhawk will start beeping. Move the aircraft around until the beeping stops. You’re done…

Thank you Oldgazer.
I will do as you advised. Will calibrate compass in the flying location.
Just want to point out that the Pixhawk eventually armed and only then I flew it. I assumed that it would not arm if there is a compass error.
Also… my copter can fly really far. Outside of the USA flying beyond visual is usually permitted. How about flying 10 miles or more from the starting point if compass needs to be calibrated for different but not so distant locations? Wouldn’t such flying be too risky because of that?

no problem 10 miles, no need recalibration