Summary of Kalman Filter for Beginners, Part 1 - Recursive Filters & MATLAB Examples
Summary of "Kalman Filter for Beginners, Part 1 - Recursive Filters & MATLAB Examples"
This video introduces the foundational concepts behind Recursive Filters, leading up to the Kalman Filter, with practical MATLAB demonstrations. The main focus is on understanding how to efficiently compute averages and smooth noisy sensor data in real time, which is critical for applications with limited computational resources such as drones, spacecraft, or embedded systems.
Main Ideas and Concepts
-
Recursive Filters and Recursive Average:
- Batch average: The straightforward average of K data points is computed by summing all data points and dividing by K. This is computationally expensive for large K because it requires reprocessing all data points each time a new measurement arrives.
- Recursive average: A more efficient method that updates the average using only the previous average and the new data point:
\(\bar{X}_k = \frac{k-1}{k} \bar{X}_{k-1} + \frac{1}{k} X_k\)
This avoids summing all data points repeatedly and is suitable for real-time, low-power devices. - Alpha notation: Defining \(\alpha = \frac{k-1}{k} = 1 - \frac{1}{k}\), the recursive average can be written as:
\(\bar{X}_k = \alpha \bar{X}_{k-1} + (1-\alpha) X_k\)
Here, \(\alpha\) depends on the number of data points.
-
Practical Example of Recursive Average:
- Using sample data points (10, 20, 30), the recursive average converges to the batch average.
- MATLAB code demonstrates the recursive average filter using persistent variables to store state between function calls.
-
Handling Noisy Measurements:
- Example: Voltage measurement with noise uniformly distributed between -4 and +4 volts around a true value of 14.4 volts.
- Recursive averaging smooths noisy measurements and converges to the true value over time.
-
Moving Average Filter:
- Unlike the recursive average, the moving average computes the average over the last n data points (a sliding window).
- Recursive form of moving average:
\(\bar{X}_k = \bar{X}_{k-1} + \frac{X_k - X_{k-n}}{n}\) - This reduces computational cost compared to batch averaging.
- Applied to noisy altitude data from sonar, moving average smooths data but introduces a delay that grows with window size n.
-
Limitations of Moving Average:
- Equal weighting of all points in the window causes lag in response to changes.
- This is problematic for dynamic signals (e.g., aircraft altitude) where recent data should be weighted more heavily.
-
First-Order Low-Pass Filter:
- Improves on moving average by weighting recent data more heavily.
- Expressed as:
\(\bar{X}_k = \alpha \bar{X}_{k-1} + (1-\alpha) X_k\) - Here, \(\alpha\) is a free parameter (between 0 and 1), not tied to the number of data points.
- This filter exponentially weights past data, giving more importance to recent measurements.
- MATLAB demos show how different \(\alpha\) values affect smoothing and lag.
-
Introduction to the Kalman Filter:
- Described as a dynamic Low-Pass Filter where \(\alpha\) changes at each step based on system and measurement noise.
- It provides an optimal estimate of the true state from noisy measurements.
- The Kalman Filter includes two main steps:
- Prediction: Estimate the next state based on a model.
- Estimation (Update): Incorporate the new measurement to refine the estimate.
- Key variables:
- \(Z_k\): Measurement at time \(k\).
- \(\hat{X}_k\): Estimate of the state at time \(k\).
- \(P_k\): Error covariance matrix representing uncertainty.
- \(A, H, Q, R\): Matrices related to system dynamics, measurement mapping, and noise characteristics.
- Emphasizes that practical application does not require deep theoretical knowledge; the Kalman Filter can be used as a "black box" tool.
-
Applications and Tuning:
- Kalman filters are widely used in Aerospace, robotics, and Sensor Fusion.
- Proper tuning of noise covariance matrices \(Q\) and \(R\) is essential for good performance.
- Example sensors may provide error specs to guide tuning.
Methodologies and Instructions
- Recursive Average Filter Algorithm:
- Initialize \(\bar{X}_0\) as the first data point or zero.
- For each new data point \(X_k\), update the average using the recursive formula.
- Use persistent variables in MATLAB to maintain state between function calls.
Category
Educational