Click & Whirr needs a wider screen
Open it on a laptop or desktop (1280px or wider recommended). The Learn · Code · Watch workspace needs the room to breathe.
Lesson 13
The kidnapped robot
Checkpoints · 0 of 2 (waiting for Run)
- Lock on: pull your belief onto the truth (waiting for Run)
- Hold it: stay locked without chasing the noise (waiting for Run)
Dead reckoning that starts wrong
Someone picked your robot up and set it down somewhere else. Teach it to find itself again from a landmark.
Its Odometry from lesson 5 is still running the prediction, counting wheel moves and adding them up, and here the wheels do not slip, so that dead reckoning is exact. The trouble is where it started counting from. It was told the old spot, so its whole belief is shifted by that same offset, about 70 px, and it holds that offset forever. Exact arithmetic on a wrong anchor stays wrong. It cannot notice on its own, because nothing it reads ever mentions the anchor.
What can mention it is a landmark. The diamond on the map sits at a spot you know, and every tick it sends a noisy range and bearing: how far off it is, and at what angle from your heading. From those two numbers and the beacon’s known position you can work out where the fix implies you are, then nudge your belief a fraction of the way toward it. That nudge is the measurement update, the move at the heart of every real localizer, and it is the last thing this course has to teach.
Predict, then pull toward the fix
Hold it without chasing noise
▸API reference
- Localizer(x, y, theta, gain=0.4)
- Built on Run with the pose your robot BELIEVES it starts at (which is wrong today). The gain is a default in the signature, not a slider: edit it in the code and press Run to retune. Your L5 Odometry does the prediction; the banner offers the reference if you haven't built it.
- update(v_left, v_right, beacon_range, beacon_bearing, dt)
- Called every tick with the commanded wheel speeds and the beacon fix: range in px, bearing in radians relative to your heading (+ = beacon to your left). Return your (x, y, theta) belief.
- robot.sensors.beacon()
- The same fix via the facade: returns (range, bearing).
- how you're graded
- Your belief is compared against the hidden true pose. Checkpoint 1 (locked on) needs the belief pulled onto the truth; checkpoint 2 (steady) needs it to STAY there. Never correcting leaves the full offset (fails 1); trusting the noisy beacon too hard jitters (fails 2).
space pause · r reset · ctrl/cmd+enter run
Simulator
This lesson imports Odometry from your library. You haven’t built Odometry yet.