"GPS Glitch" / "Bad Velocity"
What it Means
When your HUD flashes GPS GLITCH, it does not necessarily mean the GPS signal is lost. It means the GPS is lying (or the EKF thinks it is).
The Flight Controller constantly integrates the IMU (Accelerometers) to predict where the drone should be. If the GPS reports a position that is statistically impossible based on the physics of the last few seconds, the EKF declares a Glitch.
The Trigger Mechanism
The EKF calculates two metrics:
posTestRatio: Position Error / Gate SizevelTestRatio: Velocity Error / Gate Size
The Gate Size is typically 5 Standard Deviations (EK3_POS_I_GATE = 500).
- Ratio < 1.0: Normal flight. GPS and IMU agree within reason.
- Ratio > 1.0: Glitch. The error is larger than 5x the expected uncertainty.
Common Causes in Virtual GPS
1. Latency Mismatch
If the time_usec timestamp is wrong, the "Rewind" mechanism fails.
- Scenario: You push the stick forward. The drone accelerates.
- IMU: "Moving forward at T=0."
- GPS: "Still at Start at T=0." (Because the packet was delayed but not timestamped correctly).
- Result: The EKF sees a massive disagreement between the IMU prediction (Moved) and GPS report (Stationary). GPS GLITCH.
2. The Multipath Teleport
In an urban canyon, a reflection might cause the position solution to jump 10 meters instantly.
- Physics: A drone cannot move 10 meters in 0.1 seconds (100 m/s velocity).
- Reaction: The EKF rejects the jump as physically impossible. It triggers a glitch and ignores the GPS until it "settles."
Recovery
To clear the glitch, the GPS and IMU must agree (Ratio < 1.0) for 10 continuous seconds. This prevents the drone from latching onto a bad signal that is just fluctuating wildly.