Mobile Robot Navigation, step 4
Mapping with an occupancy grid
Drive through a maze you've never seen and build its map from lidar beams, one grid cell at a time.
Builds on Bonus: Probability & Bayes' rule, from the free Foundations.
Write and run this step in the simulator with ProA map that remembers
A scan lasts a moment; to plan a route the rover needs a map that remembers. An occupancy grid splits the floor into 1 cm cells and keeps, for each, how likely it is to be solid.
What one beam says
A beam that stopped after metres says two things: every cell it passed through is free, and the cell it stopped in is occupied. A miss says only the first. One beam can be wrong, so each only nudges its cells.
Log-odds
Each cell stores its belief as log-odds, , where is the probability that the cell is solid. means : unknown. In log-odds, Bayes' rule becomes addition: each beam adds to the cells it crosses and to the one it stopped in, so evidence piles up. Three beams through a cell make , or . Every cell is clamped to so the map can still change its mind, and turns it back into a probability for display. Foundations: Bayes' rule explains why the evidence adds up.
Walking a beam through the grid
Which cells does a beam cross? Sample the segment from the rover to the beam's end every half a cell: with steps, point is . grid.cell(points) gives the (rows, cols) of every point at once. Drop each cell that repeats the one before, and what's left is the beam's cells, in order. Half-cell steps are short enough that each cell touches the next.
Your task
- Write
beam_cells(grid, start, end): the(row, col)cells from the start's cell to the end's cell, in order, each once. - Finish
update(logodds, pose, scan): for each beam, addL_FREEto all its cells but the last, andL_OCCto the last if the beam hit (r < scan.max_range), skipping cells off the grid.
The rover follows a route through a maze you don't have the map of, and the Images tab shows your map filling in. The grader tests both functions, then wants ≥ 95 % of the scored cells right and ≥ 90 % of the scored wall cells occupied. It scores the cells the scans reached, except those beside a wall face, where lidar noise decides which side a hit lands on.