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.  

Views: 12701

Comment by Harry on December 5, 2014 at 5:56pm

I had a hard enough time understanding DCM and then Quaternions, but I did eventually understand enough to work with it and diagnose and correct problems in code.  If your tutorial can teach me, then it will be a success so keep it coming..

Comment by Jesse on December 5, 2014 at 6:52pm

This is great! One of the best ways to learn/master a subject is to teach it. I'm sure you'll learn even more by creating this tutorial. I look forward to going through it! I too had a hard time trying to learn the EKF, still do. ;-)

Comment by Ludovic on December 5, 2014 at 7:25pm

Part4:

there is:  x ^ k   =   x ^ k   +   0 * (z k - x ^ k-1 ) =  x ^ k-1
must be:   x ^ k   =   x ^ k-1   +   0 * (z k - x ^ k-1 ) =  x ^ k-1

Comment by Blake Morgan on December 5, 2014 at 7:36pm

Very cool. And the interactive parts really drive home how the different variables fit together in an intuitive way. In the few minutes it took me to read your clear tutorial I went from "read something about that on the 'drones discuss' forum, check that box in the parameters, 'cause it sounds cool" to comprehension. Keep up the fabulous work! 

Comment by Nikola Rabchevsky on December 6, 2014 at 9:16am

Cool.  If I may offer a few recommendations, please try to avoid using Greek letters, accented terms (i.e. prime or hat), subscripted notation, and other mathematical notation that can't easily be translated into code.  In fact, I'd ask that the tutorial be written as C code (IMHO, Matlab is cheating).  I've read dozens of papers and they all stem from a purely theoretical/mathematical basis which is lost on a lot of folks.  I've often chuckled at every SIGGraph paper presentation on fluid dynamics when the speaker says, "We implemented the Navier-Stokes equations..."  Yeah, sure you did.  Show me well-documented code.

Francis X Grovers has a video presentation from the DPRG that started off awesome but sadly he got distracted by too many questions so the tutorial is incomplete.

And then, of course, I'm sure we'd all like to know how kalman filters can be used to fuse different sensor types together and how you can add additional sensor types.

Comment by MikeRover on December 7, 2014 at 2:38am

I disagree with Nikola - the proper notation is far easier to understand than arcane variable names written in a stream of pseudocode.  Matlab is perfectly valid and well suited for demonstration code. 

 

If you want to see a C-coded Klaman Filter, then look at the APM code!!

Comment by MHefny on December 7, 2014 at 7:22am

Thank you for your great effort.... many thanks indeed

Comment by Julien Dubois on December 7, 2014 at 12:57pm

Great job, tanks a lot!

Added to favourite :)

Comment by Greg Dronsky on December 7, 2014 at 1:57pm

i almost missed this post! Thanks man!!!!

Comment by Simon D. Levy on December 7, 2014 at 2:30pm

Thanks for the comments, everyone -- especially @Ludovic for catching the typo!  I appreciate the problems pointed out by @Nikola and @MikeRover and am trying to strike a balance between formulas (for engineers) and code (for programmers).  In some cases I've annotated the the formulas with actual JavaScript code used to generate the plots -- will try and do this for other formulas too, maybe even have links to code (C, Python, Matlab). Also, for the final pages, I plan to show actual EKF C code, annotated with the corresponding formulas.

Comment

You need to be a member of DIY Drones to add comments!

Join DIY Drones

Groups

Season Two of the Trust Time Trial (T3) Contest 
A list of all T3 contests is here. The current round, the Vertical Horizontal one, is here

© 2019   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service