Localisation & SLAM, step 2
Localising in a corridor
Split a corridor into cells and keep a probability for each: predict with every move, correct with every reading, until one cell wins.
Builds on Bonus: Probability & Bayes' rule, from the free Foundations.
Write and run this step in the simulator with ProA belief over cells
The rover is somewhere in a 1.16 m corridor, and it doesn't know where. Cut the corridor into cells of 5 cm. The belief is the probability that the rover is in cell ; it starts flat, .
What the rangefinders say
Two rangefinders look sideways. Shelves stick 2 cm out of both walls, so a beam reads about 4 cm at a shelf and 6 cm at bare wall, with cm of noise. EXPECTED[j] holds the ranges (right, left) you'd read in cell : that's the map. The likelihood of cell is how well it explains a reading :
Update: Bayes' rule
Cells that explain the reading gain probability and the others lose it. One noisy reading fits many cells, so the belief has many peaks at first. Foundations: Bayes' rule derives this.
Predict: the rover moved
After each 5 cm drive the rover is probably one cell on, but the wheels aren't exact: KERNEL holds the probabilities that it really moved 0, 1 or 2 cells.
The far wall stops the rover, so probability that would pass cell stays there. Predicting blurs the belief; updating sharpens it. Only the true cell keeps explaining reading after reading.
The program
The rover starts somewhere random, reads, then drives 14 cells, predicting and updating after each. The belief floats over the corridor and appears in the Images tab; the Plots tab shows the readings.
Your task
Write likelihood(z), update(belief, like) and predict(belief). Each returns an (N,) array. The grader checks them on fixed cases, then checks that your final belief peaks within one cell of the rover.