EKF SLAM: jointly estimating robot pose and landmark positions with the extended Kalman filter.
The robot has no map. It doesn't know where it is. All it has are sensor measurements z1:t and controls u1:t. It must simultaneously build a map of the environment and localize itself within that map. This is SLAM — Simultaneous Localization and Mapping.
SLAM is more difficult than localization (Chapter 7) because the map is unknown and must be estimated. It is more difficult than mapping (Chapter 9) because the poses are unknown and must be estimated. The interaction between these two unknowns creates rich mathematical structure that we will explore over the next five chapters.
The SLAM problem has two components: a continuous component (estimating poses and landmark positions) and a discrete component (determining which observation corresponds to which landmark — the data association problem).
There are two formulations of the SLAM problem:
| Formulation | Posterior | Character |
|---|---|---|
| Online SLAM | p(xt, m | z1:t, u1:t) | Current pose + map; incremental |
| Full SLAM | p(x1:t, m | z1:t, u1:t) | Entire path + map; batch |
Online SLAM estimates only the current pose xt and the map m. Past poses are integrated out. This is what we need for real-time operation: the robot processes data incrementally and discards old measurements.
Full SLAM estimates the entire path x1:t and the map. This is a batch problem — all data is considered at once. Full SLAM can produce better maps because it can revise past pose estimates when new information arrives.
EKF SLAM applies the extended Kalman filter to the online SLAM problem. It makes several key assumptions:
• Feature-based maps: The map is a collection of N point landmarks. Each landmark has coordinates (mj,x, mj,y) and a signature sj.
• Gaussian noise: Motion and measurement noise are Gaussian. The posterior must remain approximately Gaussian.
• Small uncertainty: Linearization only works well when the uncertainty is small (orientation error < 20°).
• Positive measurements only: The algorithm can only process observed landmarks, not the absence of expected landmarks.
With known correspondences, EKF SLAM is a direct extension of EKF localization. The state vector combines the robot pose and all landmarks:
This is a vector of dimension 3 + 3N. The mean μt and covariance Σt are (3+3N)-dimensional.
Motion update: Only the robot pose changes during motion. The landmark positions stay the same. But the covariance grows because the robot-landmark correlations weaken with motion noise.
Measurement update: Observing landmark j updates both the robot pose estimate and the landmark j position estimate. Because of the correlations in Σt, observing landmark j also indirectly improves the estimates of all other landmarks.
The covariance matrix Σt is the heart of EKF SLAM. It has dimension (3+3N) × (3+3N) and encodes all uncertainty:
| Block | Dimension | Meaning |
|---|---|---|
| Σxx | 3 × 3 | Robot pose uncertainty |
| Σxmj | 3 × 3 | Correlation between robot and landmark j |
| Σmimj | 3 × 3 | Correlation between landmarks i and j |
The off-diagonal blocks are crucial. When the robot observes landmark A and then moves to observe landmark B, the two landmarks become correlated through the shared robot pose. The covariance matrix captures this: ΣmAmB ≠ 0.
The computational cost: storing Σt requires O(N2) space. Updating it requires O(N2) time per observation. For 1,000 landmarks, that's a million-element matrix — manageable. For 100,000 landmarks, it's ten billion elements — impractical. This quadratic scaling is the main limitation of EKF SLAM.
Why do landmark estimates become correlated? Consider this scenario:
1. The robot sees landmark A. Now the robot pose and A are correlated.
2. The robot moves and sees landmark B. Now the robot pose and B are correlated.
3. Through the shared robot pose, A and B become correlated: if A turns out to be further east than expected, the robot was probably further east when it saw A, which means it was also further east when it saw B, which means B is probably further east too.
The price of correlations: you cannot estimate landmarks independently. Updating any single landmark requires updating its correlations with all other landmarks. This is why the covariance matrix is dense and updates are O(N2).
In practice, the robot doesn't know which landmark it's seeing. EKF SLAM uses the same maximum likelihood correspondence approach as EKF localization (Chapter 7):
Minimizing the Mahalanobis distance over all known landmarks. If no landmark produces a sufficiently small distance, the observation is treated as a new landmark and added to the state vector.
Provisional landmarks: A practical defense: don't permanently add a landmark until it has been observed multiple times with consistent correspondences. This prevents spurious features (sensor noise, moving objects) from polluting the map.
The quality of EKF SLAM depends heavily on the quality of the features. Several strategies help:
| Strategy | Purpose |
|---|---|
| Provisional landmarks | Require multiple consistent observations before adding to map |
| Outlier rejection | Discard observations with large Mahalanobis distance |
| Mutual exclusion | Two different observations can't correspond to the same landmark |
| Landmark pruning | Remove landmarks that haven't been seen in a long time |
The landmark density trade-off: Too few landmarks and the robot can't localize accurately (large pose uncertainty increases wrong-correspondence risk). Too many landmarks and the computation becomes prohibitive, plus dense landmarks are easily confused with each other.
Watch EKF SLAM in action. The robot moves through an environment, discovering landmarks. The state vector grows as new landmarks are added. Covariance ellipses show the uncertainty of each estimate.
Orange dot = robot, teal diamonds = estimated landmark positions, ellipses = uncertainty. Click Step to move the robot and discover/re-observe landmarks.
| Aspect | EKF SLAM |
|---|---|
| State | Robot pose + all landmark positions (3+3N dimensions) |
| Complexity | O(N2) per update |
| Map type | Feature-based (point landmarks) |
| Correlations | Dense covariance; all landmarks correlated |
| Loop closure | Powerful — improves all estimates simultaneously |
| Limitations | Quadratic scaling, Gaussian assumption, brittle correspondences |