Thrun et al., Chapter 7

Mobile Robot Localization

Markov localization, EKF localization with feature-based maps, data association, and multi-hypothesis tracking.

Prerequisites: Chapters 2-6 (Bayes filter, Gaussian filters, motion & sensor models).
10
Chapters
1
Simulation
10
Quizzes

Chapter 0: Why Localization?

A robot has a map. It has sensors. It moves around. But where is it? This is the mobile robot localization problem: determining the robot's pose (x, y, θ) relative to a known map, using sensor data accumulated over time.

Localization is fundamentally a problem of coordinate transformation. The map lives in a global frame. The robot's sensors live in a local frame. Knowing the robot's pose connects the two, enabling navigation, obstacle avoidance, and task execution.

The core challenge: A robot in a long corridor sees identical walls in every direction. A single sensor reading is ambiguous — many poses could explain it. The robot must integrate data over time, combining motion and measurements through the Bayes filter, to narrow down its location. Localization is the Bayes filter applied to the pose estimation problem.

No robot has a perfect pose sensor. GPS is noisy and unavailable indoors. Wheel odometry drifts. The pose must be inferred from indirect evidence, and that inference is inherently probabilistic.

Check: What is the mobile robot localization problem?

Chapter 1: A Taxonomy of Localization Problems

Not all localization problems are equally hard. We classify them along four dimensions:

DimensionEasyHard
Initial knowledgePosition tracking (pose roughly known)Global localization (pose unknown)
EnvironmentStatic (only robot moves)Dynamic (people, furniture move)
ControlActive (controls motion for localization)Passive (observes only)
RobotsSingle robotMulti-robot (can share beliefs)

Position tracking assumes the initial pose is approximately known. Uncertainty stays small and local — a single Gaussian suffices. This is the easiest case.

Global localization starts from complete ignorance. The robot could be anywhere. The belief must be multi-modal — a single Gaussian cannot represent "maybe I'm here or maybe I'm there." This is much harder.

The kidnapped robot problem is the hardest: the robot thinks it knows where it is, but it has been secretly moved. It must detect its own failure and re-localize from scratch. This tests an algorithm's ability to recover from catastrophic errors.

Why kidnapping matters: No localization algorithm is perfect. Wheels slip, sensors fail, maps become outdated. The kidnapped robot problem is a proxy for testing whether an algorithm can recover from real-world failures, not just artificial teleportation.
Check: Why is global localization harder than position tracking?

Chapter 2: Markov Localization

Markov localization is simply the Bayes filter applied to the localization problem. It is the most general probabilistic localization algorithm — every other method in this chapter is a special case.

The algorithm takes a belief bel(xt-1), a control ut, a measurement zt, and a map m, then outputs the updated belief bel(xt):

Prediction: bel̄(xt) = ∫ p(xt | ut, xt-1, m) bel(xt-1) dxt-1
Update: bel(xt) = η p(zt | xt, m) bel̄(xt)

The initial belief determines the type of problem being solved:

ProblemInitial bel(x0)
Position trackingNarrow Gaussian around known pose
Global localizationUniform over all poses in the map
Kidnapped robotMust inject random particles / uniform mass during operation
Key point: Markov localization is representation-agnostic. The belief can be a Gaussian (Ch 7.5), a histogram grid (Ch 8.2), or a particle set (Ch 8.3). The algorithm is the same — only the representation changes. Each choice brings different strengths and limitations.
Check: How does Markov localization handle global localization?

Chapter 3: The Hallway Example

Consider a 1D hallway with three identical doors. The robot starts with no idea where it is (uniform belief). Watch the Bayes filter in action:

Step 1 — Sense a door: The robot detects it is next to a door. It multiplies its uniform belief by p(z|x,m), which peaks at the three door locations. The resulting belief has three peaks — the robot knows it's near some door, but not which one.

Step 2 — Move right: The prediction step convolves the belief with the motion model. Each peak shifts right and spreads out (motion adds uncertainty).

Step 3 — Sense a door again: The second measurement multiplies in another likelihood. Now the posterior strongly favors the correct position, because only one hypothesis is consistent with seeing a door at this new location after moving that distance.

The magic of sequential estimation: One measurement gives three hypotheses. Two measurements plus the distance traveled between them collapse the ambiguity to (almost) one. The Bayes filter accumulates evidence over time, and that accumulation is what makes localization possible despite ambiguous individual measurements.

This example works beautifully with histograms and particle filters, which can represent multi-modal beliefs. With an EKF (single Gaussian), we need to know which door we're at — we can't represent three hypotheses simultaneously.

Check: Why do two measurements resolve the ambiguity that one cannot?

Chapter 4: EKF Localization

EKF localization represents the belief as a single Gaussian: mean μt and covariance Σt. It uses feature-based maps — a list of point landmarks with known positions.

At each time step, the robot observes a set of features zt = {zt1, zt2, ...}, where each feature measurement is a vector:

zti = (rti, φti, sti)T

containing the range r (distance), bearing φ (angle), and signature s (identity) of the landmark.

The EKF localization algorithm has two phases:

Motion update (lines 2-4): Predict the new pose using the velocity motion model. The mean shifts by the expected motion; the covariance grows by the motion noise Rt.

Measurement update (lines 5-15): For each observed feature, compute the expected measurement, the Jacobian Hti, and the Kalman gain Kti. Each feature tightens the uncertainty.

How multiple features help: The updates from multiple features are additive in information space. Each observed landmark contributes independent evidence about the pose, and the EKF combines them all. More landmarks = lower uncertainty.

