The Extended Kalman Filter: An Interactive Tutorial for Non-Experts
In working with autopilot systems like
Crazyflie and
ArduPilot
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. [1]
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. Starting with some simple examples and the
standard (linear) Kalman filter, we work toward an understanding of actual EKF implementations at end of the tutorial.
Part 1: A Simple Example
Imagine an airplane coming in for a landing. Though there are many things we might worry about, like airspeed, fuel, etc.,
the most obvious thing to focus on his the plane's altitude (height above sea level). As a very simple approximation,
we can think of the current altitude as a fraction of the previous altitude. For example, if the
plane loses 2% of its altitude each time we observe it, then its altitude at the current time
is 98% of its altitude at the previous time:
altitudecurrent_time = * altitudeprevious_time
Engineers use the term recursive to refer to a formula like this where a quantity is defined in terms of its previous
value: to compute the current value, we must “recur” back to the previous. Eventually we recur back to some
initial “base case”, like a known starting altitude.
Try moving around the slider above to see how the plane's altitude changes for different percentages.
[1] Two notable exceptions are
Kalman Filtering for Dummies and
the
the Wikipedia page, from which I have borrowed here. For a more pictorial approach, take a look at
this tutorial.
If you're already comfortable with math notation, you might want to check out
this tutorial
before spending any more time here.
This tutorial has also benefited from helpful
comments by members of the DIY Drones community (esp. Tim Wilkin, who
corrected a number of inaccuracies in my explanations).