An Intuitive Introduction to Kalman Filtering
Ten modules that go from “what is sensor noise?” to a working error-state Kalman filter. Each module adds one idea, starts from something the previous module got wrong, and has a MATLAB script where you build the idea yourself.
“How much should I trust this new measurement, compared with what I already believe?”
That question runs through the whole course. The answer is always a gain K between 0 and 1, used the same way every time: estimate = prediction + K · (measurement − prediction).
Modules
- 1Signals, noise and sensorsA sensor reading is the truth plus random error, and that error has a describable shape.Open slides
- 2Smoothing without a modelBlend each new measurement with the previous estimate using a fixed gain.not online yet
- 3Adding a motion model with fixed gainsPredict with kinematics, then correct with the measurement.not online yet
- 4Uncertainty and the one-state Kalman filterCarry a variance with every estimate and let the variances set the gain.not built yet
- 5Two states and correlationWhy a position measurement can correct a velocity that is never measured.not built yet
- 6Adding an accelerometerLet the accelerometer drive the prediction and the position sensor correct it.not built yet
- 7The linear Kalman filterName and organize, in matrix form, what you have already built.not built yet
- 8Estimating sensor errorsAnything unknown that affects the system can be made a state.not built yet
- 9The error-state Kalman filter in one dimensionA nominal solution, plus a filter that estimates only its small errors.not built yet
- 10Capstone: a planar vehicle with headingAttitude makes the problem nonlinear, and the error-state form handles it.not built yet
How each module works
1. Slides. Open the module’s slides from the list above. Use the arrow keys or the on-screen buttons to move, and press N for instructor notes.
2. MATLAB. Open the module’s mNN_student.m and press Run. It works as it is. Fill in the TODO blocks one at a time and run again; the Command Window prints PASS or FAIL for each. The finished version is mNN_solution.m. Only base MATLAB is needed, no toolboxes.
3. Scoreboard. Each module ends by adding a bar to a chart of RMS error, so you can see each technique improve on the last.
Color code
Used in every figure, widget and MATLAB plot: blue is the truth, red is a sensor measurement, green is our estimate.
Notation
| Symbol | Meaning | First used |
|---|---|---|
| p, v, a | True position, velocity and acceleration of the sled | Module 1 |
| z | A sensor measurement | Module 1 |
| n | Measurement noise | Module 1 |
| σ, σ² | Standard deviation (“one sigma”) and variance | Module 1 |
| k | Sample index: zk is the reading at sample k | Module 1 |
| x̂ | A hat marks an estimate: p̂ is our estimate of p | Module 2 |
| K | Gain: how much of the measurement’s disagreement we accept, from 0 to 1 | Module 2 |
| x̂− | A minus superscript marks a prediction, before the measurement is used | Module 3 |
| P | Variance (later, covariance matrix) of our estimate | Module 4 |
| R | Variance of the measurement noise | Module 4 |
| Q | Variance of the process noise: how much uncertainty each prediction step adds | Module 4 |