Test a policy with imperfect sensors
Replace a perfect measurement with noise, bias, delay, and missing samples.
Opening the Python editor…
Requirements and learning goals
Before you start
- Python 3
- An observation contract with units and timestamps
You will be able to
- Distinguish random noise from systematic error
- Test stale and missing observations without confusing them with zero
The browser exercise above works without extra setup. The project brief below assumes the listed prerequisites and gives you a task and checks to perform. Need a guided first project?
Why clean data can teach the wrong behavior
A simulator can supply an exact distance at perfectly regular intervals. A real sensor may fluctuate, report a consistent offset, drift as it warms up, or miss a reading. Cameras add motion blur, exposure changes, occlusion, and imperfect calibration. Transport adds delay and jitter.
A trained only on pristine inputs can rely on precision or timing that hardware cannot supply. Random noise is only one part of that gap: averaging may reduce fluctuations, but it does not remove a fixed calibration error or make an old frame current.
In the Go2/G1 sensor workflow, pause a sensor and check how your app handles stale observations. Then compare simulated readings with recorded hardware data before choosing fault ranges.
Inject repeatable faults
This is a synthetic distance sensor, not a robot driver. Save it as sensor_faults.py and run python3 sensor_faults.py:
import random
rng = random.Random(7)
truth_m = 1.0
bias_m = 0.05
for step in range(8):
capture_s = step * 0.1
arrival_s = capture_s + (0.3 if step == 5 else 0.02)
value = None if step == 3 else truth_m + bias_m + rng.gauss(0, 0.01)
age_s = arrival_s - capture_s
usable = value is not None and age_s < 0.15
print(step, value, round(age_s, 2), usable)Expect readings near 1.05 m despite a true distance of 1 m. Step 3 is missing; step 5 is late. Both are unusable. These numbers illustrate faults; they are not measured specifications for any sensor.
Test your response
Feed the samples into your observation adapter. Missing must not become zero distance. Late samples must not gain a new capture timestamp. Repeated runs should produce the same results because the random seed is fixed.
Optional extension: introduce faults separately, then combine them. Measure task success and stop behavior, not just average prediction error. Choose realistic ranges from hardware logs; independent Gaussian noise cannot reproduce every real failure.
Related lesson: sim-to-real checks. The sensor dashboard walkthrough explains pausing sensors and checking freshness.
Before you move on
Can you do each of these?
- Distinguish random noise from systematic error
- Test stale and missing observations without confusing them with zero
0 of 2 checkpoints solved. Try checkpoint 1