The Extended Kalman Filter: An Interactive Tutorial

In working with autopilot systems like OpenPilot and Pixhawk I have frequently come across references to something called an Extended Kalman Filter (EKF). Googling this term led me to several different web pages and reference papers, most of which I found too difficult to follow. So I decided to create my own tutorial for teaching and learning about the EKF from first principles. This tutorial assumes only high-school-level math and introduces concepts from more advanced areas like linear algebra as needed, rather than assuming you already know them.

The tutorial is currently about 2/3 complete.  I still need to introduce linear algebra concepts for sensor fusion, and then nonlinearity for the EKF.  But in the open-source spirit of "release early, release often", I'm posting this now, in the hope that people will try it out and provide comments.

• Simon,

I know you assembled this tutorial some time ago, but I just discovered it today, and thoroughly enjoyed the limited time I had clicking through it.  I look forward to having more time to benefit from it, and thank you for bringing the fine work of brilliant math minds down to my level and in the context of RC modeling.

Kelly

• Okay, the sensor-fusion material is finally ready -- comments welcome!  I also implemented it in Matlab. I started to implement it in Python, too, but found that it was too much of a hassle to deal with all the library calls (numpy, matplotlib) and numpy matrix weirdness. The Matlab implementation works fine in Octave, if you don't have a Matlab license.

• I am sure it will be much more clear for me after sensor fusion example:) Thanks again for the great work!
• You make some good points here!  Keep in mind that I've used the scalar constant 0.75 as a way of simplifying the the state-transition matrix to a single value, because I don't assume a knowledge of linear algebra.  A more realistic example like the one in Slides 11-12 shows how the A can be used to model state-transitions in a less trivial way.

• Thanks! Actually I was referring to that footnote in my question. It seems that the green Kalman Signal is generated by multiplying the first noisy signal value by 0.75 again and again. So I could not understand the effect of the updated value in the predicted value in your example. The effect of Kalman filetering seems very limited when r is 200 considering the resulting is 0.003 (xupdated is almost equal to x predicted in this case)
But when r is less (like 20)then the noise is also less and the effect of a bigger g is not visible.
Anyway, I am just trying to understand your example.
• Look at footnote 9 on that page.  It shows very clearly how the xhat values are updated.

• I have q question. The Kalman values used to generate the green(Kalman) signal are always equal to 0.75 times previous prediction.(The values in the Xhat row can be obtained by multiplying the first noisy value by 0.75 again and again) So when and how do we use updated values while generating Kalman signals in your example.
• Thanks, Ludovic.  I fixed this and will post the new pages tonight.

• On the second page, if you click on the "Previous" link, another lateral pane pops.