Extended Kalman Filter (EKF)

The Extended Kalman Filter is the workhorse of recursive state estimation with nonlinear models. It maintains a Gaussian belief N(x^,P)\mathcal{N}(\hat{\mathbf{x}}, P) over the state and alternates two steps — predict (propagate the belief through a motion model) and update (correct it with a measurement) — which is exactly the recursive Bayes filter with all densities approximated as Gaussians and all models linearized at the current estimate.

Setup

The system is described by a nonlinear motion model and a nonlinear observation model:

xk=f(xk1,uk)+wk,wkN(0,Qk)\mathbf{x}_k = f(\mathbf{x}_{k-1}, \mathbf{u}_k) + \mathbf{w}_k, \qquad \mathbf{w}_k \sim \mathcal{N}(\mathbf{0}, Q_k) zk=h(xk)+vk,vkN(0,Rk)\mathbf{z}_k = h(\mathbf{x}_k) + \mathbf{v}_k, \qquad \mathbf{v}_k \sim \mathcal{N}(\mathbf{0}, R_k)

where x\mathbf{x} is the state (e.g., camera pose, velocity, landmark positions), u\mathbf{u} a control or IMU input, z\mathbf{z} a measurement (e.g., pixel coordinates of a tracked feature), and QQ, RR the process and measurement noise covariances. The EKF linearizes ff and hh with their Jacobians evaluated at the current estimate:

Fk=fxx^k1k1,Hk=hxx^kk1F_k = \left.\frac{\partial f}{\partial \mathbf{x}}\right|_{\hat{\mathbf{x}}_{k-1|k-1}}, \qquad H_k = \left.\frac{\partial h}{\partial \mathbf{x}}\right|_{\hat{\mathbf{x}}_{k|k-1}}

Predict

x^kk1=f(x^k1k1,uk)\hat{\mathbf{x}}_{k|k-1} = f(\hat{\mathbf{x}}_{k-1|k-1}, \mathbf{u}_k) Pkk1=FkPk1k1FkT+QkP_{k|k-1} = F_k P_{k-1|k-1} F_k^T + Q_k

The mean is pushed through the full nonlinear model; only the covariance uses the linearization. Uncertainty grows in this step (dead-reckoning drift).

Update

yk=zkh(x^kk1)(innovation)\mathbf{y}_k = \mathbf{z}_k - h(\hat{\mathbf{x}}_{k|k-1}) \qquad \text{(innovation)} Sk=HkPkk1HkT+Rk(innovation covariance)S_k = H_k P_{k|k-1} H_k^T + R_k \qquad \text{(innovation covariance)} Kk=Pkk1HkTSk1(Kalman gain)K_k = P_{k|k-1} H_k^T S_k^{-1} \qquad \text{(Kalman gain)} x^kk=x^kk1+Kkyk,Pkk=(IKkHk)Pkk1\hat{\mathbf{x}}_{k|k} = \hat{\mathbf{x}}_{k|k-1} + K_k \mathbf{y}_k, \qquad P_{k|k} = (I - K_k H_k)\, P_{k|k-1}

The gain KkK_k weighs the measurement against the prediction: confident predictions (small PP) or noisy sensors (large RR) yield small corrections, and vice versa. The innovation covariance SkS_k also supports gating — a Mahalanobis test yTS1y<χ2\mathbf{y}^T S^{-1} \mathbf{y} < \chi^2 threshold rejects outlier measurements before they corrupt the state.

EKF-SLAM

In EKF-SLAM (the formulation behind MonoSLAM), the state stacks the camera/robot pose and all landmark positions,

x=[xrobotTm1TmnT]T,\mathbf{x} = \begin{bmatrix} \mathbf{x}_{\text{robot}}^T & \mathbf{m}_1^T & \cdots & \mathbf{m}_n^T \end{bmatrix}^T,

and PP stores the full joint covariance including pose-landmark and landmark-landmark correlations. Those cross-correlations are what makes loop closure work in a filter: correcting the pose also drags every correlated landmark. The costs are structural:

These limitations are why modern visual SLAM moved to keyframe-based nonlinear optimization (“why filter?” debate, Strasdat et al.), while filtering survives where its constant-time recursive form shines: visual-inertial odometry (MSCKF, ROVIO, error-state EKFs) and sensor fusion of odometry with GPS/RADAR/wheel encoders.

Why it matters for SLAM

The EKF is the historical foundation of SLAM (EKF-SLAM was the solution for a decade) and is still the backbone of production VIO (MSCKF derivatives run on many AR headsets and drones). Even in optimization-centric pipelines, EKF concepts are everywhere: prediction/update structure, innovation gating for outlier rejection, covariance propagation for uncertainty, and marginalization (a fixed-lag smoother’s marginalization step is algebraically a Kalman update). Understanding when the EKF’s single-linearization assumption breaks is the key to understanding why bundle adjustment wins on accuracy and why MSCKF-style filters delay linearization.