Extended Kalman Filter (EKF)
Problem Statement
The EKF estimates nonlinear UAV state with Gaussian uncertainty when direct closed-form Bayesian updates are unavailable. It is commonly used for tightly-coupled inertial and positional sensing in real-time flight stacks.
Model and Formulation
Nonlinear system:
Linearization around the current estimate yields Jacobians F_k = \partial f/\partial x, H_k = \partial h/\partial x. The covariance recursion is:
Algorithm Procedure
- Predict state with nonlinear process model
f. - Propagate covariance using local Jacobian
F_k. - Compute innovation
y_k = z_k - h(\hat{x}_{k|k-1}). - Update state and covariance with Kalman gain
K_k.
Tuning Guidance
Qis the covariance accumulated over one step, so it must scale withdt. A fixeddiag([...])means something different at every rate: at 200 Hz a "reasonable looking"0.1on the velocity states claims the velocity random-walks by 0.32 m/s every 5 ms. The filter concludes its own prediction is worthless and degenerates into echoing the raw measurement — all the machinery, none of the benefit.- Build it from an acceleration noise density instead, and the tuning survives a change of step size:
from uav_sim.estimation import constant_velocity_q
ekf.Q = constant_velocity_q(dt, psd=1.0)Sanity-check the reported 1σ against the actual error. They should be the same order. A filter whose covariance is far tighter than its error has stopped listening; one whose covariance is far looser is wasting the prediction. The atlas demo reports 0.33 m of 1σ against 0.47 m of error.
The result to expect: the filter must beat its own sensor. Here, 0.47 m against 0.63 m of raw GPS.
Start with conservative
Qto avoid overconfident predictions.Increase
Rfor noisy GPS updates in urban or multipath environments.Validate filter consistency using normalized innovation squared (NIS).
Failure Modes and Diagnostics
- Linearization error can destabilize updates during aggressive maneuvers.
- Unmodeled bias states produce persistent innovation drift.
- Divergence often appears as shrinking covariance but rising position error.
Implementation and Execution
python -m uav_sim.simulations.estimation.ekfEvidence

References
- Julier and Uhlmann, New Extension of the Kalman Filter to Nonlinear Systems (1997)
- Maybeck, Stochastic Models, Estimation, and Control, Volume 1