Introduction to Kalman Filters

This article is a WIP - expect lots of changes in future

This will serve as a brief Introduction to the Kalman filter course. The aim of this course is Kalman filters in practice, and there are a few points I want to make in advance to prepare a reader.

Summary

I will not be covering Kalman filter "basics" like the motivations behind a Kalman filter, what it is, how it works and so on. There are a large number of materials available which cover this. I recommend Roger Labbe's Kalman-and-Bayesian-Filters-in-Python book, which is freely available online. Another fantastic resource is Fundamnetals of Kalman Filtering: A Practical Approach by Paul Zarchan and Howard Musoff.

So, instead of covering these basics, I'll be looking at just the practice of actually programming Kalman filters. The number one largest issue with Kalman filter literature by far is that there is usually not enough information given to actually reproduce the filter, nor is there any regard given to how one would program the theoretical filter desgined. When simulations are run, they are often meaningless. For instance, take a look at the following figures from Improving GPS Positioning Accuracy Using Weighted Kalman Filter and Variance Estimation Methods by Sh. Shokri, N. Rahemi and M. R. Mosavi, published in CEAS Aeronautical Journal in 2019. Keep in mind this is a peer reviewed article.

Errr... what? This is no simulation, no result. It's just a line on a plot. This doesn't tell us anything at all. Here's an example of one of the simulations we will be making in our course.

I consider this to be a kind of bare minimum - a true value, noisy measurements, and then the filter results. This shows you instantly how the filter is doing on real data that you might get (actually, the noise on these measurements is huge). Many poor filters could have been squashed quickly if this kind of simple simulation and plot was made.

Another thing I want to note is the code in this course will be in Rust. This is because I like Rust. Most Kalman filter books are either written in Matlab or Fortran. Matlab is obviously unacceptable since it is a closed source and proprietary language that requires a license to run. This alienates those who don't want to spend thousands per year on the most bottom tier language ever made. Fortran is totally fine, but most Kalman filtering code written in Fortran is almost impossible to understand unless you know what's going on already. This is just a little counterproductive since the code is often a good way to understand exactly what is going on.

My programming style for this course is going to be aimed at clarity. I will code in such a way that it makes everything very obvious what is going on, at the expense of performance. A lot of Kalman filtering code is highly optimised (which, is not a bad thing at all! It is usually intended to be run several times a second on embedded hardware with very little resources), but this makes it hard for a beginner. This course won't be about optimising Kalman filter performance on embedded hardware. For instance, I will be using the Peroxide crate for linear algebra, which is very easy to use and makes the matrix operations very clear. On the other hand, you probably don't want to use it in production since it makes use of Vec under the hood, leading to all sorts of runtime overheads. This could be avoided by using something like ndarray in production. In other words, the goal of this course is education, not production.

Now, I just want to quickly go over my notation for the course. Every single person invents their own notation when they write a Kalman filter book, and I intend to fully break with this tradition. I will be using the same notation as Zarchan.

Without further ado, let's get onto our first simulation - tracking a falling object.