The key limitation: EKF localization can only handle position tracking. The Gaussian cannot represent multi-modal beliefs, so global localization is impossible.

Check: Why can't EKF localization solve global localization?

Chapter 5: The EKF Localization Algorithm

Here is the concrete algorithm, step by step. We use the velocity motion model and the feature-based measurement model.

Motion update: Given control ut = (vt, ωt), compute the predicted pose and covariance:

μ̄t = μt-1 + (- v/ω sinθ + v/ω sin(θ+ωΔt), v/ω cosθ - v/ω cos(θ+ωΔt), ωΔt)T
Σ̄t = Gt Σt-1 GtT + Rt

where Gt is the Jacobian of the motion model at μt-1.

Measurement update: For each observed feature zti with known correspondence cti = j:

δ = (mj,x - μ̄t,x, mj,y - μ̄t,y)T,   q = δTδ
ti = (√q, atan2(δyx) - μ̄t,θ, mj,s)T
Kti = Σ̄t HtiT (Hti Σ̄t HtiT + Qt)-1

The final pose estimate integrates all features:

μt = μ̄t + Σi Kti (zti - ẑti)
Σt = (I - Σi Kti Hti) Σ̄t
Signature has no effect: The last row of Hti is all zeros because the signature s doesn't depend on the robot pose. If we already know the correspondence, the observed signature is uninformative. It only matters when correspondences are unknown.
Check: What does the Jacobian Gt capture?

Chapter 6: Unknown Correspondences

In practice, the robot doesn't know which landmark it's seeing. The feature signature helps, but isn't always unique. This is the data association problem.

The simplest solution: maximum likelihood correspondence. For each detected feature zti, find the landmark k that makes the measurement most probable:

j(i) = argmink (zti - ẑtk)T Ψk-1 (zti - ẑtk)

where Ψk = Htk Σ̄t HtkT + Qt is the innovation covariance — the combined uncertainty of the pose and the measurement projected into measurement space.

This is a Mahalanobis distance: it measures how surprising the measurement is, normalized by the expected uncertainty. The landmark with the smallest Mahalanobis distance wins.

Danger of wrong associations: A single wrong correspondence can be catastrophic. If the robot thinks it sees landmark 3 but it's actually landmark 7, the Kalman gain will push the pose estimate in the wrong direction. This error compounds: the wrong pose leads to more wrong correspondences, causing the filter to diverge.

Two defenses: (1) Design landmarks to be unique and well-separated. (2) Keep the pose uncertainty small — a narrow Gaussian makes it unlikely that a far-away landmark is mistaken for a nearby one. Also, apply an outlier threshold: reject any correspondence whose Mahalanobis distance exceeds a cutoff.

Check: What does maximum likelihood correspondence minimize?

Chapter 7: Multi-Hypothesis Tracking

Maximum likelihood correspondence is brittle — it bets everything on one hypothesis. The Multi-Hypothesis Tracking (MHT) algorithm hedges its bets by maintaining multiple Gaussians simultaneously:

bel(xt) = Σl ψt,l · N(xt; μt,l, Σt,l) / Σl ψt,l

Each mixture component (or track) carries its own mean μt,l, covariance Σt,l, and weight ψt,l. Each track is conditioned on a unique history of data association decisions.

How it works: At each time step, every existing track spawns new tracks for each possible correspondence assignment. Each new track's weight is set to:

ψt,m = ψt,l · p(zt | c1:t-1,l, ct,m, z1:t-1, u1:t)

Tracks with weight below a threshold ψmin are pruned. This keeps the number of tracks manageable — at most 1/ψmin tracks at any time.

MHT vs EKF: The MHT is more robust to data association errors because it doesn't commit to a single hypothesis. But it is more expensive, and it still can't solve true global localization — the Taylor expansion breaks down when σθ exceeds about ±20 degrees.
Check: How does MHT handle ambiguous correspondences?

Chapter 8: Localization Demo

Watch EKF localization in action. A robot moves along a corridor and observes landmarks with known positions. The blue ellipse shows the pose uncertainty (covariance). When a landmark is observed, the ellipse shrinks.

EKF Localization: Landmark Observation

The robot moves right. Uncertainty grows during motion (ellipse expands). Observing a landmark (teal diamond) shrinks the uncertainty. Click "Step" to advance.

Ready. Click Step to begin.
What to notice: The covariance ellipse elongates during motion (prediction adds noise) and contracts when a landmark is observed (measurement reduces uncertainty). After passing a landmark, the ellipse starts growing again until the next observation.
Check: What happens to the EKF covariance ellipse during motion without observations?

Chapter 9: Summary

This chapter introduced mobile robot localization and the EKF approach. Key takeaways:

ConceptKey Point
Markov localizationBayes filter for pose estimation; representation-agnostic
Position trackingEasy — small, local uncertainty; Gaussian works well
Global localizationHard — multi-modal; Gaussians insufficient
EKF localizationGaussian belief + feature-based maps; position tracking only
ML correspondencePick the most likely landmark; fast but brittle
MHTGaussian mixture; robust to association errors; still local
What comes next: The EKF and MHT are limited to position tracking. Chapter 8 introduces grid localization and Monte Carlo localization (MCL) — nonparametric algorithms that can solve global localization and even recover from kidnapping.
"A single Gaussian can track a known position.
But to find yourself from scratch,
you need the full power of the Bayes filter."
Check: Which localization problems can EKF localization solve?