The extended Kalman filter (EKF) is a recursive state estimator that applies the Kalman filter equations to nonlinear motion and measurement models by linearizing them with first-order Taylor expansions around the current estimate. In robotics and in control systems more broadly, the EKF fuses noisy sensor readings with a dynamic model to produce a best estimate of the state and a covariance matrix that quantifies its uncertainty.
The filter has been the workhorse of robot localization, inertial navigation and early SLAM for decades because it is computationally light and works well when the nonlinearity is mild. Its weaknesses appear when the models are strongly nonlinear or the initial estimate is poor, which is why practitioners treat it as a pragmatic approximation rather than an optimal solution.
How the extended Kalman filter linearizes a nonlinear system
The EKF works by replacing the nonlinear functions of the system with local linear approximations at every time step. The process model x_k = f(x_{k-1}, u_k) + w_k describes how the state evolves under the control input, and the measurement model z_k = h(x_k) + v_k describes what the sensors should observe; both carry zero-mean Gaussian noise with covariances Q and R.
At each cycle the filter evaluates the Jacobian matrices F and H, the partial derivatives of f and h with respect to the state, at the latest estimate. These Jacobians play the role that the constant system matrices play in the linear Kalman filter, so the covariance propagation and the Kalman gain are computed exactly as in the linear case, while the mean is pushed through the full nonlinear functions.
The table below summarizes the two phases of one EKF iteration and what each step computes.
| Step | Computation | Purpose |
|---|---|---|
| State prediction | x⁻ = f(x, u) | Propagate the mean through the motion model |
| Covariance prediction | P⁻ = F P Fᵀ + Q | Grow uncertainty by model and process noise |
| Innovation | y = z − h(x⁻) | Compare the actual and expected measurement |
| Kalman gain | K = P⁻ Hᵀ (H P⁻ Hᵀ + R)⁻¹ | Weight the sensor against the prediction |
| State update | x = x⁻ + K y | Correct the estimate toward the measurement |
| Covariance update | P = (I − K H) P⁻ | Shrink uncertainty after the measurement |
Key parameters and tuning of an EKF
An EKF behaves well only when its noise covariances reflect reality. The process noise Q encodes how much the model is trusted, and the measurement noise R encodes how much each sensor is trusted; their ratio effectively sets the bandwidth of the estimator, trading responsiveness against smoothness.
| Parameter | Meaning | Effect if set too large | Effect if set too small |
|---|---|---|---|
| Process noise Q | Model uncertainty per step | Noisy, jumpy estimate | Sluggish response, divergence risk |
| Measurement noise R | Sensor uncertainty | Sensors largely ignored | Estimate follows sensor noise |
| Initial covariance P₀ | Confidence in the starting state | Early estimates follow first measurements | Wrong start is locked in |
| Update rate | Frequency of predict and update | Higher computational load | Larger linearization errors |
Engineers usually identify R from sensor datasheets and static recordings, then tune Q empirically. A standard consistency test is the normalized innovation squared (NIS), which should follow a chi-square distribution when the filter is well tuned; persistent values outside the expected band indicate mismatched covariances or model errors.
How the EKF compares with other state estimators
The EKF sits between the exact but restrictive linear Kalman filter and more expensive nonlinear estimators. Choosing among them is a question of nonlinearity, noise shape and compute budget, and each option fails in a different way.
| Estimator | Handles nonlinearity by | Relative cost | Typical weakness |
|---|---|---|---|
| Kalman filter | Assuming linear models | Lowest | Invalid for nonlinear systems |
| Extended Kalman filter | First-order Jacobian linearization | Low | Bias and divergence under strong nonlinearity |
| Unscented Kalman filter | Propagating deterministic sigma points | Moderate | Still assumes a Gaussian posterior |
| Particle filter | Sampling the full distribution | High | Sample depletion in high dimensions |
| Factor graph smoother | Iterative optimization over a window | Moderate to high | Latency and implementation complexity |
Variants refine the basic idea. The iterated EKF relinearizes the measurement model several times within one update, the error-state EKF estimates small deviations from a nominal trajectory and is standard in inertial navigation, and the invariant EKF exploits Lie-group symmetries so that the linearization does not depend on the current estimate.
Typical uses of the extended Kalman filter in robots
The EKF is the default choice wherever a robot must fuse fast proprioceptive sensors with slower absolute references. Inside a feedback loop, the estimated state feeds controllers such as PID, LQR or model predictive control, so estimation quality directly limits control performance.
- Mobile robot localization fusing wheel odometry, an IMU and GNSS or landmark observations.
- Attitude and heading estimation in drones, combining gyroscope integration with accelerometer and magnetometer corrections.
- Visual-inertial odometry, where an error-state EKF tracks pose, velocity and IMU biases.
- EKF-SLAM, which estimates the robot pose and landmark positions jointly in one state vector.
- Parameter estimation, for example identifying payload mass or friction by augmenting the state.
In the ROS 2 ecosystem, the widely used robot_localization package provides a configurable EKF node, which illustrates how routine the method has become in production robot software.
Limitations and common mistakes
The central limitation is that the EKF is not optimal for nonlinear systems: it ignores higher-order terms, so its covariance can become overconfident and the estimate can diverge without any warning from the filter itself. EKF-SLAM is a known example, where linearization errors make the map inconsistent as the robot revisits areas.
| Symptom | Likely cause | Remedy |
|---|---|---|
| Covariance collapses | Q too small or overconfident updates | Increase Q, check consistency with NIS |
| Estimate drifts away | Poor initial guess or strong nonlinearity | Better initialization, iterated EKF or UKF |
| Heading jumps by 2π | Angles not wrapped in the innovation | Normalize angle residuals |
| Matrix loses symmetry | Numerical round-off | Use the Joseph form update |
| Wrong Jacobians | Derivation or coding errors | Verify against numerical differentiation |
A further subtle error is treating correlated or delayed measurements as independent and current. Camera frames that arrive after processing delay, or sensors sharing a common error source, violate the filter assumptions and require time-stamped buffering or explicit modeling of the correlation.
Stripped to the essentials
A robot never knows exactly where it is. Its wheels slip, its sensors are noisy, and its own predictions drift. The extended Kalman filter is a method that keeps a running best guess and a measure of how sure the robot is about that guess.
It works in a loop. First the robot predicts where it should be based on how it moved. Then a sensor reading arrives, and the filter blends the prediction with the reading, trusting whichever source is more reliable at that moment. The word extended means it can handle curved, nonlinear behavior by treating it as nearly straight over very short steps, much like a road map that looks flat when one zooms in far enough.
Where it is applied
Consider an autonomous delivery robot in a hospital corridor. It runs an EKF at 100 Hz with a state of planar position, heading and velocity. Wheel odometry and a gyroscope drive the prediction step, while a ceiling-facing camera detects fiducial markers about twice per second and supplies absolute position corrections.
Between markers, the uncertainty ellipse grows steadily as wheel slip accumulates on polished floors. Each marker detection shrinks it again, keeping the position error below about five centimeters along the route. When a marker is blocked by a cart for several seconds, the robot continues on odometry alone and slows down because its covariance exceeds a safety threshold, then resumes normal speed once the next marker restores confidence. The result is reliable docking at charging stations without expensive lidar.