Final project for the Probabilistic models for decision making course, from my MSc in Computer Science: an interactive and real time 2D simulation of the Kalman Filter in use to reduce input noise.
The Kalman Filter is an algorithm that uses a series of measurements observed over time, containing statistical noise and other inaccuracies, and produces estimates of unknown variables that tend to be more accurate than those based on a single measurement alone, by estimating a joint probability distribution over the variables for each timeframe. The algorithm works in a two-step process. In the prediction step, the Kalman filter produces estimates of the current state variables, along with their uncertainties. Once the outcome of the next measurement (necessarily corrupted with some amount of error, including random noise) is observed, these estimates are updated using a weighted average, with more weight being given to estimates with higher certainty. The algorithm is recursive. It can run in real time, using only the present input measurements and the previously calculated state and its uncertainty matrix; no additional past information is required.
Algorithm pseudocode:
m = [X, Y, deltaX, deltaY] ← measurement vector
c = [0, 0, 0, 0] ← control vector (not used here)
Prediction Step:
x = (A * x) + (B * c)
P = (A * P * AT) + Q ← AT is the matrix transpose of A
Correction Step:
S = (H * P * HT) + R ← HT is the matrix transpose of H
K = P * HT * S-1 ← S-1 is the matrix inverse of S
y = m - (H * x)
x = x + (K * y)
P = (I - (K * H)) * P ← I is the Identity matrix
If prediction is enabled, the prediction step is looped for n
more frames after the above code is executed:
predX = x
predX = (A * predX) + (B * c)
The estimated position of the cursor is in the x vector:
x ← [xPos, yPos, xVel, yVel]
git clone
npm install
npm run serve
Publish on avivace.github.io/kalman
:
npm run deploy
Development is done on the
develop
branch due to GitHub's restriction on branches for user pages (the build is deployed on themaster
branch and published toavivace.github.io/kalman
from there).
- Vue.js JS framework;
- MuseUI CSS framework;
- Sylvester Vector and matrix math;
- CanvasRenderingContext2D web API to draw the simulation.
- An introduction to the Kalman Filter
- Implementation of Kalman Filter with Python Language
- Understanding the Basis of the Kalman Filter via a Simple and Intuitive Derivation
- Kalman Filter Simulation
- Kalman Filtering - Drew Bagnell
- Applications of Kalman Filtering in Aerospace 1960 to the Present - MOHINDER S. GREWAL and ANGUS P. ANDREWS
- Discriminative Training of Kalman Filters - Pieter Abbeel, Adam Coates, Michael Montemerlo, Andrew Y. Ng and Sebastian Thrun
- Relative Study of Measurement Noise Covariance R and Process Noise Covariance Q of the Kalman Filter in Estimation. - Yashpal Singh, Rajesh Mehra
- Stochastic Filtering - Rui Castro
- Apollo Guidance System software:Virtual AGC — AGS — LVDC — Gemini
Manuele Rota for cleaning up some of my trash code and improving the animation logic