The Kalman Filter: Continuous State Tracking
Unlike Hidden Markov Models (HMMs) and Dynamic Bayesian Networks (DBNs) which often deal with discrete probability states (e.g., "Raining" vs "Not Raining"), a Linear Dynamical System using a Kalman Filter tracks continuous variables (e.g., position, velocity, temperature).
The Kalman Filter represents uncertainty using Gaussian (normal) distributions, defined by a mean (the most likely estimate,
The filter operates in a continuous two-step loop:
1. The Predict Step (Time Update)
The filter uses the laws of physics or a known mathematical model to guess where the system will be next. Because no model is perfect, this step injects Process Noise (
-
Predicted State:
-
Predicted Uncertainty:
2. The Update Step (Measurement Update)
The system takes a reading from a sensor. Sensors are inherently flawed, so this measurement has its own Measurement Noise (
-
Kalman Gain:
-
New State Estimate:
-
New Uncertainty:
Note on Tuning: As mentioned in the lecture notes, if
A 1D Numerical Example
Imagine a robot moving in a straight line. We want to track its position along an x-axis.
-
It starts at position 0, moving at 1 meter per second.
-
Initial Estimate (
): 0 -
Initial Uncertainty (
): 1.0 (We are somewhat unsure exactly where the center of the robot is) -
Process Noise (
): 0.1 (We trust our motors and physics model quite a bit) -
Measurement Noise (
): 0.5 (Our GPS/sensor is somewhat noisy)
Time Step 1 (
Step 1: Predict
The robot was at 0 and moves at 1 m/s, so we predict it is now at 1.0. We add the process noise to our uncertainty.
Step 2: Measure
The robot's GPS sensor takes a reading. Let's say it reads a slightly inaccurate value of 1.2.
Step 3: Update (Calculate Kalman Gain)
We calculate
-
(Because
is closer to 1, it means we are leaning slightly more toward trusting the measurement than our prediction, since our prediction uncertainty 1.1 is higher than the sensor noise 0.5).
Step 4: Update (Final State and Uncertainty)
Now we calculate the final, optimized position estimate and update our confidence.
-
New Position (
): -
New Uncertainty (
):
The Result: The filter cleverly blended the prediction (1.0) and the sensor reading (1.2) to arrive at 1.1375. Crucially, as highlighted in the lecture snippet, observe how the uncertainty
1. The Intuition: Overlapping Certainty
The lecture begins by visually explaining why the Kalman Filter works using Probability Density Functions (Gaussian curves).
-
A system starts with an initial state estimate that has a specific variance (uncertainty).
-
When the system predicts its next state through movement, the variance widens, meaning uncertainty increases.
-
A sensor provides a measurement, which has its own independent curve and variance.
-
The Magic: By multiplying these two probability curves together, the filter produces an "Optimal state estimate". Crucially, the resulting curve is narrower and taller than both the prediction and the measurement curves, proving that combining two uncertain sources results in a higher overall certainty.
2. The Scalar Kalman Filter & The Gain ( )
The presentation mathematically dissects the 1D (scalar) version of the filter to explain the behavior of the Kalman Gain (
The formula for the gain is defined as the ratio of the Estimate Error (
This creates two important extreme bounds for how the filter behaves:
-
Trusting the Sensor (
): If the measurement error is effectively zero ( ), the sensors are perfectly accurate. The gain becomes 1, and the filter updates its current state to match the measurement exactly ( ). -
Trusting the Prediction (
): If the measurement error is incredibly high (sensors are inaccurate), the denominator approaches infinity, driving the gain toward 0. The filter ignores the faulty sensor data and relies entirely on its previous prediction ( ).
3. The Matrix Kalman Filter
Real-world robotics rarely operate in 1D. A robot needs to track position and velocity across X and Y axes simultaneously. To do this, the scalar equations are upgraded to matrices.
The Prediction Step:
-
State (
): . The state matrix ( ) is updated by multiplying the previous state by the transition matrix ( ), adding any control inputs ( ) modified by the control matrix ( ), and accounting for process noise ( ). -
Uncertainty (
): . The covariance matrix ( ) is projected forward using and its transpose , while adding the process noise covariance ( ).
The Update Step:
-
Kalman Gain (
): . This uses the observation matrix ( ) to map the state space to the measurement space, factoring in sensor noise ( ). -
Final State (
): . The filter calculates the residual (the difference between the actual measurement and the predicted measurement ) and scales it by to correct the state. -
Final Uncertainty (
): . The uncertainty is reduced based on how much new information was gained.
4. Designing a Filter using Kinematics
The lecture concludes by showing how to build the
If you are tracking 1D distance and velocity, the state matrix is
-
The Transition Matrix (
): Models how position and velocity naturally evolve over a time step ( ). -
The Control Matrix (
): Models how external acceleration ( ) impacts both position and velocity.
By plugging these physically derived matrices into the Kalman equations, the algorithm can accurately track a moving object over time.