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 05
Dead reckoning
Checkpoints · 0 of 3 (waiting for Run)
- YOUR odometry tracks the ghost through the clean stretch (waiting for Run)
- The slip begins: the estimate peels away (waiting for Run)
- Let the lie grow past 80px (waiting for Run)
Guessing position from wheels
Your robot can drive anywhere by now, but it has no idea where it is. Teach it to keep a running guess, then watch that guess start to lie.
There is no GPS in this arena. The only thing the robot knows is what its own wheels were told to do, so it guesses: every tick it takes the commanded wheel speeds, works out the little move they imply, and adds it onto where it thought it was. Sailors called this dead reckoning. Roboticists call it odometry, and the running total is the robot’s belief.
The driving is not your job this time. Press Run and the sim steers a gentle, fixed loop on its own, the same loop every run. Your job is the guesser: the Odometry class in the editor. The solid bot is the truth; the hollow ghost is the engine’s own belief, computed from the same commands your class receives. Match it and you have written real odometry.
Integrate heading, then position
Stay glued to the ghost
Watch the estimate peel
Let the lie grow
▸API reference
- Odometry(x, y, theta)
- Built at the start pose when you press Run, and rebuilt on Reset. Store the pose on self: it must survive from tick to tick.
- update(v_left, v_right, dt)
- Called every tick with the commanded wheel speeds (the scripted drive's numbers, in wheel command units) and dt = 1/60 s. Return your (x, y, theta) estimate.
- WHEELBASE = 55 · SPEED_SCALE = 1.6
- The engine's geometry: commands scale by 1.6 to px/s, and the turn rate is the wheel-speed difference over the 55 px wheelbase.
- the fixed scenario
- The bot drives a scripted loop on its own. The wheels grip perfectly for the first 8 seconds, then a fixed, calibrated slip starts on the right wheel and the encoders never see it. Every run is identical; there is nothing to set.
- how you're graded
- The hollow ghost stays the ENGINE's own dead reckoning. The first checkpoint checks your class AGREES with it (within 8 px) on the clean stretch. The last two watch the belief peel away from the truth once the slip begins.
space pause · r reset · ctrl/cmd+enter run