Softivation

Why the GPS position suddenly drifts

If the map position suddenly drifts while the drone is hovering, GPS may not be the culprit. We explain where the jump comes from and what to check on your own board.

Furkan IŞIKAY 6 min read

The drone is hanging in the air and you aren't touching the transmitter. Then the icon on the map suddenly jumps thirty meters sideways. Sometimes it comes back on its own, sometimes the drone starts drifting toward the new point.

The odd part is that the satellite count on the screen is still ten and HDOP is still low. There's no visible problem with the GPS, but the position is moving.

What you see on the screen

The symptom shows up in three ways. The icon on the map skips one frame and returns to its old place. Or a drone sitting in LOITER mode slides a few meters without a command and settles again.

In the worst case, the autopilot cuts the flight and switches to land mode, and you stand on the ground thinking "but the GPS was fine."

The autopilot produces the jump

The autopilot doesn't read position directly from GPS. It builds its own estimate from the IMU and compass, and compares what comes from GPS against that estimate. The difference between the two is called the innovation.

If this difference exceeds a certain radius, the autopilot drops its own estimate and resets the position to wherever the GPS says it is. The default radius is 25 meters. Look at the moment in the figure where the estimate leaves the dashed circle: the jump you see on the map is that reset.

The jump on the map is the moment the estimate is reset to GPS

Schematic: the GPS position moves along a straight line, and the autopilot's estimate, drifting because of compass error, moves away from it. When the difference exceeds the 25-meter radius, the position is reset to GPS and the jump appears on the map.
Where to look: the dashed red circle and the hollow final point. The moment the estimate leaves the circle, the position jumps to the blue dot. The size of the jump shows how long the estimate has been drifting.

The size of the jump shows how long the autopilot has been in the wrong place. The radius is held in the EK3_GLITCH_RAD parameter.

The message says GPS, but GPS may not be the culprit

In this case ArduCopter sends the ground station this line: GPS Glitch or Compass error. When you see the message, you probably read only the first half.

The message reports that the autopilot can't reconcile GPS with its own estimate. The GPS data may be fine. What breaks the estimate side is usually the compass: a magnetometer mounted next to a power cable shifts its heading as you add throttle. The autopilot thinks it's heading the wrong way, finds GPS inconsistent, and rejects it.

In the "GPS glitch for unknown reason" thread on the ArduPilot forum, a user reported exactly this picture: the GPS track looked clean in the logs, but the EKF position was jumping. A developer who replied showed that the compass was affected by throttle. The problem ended when the user moved the compass away from the power cables and recalibrated.

Source: discuss.ardupilot.org, GPS glitch for unknown reason

The same pattern applies to vibration. On a board with a noisy IMU, the autopilot's estimate diverges quickly and it starts rejecting GPS. So when you see "GPS glitch," look first at the VIBE logs and the compass calibration.

See the mix-up for yourself in SITL

Instead of trying out GPS jamming in the field, you can simulate it in SITL. In ArduCopter 4.7.0, take the drone up to 30 meters, watch the EKF_STATUS_REPORT.pos_horiz_variance value, and set the SIM_GPS1_JAM parameter to 1. If you want to simulate a position jump, there are also the SIM_GPS1_GLTCH_X/Y/Z parameters.

When jamming starts, the variance exceeds the threshold

In SITL, when SIM_GPS1_JAM is set to 1, the horizontal position variance often rises above the 0.8 threshold. With jamming off, the variance stays near zero.
Where to look: the dashed 0.8 line, which is FS_EKF_THRESH. In the clean section on the left, the blue line never comes close to it. Once jamming starts, it stays above the line for a long time.

In the example in the figure, with jamming off, none of the 1638 samples come near the threshold; the highest value is 0.011. With jamming on, 437 of the 1001 samples (43.7%) are above the threshold, with a peak of 5.54.

After jamming starts, the autopilot first switches between EKF lanes. Then the failsafe kicks in and the vehicle is put into Land mode and lands.

What to do on your own board, step by step

These are field tasks; you'll look at your own board and flight logs.

  • Move the compass away from the power cables and ESCs, then recalibrate. If the heading drifts when you add throttle, the problem is here.
  • Measure the vibration. Put the flight controller on dampers and check the clipping count in the VIBE logs.
  • Don't push the GPS update rate. The GPS1_RATE_MS default is 200, which is 5 Hz. Most receivers can't carry 10 Hz with all constellations.
  • Separate the GPS antenna from the telemetry antenna. Putting the two side by side raises the noise floor in front of the receiver.
  • If you have two GPS units, turn on blending with GPS_AUTO_SWITCH. A momentary glitch in a single module shouldn't bring down navigation on its own.
  • Don't turn off ARMING_CHECK. With the checks off, you never see the warning, and you learn about the actual fault in the air.

Error Messages and Their Meanings

The lines below appear with exactly this text in ArduCopter 4.7.0.

GPS Glitch or Compass error

The autopilot couldn't reconcile the GPS position with its own estimate. The source is the gpsglitch_check function in ArduCopter/events.cpp.

Deal with the compass and vibration first. Before you blame GPS, look at the VIBE and MAG logs.

Glitch cleared

The closing line produced by the same function. The autopilot has agreed with GPS again.

Not good news on its own. Count how many times it opened and closed during the flight; if it repeats, the root cause is still there.

EKF variance

At least two of the position, velocity and compass variances exceeded the FS_EKF_THRESH value for 1 second. If the velocity variance exceeds twice the threshold, it is enough on its own. The default threshold is 0.8.

Don't silence it by raising the threshold. Find out from the log which variance is rising.

EKF Failsafe: changed to Land Mode

The EKF failsafe triggered and, per the FS_EKF_ACTION default, the vehicle was put into land mode.

Changing the failsafe action without fixing the root cause increases the risk. First find out why the variance is rising.

PreArm: High GPS HDOP

The HDOP value is above the GPS_HDOP_GOOD parameter. This parameter is in hundredths; the default is 140, which means HDOP 1.40.

If you need to loosen the parameter, enter 220, not 2.2. The wiki's "set it to 2.2 or 2.5" skips the unit and makes the check impossible.

What changes in the field

In simulation you turn jamming on and off yourself, so you know the cause. In the field, all you have is the result: a jump and a failsafe record.

That's why the job on the field side is narrowing down the root cause. Does the jump always happen in the same area, or when you add throttle? The first points to reflections and interference in the surroundings, the second to the compass and vibration on your own vehicle.

Example: In a swarm flight with five vehicles in the air at once, if only one icon jumps, look for the cause on that vehicle. Its compass may be mounted close to a power cable, or its board may not be getting away from vibration. If all five icons jump in the same second, the problem isn't in the vehicles but in interference or reflections in that area. You can make this distinction at a glance on the ground station and cut the search in half without digging into the log.

The long version of the diagnostic order

The long version of the diagnostic order in this article is in the Drone Communication Technologies course. The lesson "Position jumps in telemetry while raw GPS looks clean" has a MAVLink field map, working health monitor code, parameter defaults extracted from the source code, a log signature table and seven forum cases.

Was this article helpful?

Free resourcePixhawk and ArduPilot error message glossaryThe 4 messages in this article and similar ones are in the glossary: what they mean, why they appear, what to check first.