Keep more than one possible robot position
Two places in a corridor can produce the same distance reading. Compare the possible positions to see what a sensor tells the robot, and what remains unknown.
Match a measurement to a map
Change the sensor and watch the possible positions.
Localization corridor
The 3D workspace loads when it comes into view.
Possible cells: 2, 6
More controls
The nine-cell corridor has candidate positions 2, 6 for the 2.5-cell reading. Orange rings are hypotheses, not extra robots. The actual robot is only shown when you enable its marker.
2D reference and fallback
Nearest-wall reading: 2.5 cells, exact in this model. 2 possible positions: 2, 6. Orange cells match the measurement.
Optional reasoning check
Opening the Python editor…
Requirements and learning goals
Before you start
- The route-planning lesson
- A browser with JavaScript enabled
You will be able to
- Separate actual position from an estimated position
- Identify symmetric positions that fit the same range reading
- Explain why measurement tolerance can preserve uncertainty
A route planner needs a start position, but a physical robot does not receive that position simply because a map exists. Localization means estimating where the robot is by comparing observations with what the map predicts.
For this lesson we use a separate, simpler map: a straight corridor containing nine cells, numbered 0 through 8. This is not the 11-column room from the previous lessons. Each cell center is halfway across its cell; the corridor walls lie at the outer edges of cells 0 and 8. At cell 0, the distance to the left wall is 0.5 cells; at cell 2 it is 2.5 cells.
The simulated sensor can report either the distance to the nearest wall without naming which wall, or the distance specifically to the left wall. The experiment displays every cell whose predicted reading matches. It does not assign probabilities or silently choose one answer. Allow about 10 minutes.
Try it
The Sensor selector is beside the corridor. Open More controls to change the actual position, measurement error, or actual-position marker.
- Reset. The simulated robot is at cell 2 and the sensor reports distance to the nearest wall. Read the measurement and orange candidate cells.
- Before changing the sensor, predict another cell that would give the same reading. Try the other position to test your prediction.
- Select Cell 6 under the robot placement control. Notice that the nearest-wall reading and candidate set stay unchanged.
- Restore cell 2, then select Left wall. Compare the candidate set.
- Enable Allow ±1 cell error. Explain why a directional measurement now permits several adjacent positions.
The placement control represents the experimenter's knowledge. The matcher receives only the range, the map, direction information, and tolerance. The optional green actual-position marker is for checking the result; it is not an input to .
Work through the ambiguity
At cell 2, the left wall is 2.5 cells away and the right wall is 6.5 cells away. The nearest-wall sensor reports 2.5. At cell 6 those distances are reversed, so the same sensor also reports 2.5. Both positions fit the observation.
A sensor that specifically measures the left wall resolves this symmetry: only cell 2 has an exact left-wall distance of 2.5 cells. But measurement error matters. With an allowed error of one cell, left-wall predictions from 1.5 through 3.5 cells all fit. Cells 1, 2, and 3 remain candidates.
This example does not claim that one precise reading solves general robot localization. A real robot also needs orientation, map alignment, sensor geometry, and a way to handle noisy or inconsistent observations over time.
Check the expected results
At reset, expect a nearest-wall reading of 2.5 cells and candidates 2 and 6. Showing the actual-position marker identifies cell 2 for inspection without changing those candidates.
With the left-wall sensor and exact matching, expect only candidate 2. With left-wall sensing and ±1 cell tolerance, expect candidates 1, 2, and 3. With nearest-wall sensing and that tolerance, expect six candidates: 1, 2, 3, 5, 6, and 7.
Try the center
Select actual cell 4 and turn tolerance off. Its nearest-wall reading is 4.5 cells, and only cell 4 matches. Explain why the mirrored positions collapse into one at the corridor center. Then restore cell 2 and explain why reporting a single confident estimate would hide information the sensor did not provide.
You are done when you can distinguish actual position from candidate positions and explain both symmetry and measurement tolerance.
Troubleshooting
If you see more candidates than expected, check the tolerance checkbox. If the reading changes after moving between cells 2 and 6, check whether the sensor is directional. The range is measured from cell centers to corridor walls, so the half-cell offsets are intentional.
The replanning lesson returns to the room map. It assumes the current position is known exactly so you can isolate the effect of a changed obstacle map.
Before you move on
Can you do each of these?
- Separate actual position from an estimated position
- Identify symmetric positions that fit the same range reading
- Explain why measurement tolerance can preserve uncertainty
0 of 2 checkpoints solved. Try checkpoint 1