The Extended Kalman Filter: An Interactive Tutorial

3689628578?profile=originalIn 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.  

E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones

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

  • 3701899773?profile=original

    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.

  • 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.

  • Look at footnote 9 on that page.  It shows very clearly how the xhat values are updated.

  • Thanks, Ludovic.  I fixed this and will post the new pages tonight.

  • thanks, it's worth reading

  • Thanks Fábio!  I took your indexing suggestion -- hope you like it.

  • Thanks, Sam! 

    I've posted a couple more pages, introducing sensor fusion.

  • Simon,

    I've only managed a quick look at this so far - I like your style.

    Sam

  • Tobias: Thank you for pointing me to this paper -- it is a good intro to the KF that I never found myself.

    In that paper, they are modeling a control signal representing a braking effect.  In my tutorial slide (#11), I am ignoring the control signal temporarily in order to explain the basic linear algebra operation matrix * vector multiply. 

    It is important to realize that there is no "correct" formula for the Kalman Filter that works in every example.  The KF is a general way of representing a system that takes many possible sources of variance into account: process noise, measurement noise, control signal, etc.  To describe a particular system it is often convenient to assume default values like zero or one for certain elements, as I have done at some points in my tutorial.  This is a common practice in physics and engineering exercises.  You can learn a lot about physics without taking friction into account (coefficient of friction = zero), but modeling an actual system will most likely make it dangerous to ignore friction.

    As one of my colleagues like to say, the really important equation in modeling is:

    NEW_VALUE = OLD_VALUE + CHANGE

    Other than that, there's no "magic formula": you have to think about the system you want to model, and what changes, and what doesn't change.

This reply was deleted.