Step 1
Noise and averaging
Every reading of the ball is a little wrong. Measure how wrong, then average the error away.
Sensors lie a little
Until now world.balls() told you exactly where every ball was. Real sensors (cameras, depth sensors, motion capture) don't. In this step every reading comes back with Gaussian noise added to each coordinate:
That's about the size of the grasp tolerance. The gripper only attaches when the ball is within about 1.6 cm of the fingertips' centre, so a program that trusts a single reading misses about one run in three.
Averaging
Each reading is wrong by a different random amount. Take independent readings and average them:
The errors partly cancel, and the spread of the average shrinks like :
| Readings | 1 | 4 | 25 | 100 |
|---|---|---|---|---|
| Error σ | 15 mm | 7.5 mm | 3 mm | 1.5 mm |
Four times the readings halves the error. Diminishing returns, but for a ball that sits still, reading is cheap.
See it
viz.chart(name, kind="scatter") makes a scatter plot, and viz.plot(series, y, x=..., chart=name) adds a point to it. Plot each reading's , then your mean. The cloud should be roughly circular, about 3 cm across, with the mean near its centre. Open the Plots tab after the run.
Your task
- Implement
estimate(samples): it gets an array of readings and returns your best guess of the true position (a 3-vector). The grader tests it on 60 fixed readings. - Average at least 30 readings of the red ball and use the estimate to put it in the cup.
The layout and the noise change on every run, so press Run a few times.