Thrun et al., Chapter 8

Grid & Monte Carlo Localization

Nonparametric localization: histogram grids, particle filters, recovery from kidnapping, and dynamic environments.

Prerequisites: Chapters 4, 7 (nonparametric filters, EKF localization).
10
Chapters
1
Simulation
10
Quizzes

Chapter 0: Beyond Gaussians

The EKF localization algorithm from Chapter 7 is limited to position tracking. It can't solve global localization because a single Gaussian can't represent "I might be here or there or over there." This chapter introduces two algorithms that break through this barrier:

AlgorithmRepresentationCapabilities
Grid localizationHistogram over a pose gridGlobal localization, multi-modal beliefs
Monte Carlo localization (MCL)Weighted particle setGlobal localization, kidnapped robot, dynamic environments
What makes these algorithms powerful: They can process raw sensor data (no feature extraction needed). They can represent arbitrary belief shapes. They can handle negative information ("I don't see a landmark here, so I'm probably not near one"). And they can solve global localization from complete ignorance.

Both algorithms are direct implementations of the Bayes filter from Chapter 2, using the nonparametric representations from Chapter 4. The difference from EKF localization is purely in the representation of the belief.

Check: What key limitation of EKF localization do grid and MCL algorithms overcome?

Chapter 1: Grid Localization

Grid localization divides the pose space (x, y, θ) into a grid of cells. Each cell holds a probability value pk,t. The algorithm is the discrete Bayes filter applied to localization:

Prediction:k,t = Σi pi,t-1 · p(mean(xk) | ut, mean(xi))
Update: pk,t = η · p(zt | mean(xk), m) · p̄k,t

The prediction step sums over all cells, applying the motion model. The update step multiplies by the measurement likelihood and normalizes.

A typical indoor grid uses 15 cm resolution in x and y, and 5 degrees in θ. For a 50m × 50m environment, that's roughly 330 × 330 × 72 ≈ 8 million cells. This is a lot, but manageable with careful implementation.

Key strength: Grid localization naturally represents multi-modal beliefs. In the hallway example, the three door hypotheses appear as three peaks in the histogram — no special handling needed. The algorithm automatically resolves ambiguity as evidence accumulates.
Check: What is each grid cell's value in grid localization?

Chapter 2: Grid Resolution

The resolution of the grid creates a fundamental trade-off:

ResolutionAccuracyComputationUse Case
Fine (15cm, 5°)HighVery expensiveMetric localization
Coarse (rooms, junctions)LowCheapTopological navigation

Coarse grids require noise inflation. When a grid cell is large, the measurement model p(z|x) varies wildly within a single cell. Evaluating it only at the cell center gives poor results. The standard fix: inflate the noise variance by half the cell diameter. This smooths out the likelihood function but loses information.

Motion on coarse grids is also tricky. If the robot moves 10cm/sec but the grid cells are 1m wide, the naive algorithm never transitions between cells. The fix: add random transitions to adjacent cells with probability proportional to (motion distance) / (cell diameter).

The sweet spot: Experiments show that localization error increases roughly linearly with cell size, while computation time decreases quadratically. A 15-30cm resolution with a laser scanner gives a good balance. For ultrasound, courser grids (40-60cm) work better because the sensor is inherently less precise.

Advanced implementations use selective updating: only recompute cells where the belief is significant, skipping the vast majority of zero-probability cells. This can speed up grid localization by orders of magnitude.

Check: Why do coarse grids require noise inflation in the sensor model?

Chapter 3: The MCL Algorithm

Monte Carlo Localization (MCL) is the particle filter applied to localization. It represents the belief as a set of M weighted particles: Xt = {(xt[m], wt[m])}m=1..M.

The algorithm, at each time step:

1. Sample a new pose for each particle from the motion model: xt[m] ~ p(xt | ut, xt-1[m])

2. Weight each particle by the measurement likelihood: wt[m] = p(zt | xt[m], m)

3. Resample: Draw M new particles with replacement, probability proportional to weights.

Why MCL dominates in practice: It is simple to implement, efficient (linear in M), works with any sensor model, naturally represents multi-modal beliefs, and scales gracefully — more particles = more accuracy, fewer = more speed. MCL is arguably the most widely used localization algorithm in fielded robotic systems.

For global localization, particles are initialized uniformly over the map. As measurements arrive, particles in wrong locations get low weights and are eliminated during resampling. Particles near the true pose survive and multiply.

Check: In MCL, what determines whether a particle survives resampling?

Chapter 4: Properties of MCL

MCL has several important properties that distinguish it from other localization methods:

PropertyDescription
ConsistencyAs M → ∞, the particle distribution converges to the true posterior
AnytimeWorks with any number of particles; more = better approximation
Multi-modalNaturally represents multiple hypotheses
Non-parametricNo assumptions about the shape of the belief
AdaptiveCan adjust particle count based on uncertainty (KLD-sampling)

Particle deprivation is MCL's Achilles heel. Once all particles have converged to one location, there are no particles left in other regions. If the robot is kidnapped to a new location, no particles will be near the true pose, and the algorithm cannot recover.

A related issue: during global localization in a large environment, the number of particles needed to adequately cover the space can be enormous. In a 50m × 50m building with 360° of heading, you might need millions of particles to have even one near the true pose.

