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
Someone picked your robot up and put it down somewhere else, but its odometry was told the oldstarting spot. That’s the classic kidnapped robot problem: dead reckoning is exact here, so the belief stays wrong by the same 70 px forever. It can’t notice. What can? A landmark: the diamond on the map sits at a known spot and sends you a noisy range and bearing. Every tick, work out where that fix implies you are, and nudge your belief a fraction gain toward it. That nudge is the measurement update, the heart of every real localizer.
Checkpoints
- Lock on: pull your belief onto the truth (waiting for Run)
- Hold it: stay locked without chasing the noise (waiting for Run)
Press Run ▸ to start checking your code.
Write the correction, press Run, then tune gain. At the top of the slider you trust every noisy fix almost fully and your belief jitters with the noise; too low and the pull-in crawls. Ease it down until the belief snaps on and stays put.
Steps
- 1
Predict with your Odometry
The starter already runs your L5 piece:
self.odo.update(v_left, v_right, dt). If the import banner is up, adopt the reference Odometry first. - 2
Pull toward the beacon fix
- 3
Lock on to the truth
▸API reference
- Localizer(x, y, theta, gain)
- Built on Run with the pose your robot BELIEVES it starts at (which is wrong today) plus the trust slider. 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
Simulator
This lesson imports Odometry from your library. You haven’t built Odometry yet.