Noisy Sensors & Kalman Filters, step 3
Tracking a moving ball
The ball is on a conveyor now. Predict where it went, correct with each reading: the full Kalman filter.
Builds on Combining two sensors, from the free Foundations.
Write and run this step in the simulator with ProEstimating what you can't measure
A conveyor now slides the red ball towards the robot at a few cm/s. The sensor (σ = 1 cm, 10 readings per second) only reports position, but to catch the ball you'll need its velocity too. So estimate both, as one state:
Predict, then update
Between readings, the ball keeps moving. A motion model says how the state evolves over ; for constant velocity, :
Prediction moves the belief and grows it. , the process noise, says how much you distrust "constant velocity". Here lets the velocity wander by about per step.
Then update with the reading. The sensor sees only , the position, with . That's Step 2's update, generalised:
The magic is in 's off-diagonal terms: prediction couples position and velocity, so every position reading also corrects the velocity.
Tuning Q
A conveyor is very steady, so trust the model: works well. A big makes the filter chase every noisy reading; watch the estimated line in the Plots tab get jumpy.
Your task
- Fill in
cv_model(dt)(F and Q) andkf_predict(x, P, F, Q), which returns(x, P). - Implement
track(zs, dt): readings in, states out (one per reading). The grader runs it on a fixed 60-reading track and wants the position error to be under half that of the raw readings. - Track the live ball with
sensor.next("red")for 3 s, then store its velocity (m/s) invelocity_estimate.