Explaining EKF-SLAM update and Mahalanobis gating
The EKF-SLAM update fuses predicted robot and landmark states with a new measurement by linearizing the nonlinear measurement model around the prediction, computing the innovation (residual), and calculating the Kalman gain to update the state and covariance. Data association uses the Mahalanobis distance—a residual weighted by the innovation covariance—to find the most likely landmark correspondence by gating with a threshold. The covariance update reduces uncertainty in both the robot pose and observed landmarks by incorporating measurement information and exploiting cross-correlations, shrinking the covariance along observed directions and establishing correlations between robot and landmarks that improve overall state certainty.
In an EKF‑SLAM formulation you treat the robot pose and all of the currently mapped feature positions as a single, joint state
[
x = \begin{bmatrix} x_r \ y_r \ \theta_r \ x_{\ell_1} \ y_{\ell_1} \ \vdots \end{bmatrix}
]
with an associated covariance (P) that captures not only the marginal uncertainty on each component but also the cross–correlations between the robot and the landmarks.
The prediction step propagates (x) and (P) through the motion model. When a sensor observation (z) arrives, the update step proceeds by comparing it to what the current state would predict. For a landmark (j) with state ([x_{\ell_j},y_{\ell_j}]) the nonlinear measurement function (h_j(x)) expresses range/bearing, pixel location, etc. from the robot to that landmark. In the EKF you linearise this function about the predicted state to obtain a Jacobian (H_j) with respect to the full state, and then form the innovation
[
\nu_j = z - h_j(\hat{x}^{-}),\qquad S_j = H_j,\hat{P}^{-},H_j^\top + R,
]
where (\hat{x}^{-},\hat{P}^{-}) are the predicted mean and covariance and (R) is the measurement noise covariance. The Kalman gain
[
K_j = \hat{P}^{-},H_j^\top,S_j^{-1}
]
tells you how to adjust the state estimate:
[
\hat{x}^{+} = \hat{x}^{-} + K_j \nu_j,
]
and how to shrink its uncertainty:
[
P^{+} = \bigl(I - K_j H_j\bigr),\hat{P}^{-}.
]
A more numerically robust “Joseph” form, (P^{+} = (I-KH)P^{-}(I-KH)^\top + K R K^\top), is also used.
Data association – deciding which map feature a given (z) came from – is handled by evaluating how compatible each landmark’s predicted measurement is with the actual measurement. The squared Mahalanobis distance
[
d_j^2 = \nu_j^\top,S_j^{-1},\nu_j
]
measures the residual in units of standard deviation, taking into account both sensor noise and state uncertainty. The landmark with the smallest (d_j^2) below a gating threshold is selected as the correspondence; if no distance is small enough, the observation may be treated as a new landmark.
Because the state and covariance are joint, updating with a measurement of landmark (j) does not only tighten the uncertainty on ([x_{\ell_j},y_{\ell_j}]). The nonzero entries in (H_j) pick out the robot and that landmark, and through the cross–covariances in (\hat{P}^{-}) the Kalman gain spreads the information to other components. The diagonal elements corresponding to the robot pose and the observed landmark decrease, reflecting reduced uncertainty, and the off–diagonal terms are adjusted to reflect the new correlations. Over time, as more observations are fused, the pose and map estimates become more certain where they are constrained by measurements.