The particle count question: How many particles do you need? A rough rule of thumb: for position tracking, 100-500 particles suffice. For global localization in a small environment, 5,000-50,000. For large environments, adaptive methods like KLD-sampling dynamically adjust the count.
Check: What is particle deprivation?

Chapter 5: Recovery from Failures

Standard MCL cannot recover from kidnapping because of particle deprivation. The fix: random particle injection. At each step, add a small fraction of uniformly random particles to the set.

But how many random particles? Too few and recovery is slow. Too many and the algorithm wastes resources exploring impossible poses. The clever solution monitors the average measurement likelihood of the particle set:

t = (1/M) Σm wt[m]

When w̄t is high, the particles explain the data well — no recovery needed. When w̄t drops sharply, the particles are in the wrong place — inject more random particles proportional to the drop.

The recovery algorithm (Augmented MCL): Replace a fraction of particles with poses sampled from the measurement likelihood p(xt | zt, m) rather than uniformly. This puts new particles where the current measurement says the robot might be, rather than scattering them randomly across the map. Recovery is much faster.

This augmented MCL can solve the kidnapped robot problem: when the robot is moved, the average weight drops, random particles are injected near the true pose (guided by the measurement), and within a few steps the filter converges to the correct location.

Check: How does augmented MCL detect that recovery is needed?

Chapter 6: Proposal Distributions

Standard MCL uses the motion model as its proposal distribution: new particles are sampled from p(xt | ut, xt-1), then weighted by p(zt | xt, m). This is simple but can be inefficient.

The problem: the motion model doesn't know about the current measurement. It might propose particles that are clearly wrong given what the sensor says. Those particles get near-zero weight and are wasted.

Improved proposal: Sample from p(xt | ut, xt-1, zt) — the motion model combined with the measurement. This concentrates particles where they're actually needed.

Dual sampling: A practical trick is to sample a fraction of particles from the motion model (for diversity) and the rest from the measurement-informed proposal (for efficiency). This combines the coverage of motion-based sampling with the accuracy of measurement-guided placement.
ProposalProsCons
Motion model onlySimple, no extra computationWastes particles in low-likelihood regions
Measurement-guidedConcentrates particles where they matterMore complex, may miss surprises
HybridBest of both worldsRequires tuning the mixing ratio
Check: Why is sampling from the motion model alone sometimes wasteful?

Chapter 7: Dynamic Environments

Real environments are dynamic: people walk around, doors open and close, furniture moves. These changes violate the static-world assumption underlying our sensor models.

The effect on localization: a person standing between the robot and a wall produces short range readings. The beam model handles this via pshort, but the likelihood field model does not — the person's legs look like walls in positions where no wall exists.

Filtering strategy: Preprocess the sensor data to remove readings caused by dynamic objects. For each beam:

1. Compare the measured range to the expected range (from the map).

2. If the measured range is much shorter than expected, the beam likely hit a dynamic object — discard it.

3. Only use beams whose ranges are consistent with the static map.

Why this works: Dynamic objects almost always produce shorter-than-expected readings (they're between the robot and the wall). Readings consistent with the map are overwhelmingly caused by static structure. By filtering out short readings, we remove most dynamic effects without losing the information from walls.

An alternative: include dynamic objects in the state vector. But this turns localization into a tracking problem with potentially hundreds of moving objects — far too expensive for real-time operation.

Check: How can sensor data be filtered to handle dynamic environments?

Chapter 8: MCL Demo

Watch Monte Carlo Localization solve the global localization problem. Particles start spread uniformly across a 1D hallway with 3 doors. As the robot senses and moves, particles converge to the true position.

Monte Carlo Localization: Global Localization

Particles (orange dots) start uniform. Sensing a door assigns higher weights to particles near doors. Resampling eliminates bad particles. Click Step to advance.

Ready. Particles spread uniformly.
What to notice: After the first "Sense" step, particles cluster near the three doors (multi-modal). After "Move + Sense," particles at the wrong doors lose weight and vanish. After 2-3 cycles, almost all particles are near the true position — global localization solved.
Check: Why do particles at wrong locations disappear during MCL?

Chapter 9: Summary

AlgorithmPosition TrackingGlobal LocalizationKidnapped RobotDynamic Env.
EKF (Ch 7)YesNoNoNo
GridYesYesLimitedLimited
MCLYesYesWith augmentationWith filtering

Key lessons from this chapter:

• Grid localization is the discrete Bayes filter on a pose grid. Resolution matters — too fine is slow, too coarse is inaccurate.

• MCL uses particle filters. It is the dominant localization algorithm in practice.

• Standard MCL suffers from particle deprivation. Augmented MCL with random particle injection solves the kidnapped robot problem.

• Dynamic environments require sensor data filtering to remove transient objects.

What comes next: With localization solved, we turn to mapping. Chapter 9 introduces occupancy grid mapping — building maps from sensor data when the robot's poses are known. Chapters 10-14 tackle the full SLAM problem: building maps and localizing simultaneously.
"A cloud of particles, drifting through possible worlds,
each weighed by how well it explains what the robot sees.
The ones that survive are the ones that got it right."
Check: What is the most widely used probabilistic localization algorithm in fielded robotic systems?