Problems · Problem 9 · Estimation · Medium
Kalman filter
Predict with a motion model, correct with each measurement, and keep track of how uncertain you are.
Builds on Combining two sensors, from the free Foundations.
Write and run this problem in the simulator with ProWhat it computes
A Kalman filter estimates a hidden state (say, position and velocity) from noisy measurements . It keeps a Gaussian belief: the mean and the covariance . It is the exact Bayesian answer when the models are linear and the noise is Gaussian.
Two steps, repeated
Predict with the motion model , where :
Update with a measurement , where :
Prediction grows the uncertainty and each update shrinks it. weighs the two: a precise sensor (small ) pulls the estimate towards the measurement, and a confident belief (small ) keeps it where it was.
The program
A conveyor slides the red ball across the table. The sensor reports its position 10 times a second with σ = 1 cm. The program tracks with a constant-velocity model. It plots the readings against your estimate, and records both in track.
See it in context
Noisy Sensors & Kalman Filters builds this filter step by step, then uses it to catch the ball.
Your task
Implement kf_predict(x, P, F, Q) and kf_update(x, P, z, H, R). Each returns the new (x, P), and each must work for any state size. The grader tests both on random matrices, then checks that on the live conveyor your estimates are much closer to the ball than the raw readings.