Mission Planner shows an EKF error
Mission Planner shows an EKF error and the drone won't arm. This article covers what the red EKF bar measures, where the 0.8 threshold comes from, and why no failsafe triggers.
The drone sits on the ground, it has GPS, and the satellite count is fine. The EKF label at the top of Mission Planner turns red and the motors won't arm.
If you wait, it clears. The next day it turns red again in the same spot. You don't need to hunt for a setting you broke, because no setting is broken. The autopilot is telling you how much it trusts its own position estimate.
What that bar on the screen measures
Click the EKF label in the Mission Planner HUD and the window that opens shows five bars. These are not sensor values. The autopilot compares each measurement with what it expects and divides the difference by the acceptance limit defined for that measurement. The resulting ratio drives the bar.
So when a bar rises, your compass doesn't have to be broken. What the compass reports and what the autopilot expects simply don't agree. They are two different things.
The official documentation says these values range from 0 to 1, but they have no upper limit. In the interference example below, the compass variance reaches 289. Anything above 1 means "this measurement was rejected."
Where the 0.8 comes from
The autopilot has a single threshold parameter for this, and its default value is 0.8. The number is used in two separate places: in the pre-arm check and in the in-flight failsafe.
The difference matters. The pre-arm check looks at each of the four variances individually and refuses to arm if even one exceeds the threshold. The in-flight check does not work the same way.
The in-flight check computes a score ten times per second. In the figure, look at how many points each variance contributes and where the path to the failsafe branches off.
In flight, a failsafe needs two signals
Note the chain: height variance is never compared in flight. Position variance doesn't raise the counter on its own either; it only comes into play when another condition already holds.
While the threshold is exceeded, a yaw reset is attempted on the 8th cycle and an IMU lane switch on the 9th. These are silent. If the excess lasts 10 cycles in a row, the failsafe triggers.
Why no failsafe triggers even though you see a red bar
In the 200-second recording below, you can see how the four variances separate when motor-current-induced magnetic interference rises on a hovering vehicle. Look at the region where the interference is on.
Only the compass crosses the threshold during the interference
Compass variance rises from 0.011 to 289 and stays above the threshold for 403 samples. Velocity variance peaks at 0.18 and position variance at 0.06, and neither gets near the threshold.
The EKF failsafe never triggers. The decision chain requires two independent signals, here there is only one, and the vehicle keeps flying.
Something else happens instead. The autopilot switches compasses 32 times and drops the line EKF3 IMU0 switching to compass 1 into the messages tab. Waiting for a failsafe just because you see a red bar is the wrong reflex. The real signal is in the messages tab.
Example: It's your turn to take off at the competition field, and as soon as you throttle up, the EKF label in the HUD turns red and only the compass bar shoots to the top in the window. The vehicle keeps flying and no failsafe arrives. But if compass switch lines keep appearing one after another in the messages tab, your compass is inside the field generated by the motor current. After landing, move the compass away from the power cables and the distribution board, and repeat the same test with the throttle up.
How to measure on your own board
The source of this problem on real hardware is motor current, the airframe metal, and where the compass is mounted. On your board, the motors themselves generate the interference, so measuring it is enough.
Instead of looking at the Mission Planner window, read the numbers directly. The code below connects to the autopilot and prints the four variances twice per second. It marks the one that exceeds the threshold at the end of the line.
from pymavlink import mavutil
m = mavutil.mavlink_connection('tcp:127.0.0.1:5760')
m.wait_heartbeat()
m.mav.command_long_send(
m.target_system, m.target_component,
mavutil.mavlink.MAV_CMD_SET_MESSAGE_INTERVAL, 0,
mavutil.mavlink.MAVLINK_MSG_ID_EKF_STATUS_REPORT, 500000, 0, 0, 0, 0, 0)
ESIK = 0.8
while True:
msg = m.recv_match(type='EKF_STATUS_REPORT', blocking=True, timeout=5)
if msg is None:
continue
olcum = [("compass", msg.compass_variance), ("hiz", msg.velocity_variance),
("position", msg.pos_horiz_variance), ("altitude", msg.pos_vert_variance)]
asan = [ad for ad, deger in olcum if deger >= ESIK]
satir = " ".join("%s=%6.3f" % (ad, deger) for ad, deger in olcum)
print(satir + (" OVER THRESHOLD: " + ", ".join(asan) if asan else ""))Run it with the vehicle on the ground and no throttle, then move on to takeoff without removing the propellers and watch the same lines. If there is interference, the difference appears the moment you throttle up, and the output looks like this:
compass=169.707 velocity= 0.011 position= 0.007 altitude= 0.000 OVER THRESHOLD: compass
compass=169.713 velocity= 0.011 position= 0.005 altitude= 0.000 OVER THRESHOLD: compass
compass=169.781 velocity= 0.011 position= 0.006 altitude= 0.000 OVER THRESHOLD: compass
compass=169.739 velocity= 0.010 position= 0.006 altitude= 0.000 OVER THRESHOLD: compass
compass=169.767 velocity= 0.010 position= 0.006 altitude= 0.000 OVER THRESHOLD: compass
compass=169.723 velocity= 0.010 position= 0.006 altitude= 0.000 OVER THRESHOLD: compass
compass=169.701 velocity= 0.009 position= 0.007 altitude= 0.000 OVER THRESHOLD: compass
compass=170.879 velocity= 0.009 position= 0.007 altitude= 0.000 OVER THRESHOLD: compassThe threshold is called FS_EKF_THRESH and its default value is 0.8.
The most common mistake is raising FS_EKF_THRESH to 1.0 to silence the warning. Raising the threshold doesn't fix the compass; it only narrows the window in which the autopilot can warn you. The interference stays exactly where it is, and the warning goes away.
Error Messages and Their Meanings
The following are texts that ArduPilot actually produces. They appear exactly like this in Mission Planner's messages tab.
PreArm: AHRS: EKF3 still initialising
EKF3 has started but its solution hasn't settled yet. Even after EKF3 is active, arming is delayed for a while. The gap is normal and you need to wait.
PreArm: Need Position Estimate
The EKF hasn't produced a position yet. If you're indoors, go outside and wait for the GPS to settle. The accelerometer and compass calibrations must be complete.
EKF compass variance
The compass heading looks wrong. Move the vehicle away from metal in the environment, separate the compass from the metal in the airframe, and repeat the calibration. Disabling the internal compass works for most setups.
EKF height variance
Barometer values are unstable or vibration is high. This message appears only before arming. The in-flight failsafe doesn't look at height variance.
EKF position variance
The GPS position is unstable. Move to an open area, remove any sources of emissions that could affect the GPS, and raise the antenna height.
EKF velocity variance
GPS or optical flow velocities are unstable. If you use optical flow, check its calibration.
EKF variance: over thresholds
A failsafe triggered and the cause is variance. This text has a second form, "position lost." In that case the problem is not variance but the EKF losing its position estimate entirely. They are two different faults that show up on the same line.
EKF Failsafe: changed to LAND Mode
The failsafe action ran. This is the default behavior: if you are in a mode that needs a position, the vehicle switches to LAND mode, roll and pitch stay with you, and the autopilot manages the descent rate.
EKF3 IMU0 switching to compass 1
The autopilot switched compasses. Seeing it once is normal. If it repeats back to back, it is telling you neither compass is satisfactory. In the interference example above, it repeats 32 times.
What changes in the field
- When you see a red bar, check which bar is red. Compass and position are not the same thing, and their fixes are not the same either.
- If the warning appears only when you throttle up, the cause is most likely motor current. Move the compass away from the power cables and the distribution board.
- If the warning always appears in a particular place, the cause is the environment. Move the same vehicle 200 meters away and try again.
- No failsafe doesn't mean there is no problem. Open the messages tab and count the compass switch lines.
More on this topic in the course
The threshold and decision chain here can't be memorized without knowing how the autopilot builds its position estimate. What the sensors measure, what calibration corrects, and what to check on the first flight are covered in the course, step by step.
These lessons are part of the Drone Basics: From Sensors to Flight course.
Was this article helpful?
Learn this topic from start to finish
Season plan: all six courses for 9 months, ₺790 a month. ₺390 a month for high school and university students, ₺351 the first month with your member code. You can stop in any month you like. Start the Season plan · I'm a student