Outlier Rejection and Gating
Sensors sometimes return readings that are simply wrong: a GPS jump from a reflected signal, a laser hitting a passing person. A Kalman filter trusts every reading it is given, so one bad reading can throw it off. A gate checks each reading against what the filter expects and rejects ones that are too unlikely.
The Mahalanobis gate
Before using a reading \(\mathbf{z}\), compare it with the prediction using the innovation \(\mathbf{y} = \mathbf{z} - H\hat{\mathbf{x}}^-\) and its covariance \(S\):
For 2D readings, \(d^2\) follows a chi-square distribution with 2 degrees of freedom, so a threshold \(\gamma = 9.2\) keeps 99 percent of good readings.
What to notice
Without the gate, every outlier, a red cross far from the path, yanks the estimate sideways. With the gate on, those readings are rejected, shown faded, and the estimate stays smooth. Set the threshold too tight and the filter rejects good readings too, so it slowly drifts and grows overconfident. Set it too loose and outliers slip through. The gate grows with the filter's own uncertainty, so it automatically gets more lenient when the filter is less sure. One danger: if the filter's model is too confident, for example with process noise set too low for how sharply the robot can turn, good readings start falling outside the gate. The filter rejects them, drifts further, and rejects even more, until it loses track entirely. Gating only works when the filter's uncertainty is honest.