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 11
Trust, but verify
Checkpoints · 0 of 2 (waiting for Run)
- Smooth the noise: running error well below the raw signal (waiting for Run)
- Keep tracking: don't lag behind the real signal (waiting for Run)
One sensor, all jitter
Your robot’s senses are noisy. Teach it to not believe every twitch.
Point a real sensor at a steady world and the number it returns is not steady: it jitters around the truth, a fresh error every tick. You cannot stop that. What saves you is that noise and signal behave differently. The noise is new every tick and points anywhere; the signal is patient and keeps pointing the same way. Average in a little history and the noise cancels itself while the signal stays.
The driving is not your job this time. Press Run and the bot crawls on its own; the crawl is scenery. Your job is the believer: every tick your SmoothingFilter gets one raw noisy reading and returns what it believes the true signal is. A smooth signal is buried under that noise, and the two gates grade your belief against it.
Blend toward the reading
Beat the noise, keep tracking
▸API reference
- SmoothingFilter(alpha=1.0)
- Built once when you press Run, from the default in your __init__ signature. alpha is your smoothing gain: small trusts your history (calm but laggy), large trusts the newest reading (responsive but jittery). Store your running value on self so it survives from tick to tick.
- update(reading)
- Called every tick with the raw noisy reading. Return your smoothed estimate.
- alpha default (tuned in code)
- Your gain lives in the signature. Edit the default, press Run, and a fresh filter runs with the new value from the first tick; Reset also rebuilds from your source.
- robot.sensors.noisy_scalar()
- The same raw reading via the facade.
- how you're graded
- A smooth signal is buried under the noise. The smoothed checkpoint needs your running error against it to fall well below the raw noise floor; the tracks checkpoint needs your estimate to keep following the signal instead of trailing behind it. Too little smoothing fails the first; too much fails the second.
space pause · r reset