Kalman Filters

Introduction – What are Kalman Filters?

Kalman filtering is a kind of algorithm that is used extensively within guidance, navigation and control. It can for example be used to keep an aircraft on a straight path, balance a drone or be used to refine GPS receiver results. The name is a bit confusing since it is not a filter in the traditional sense, it is more like a kind of algorithm that can be implemented in software on computers or micro controllers. Kalman filters are a great example of an application of probability and statistics. Kalman filters are used a lot within control engineering, and are for example used in airplanes, helicopters and drones to control and stabilize then in the air. They are very important, and there are a wide array of usage areas. How Kalman filters work can be hard to grasp, but this text will try to explain the fundamentals in an easy to understand way. Confusion might also arise because there are several different types of Kalman filters, however, here we will start will the basic one, and explain the different types available.

What can a Kalman filter do?

Lets start with an example to clarify how the Kalman filter can operate, and what it can do. Imagine that you have a model of an electrical engine, it gets a certain voltage, and it gives a certain torque. Also assume that we are going to use this model to control an airplane propeller. Lets assume that we have the equation

T = K V

Where T is the torque, K is a constant and V is the applied voltage. This model is simple enough, and the value K could be determined from for example real life measurements. This seems great. However, what happens if we have measurement error? Lets assume V = V_{real} +\Delta V. We then get

T = K (V_{real} +\Delta V)  = K  V_{real} + K \Delta V  

Hence, if we don’t know V exactly, we will have an error of this form. It is an reasonable assumption to assume that we have we have what is called a drifting error. This means that source of our voltage will drift without us knowing it, growing with time. We can also assume that we have a random error with zero mean, changing rapidly. We also need to think, sure maybe this model would work today, but does it work as time goes on? Will it work one year from now? The answer is probably not. This is an example how non-flexible models fail to work in real life cases. Hence we need some kind of dynamical model which can change on the go.

In the Kalman filter, we assume that we have a model of the form

x_k  = F_k x_{k-1} + B_k u_k + w_k

This might look a bit scary. However can can dissect all of these. The x_k is what we call the state. This is simple the variable that we are trying to monitor, or the output of a system. In this model the current value $x_k$ depends on the previous value of $x_k$. This is a natural assumption which is present in a lot of real-life systems. For example the amount of gas you have left in a tank in the current time slot, is dependent on the previous time slot. The term u_k is a input term. In the example of a gas tank, this means that we can refuel the tank with extra fuel. This input term is not always used, however it is useful for a lot of real world systems. The last term w_k is a noise term, the noise is assumed to be Gaussian. This is an important assumption which will be discussed more later. The state can be known or unknown, however, in general, we assume that we only see a measurement of the state. The measurement is given by

y_k = H_k x_k + v_k

Where v_k is a noise term which is assumed to be Gaussian. So if we just start to think a bit, what can we use this model for? Can it be used for the previous example of an electrical motor? Yes it can, assume that we can measure the torque, then this will be our y_k. However, assume that we measure everything once every second. This means that y_0 is for time equals zero, and y_1 corresponds to the measurement after one second has passed. The value H_k would in our case be the constant K, assumed to not change over a reasonable amount of time. The noise terms are realistic since we will always have some noise when measuring quantities. The noise term w_k can be thought as to model non-idealistic in the electrical engine, whilst v_k can be seen as a simple measurement error. The variable u_k can be seen as an increased applied voltage, it is how much we turn it up. Hence we can now understand this mathematical formulas for y_k, the measurement, and x_k the state, in our case voltage. The equations might look to complex in the beginning, however all components of them are important and enable us to build powerful and useful models.

Further learning about Kalman Filtering

There are many great books about Kalman filtering. Some of them require some fundamental understanding of mathematics and probability. A very concise book which is free for personal use is Bayesian Filtering and Smoothing by Simo Sarkka. Another classic book is Optimal state estimation : Kalman, H ∞ , and nonlinear approaches by Dan Simon, this provides an in depth knowledge about Kalman filters, however it uses a lot of mathematics, so it might be hard for a reader with novice mathematics and probability knowledge.


Optimal state estimation : Kalman, H ∞ , and nonlinear approaches by Dan Simon. Wiley 2006.