Robot Colocation
Localizing a robot in a grid from noisy sensor readings with a hidden Markov model — filtering, forward-backward smoothing, and Viterbi decoding.
╌╌╌╌
Localization asks where a robot is, given only a stream of noisy sensor readings and a map. A hidden Markov model fits the setting: the hidden state is the robot's cell in the maze, transitions encode how it moves between adjacent cells, and each cell emits a sensor reading — a color, here — corrupted by a known error rate. From a sequence of readings the model recovers a probability distribution over the robot's position, a belief that spreads across the grid and then tightens as evidence arrives.
The HMM factors the problem into a transition model and a sensor model, and the map fixes both:
- Transition model . From cell the robot steps to an adjacent cell; walls and the grid boundary zero out the illegal moves, and the legal neighbors split the remaining probability. Applied to a belief, this model diffuses mass outward — uncertainty grows with every step taken blind.
- Sensor model . Each cell carries a color. A reading equals the cell's true color with probability and, with the leftover , reports one of the other colors. Applied to a belief, this model sharpens it — mass is pulled toward cells whose color matches the reading.
Filtering tracks a belief , the probability the robot sits in cell at time given the readings . It updates in two steps: predict through the motion model, then weight by the new reading's emission probability,
renormalized to sum to one. The two models pull in opposite directions each step: the sum over is the predict step, diffusing the previous belief through the transition model, and the leading is the update step, sharpening it against the new reading. Evidence compounds. A cell keeps its mass only while it stays consistent with every emission seen, so a belief that starts near-uniform collapses toward a few cells, or one, as readings accumulate. Where the map repeats a color pattern the belief can stay multimodal — split across the matching regions — until a distinguishing reading breaks the tie.
- 1input: readings , motion model , sensor model
- 2for each cell do prior belief
- 3for to do
- 4for each cell do
- 5
- 6normalize so that
- 7return
Filtering conditions only on past readings. The forward-backward algorithm adds a backward pass carrying the influence of future readings, then multiplies the two, , to refine every past estimate with the full sequence. When the goal is the single most likely trajectory rather than per-step marginals, the Viterbi algorithm replaces the sums with maxima and reads the best path off back-pointers.
References
- Project repository
- Reference notes: Probabilistic Reasoning over Time
- Reference notes: Reasoning over Time: Tracking and Data Association
╌╌ END ╌╌