Extended Kalman filter

Also known as: EKF

On this page 7

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.

StepComputationPurpose
State predictionx⁻ = f(x, u)Propagate the mean through the motion model
Covariance predictionP⁻ = F P Fᵀ + QGrow uncertainty by model and process noise
Innovationy = z − h(x⁻)Compare the actual and expected measurement
Kalman gainK = P⁻ Hᵀ (H P⁻ Hᵀ + R)⁻¹Weight the sensor against the prediction
State updatex = x⁻ + K yCorrect the estimate toward the measurement
Covariance updateP = (I − K H) P⁻Shrink uncertainty after the measurement
The predict and update steps of one EKF cycle

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.

ParameterMeaningEffect if set too largeEffect if set too small
Process noise QModel uncertainty per stepNoisy, jumpy estimateSluggish response, divergence risk
Measurement noise RSensor uncertaintySensors largely ignoredEstimate follows sensor noise
Initial covariance P₀Confidence in the starting stateEarly estimates follow first measurementsWrong start is locked in
Update rateFrequency of predict and updateHigher computational loadLarger linearization errors
Main EKF parameters and their effects

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.

EstimatorHandles nonlinearity byRelative costTypical weakness
Kalman filterAssuming linear modelsLowestInvalid for nonlinear systems
Extended Kalman filterFirst-order Jacobian linearizationLowBias and divergence under strong nonlinearity
Unscented Kalman filterPropagating deterministic sigma pointsModerateStill assumes a Gaussian posterior
Particle filterSampling the full distributionHighSample depletion in high dimensions
Factor graph smootherIterative optimization over a windowModerate to highLatency and implementation complexity
EKF compared with related estimators

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.

SymptomLikely causeRemedy
Covariance collapsesQ too small or overconfident updatesIncrease Q, check consistency with NIS
Estimate drifts awayPoor initial guess or strong nonlinearityBetter initialization, iterated EKF or UKF
Heading jumps by 2πAngles not wrapped in the innovationNormalize angle residuals
Matrix loses symmetryNumerical round-offUse the Joseph form update
Wrong JacobiansDerivation or coding errorsVerify against numerical differentiation
Frequent EKF problems and their remedies

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.