Okay, the basics of a Kalman filter (part 1).
Let's start with a simple case: perfect observations on a deterministic linear system.
Suppose you have a puck moving in 1 dimension. You can write a
Linear Dynamical System model for the motion of the puck as
x(t+dt) = x(t) + dx/dt(t) * dtdx/dt(t+dt) = v(t)
Since the system is linear, v(t) must be a constant over the time interval t to t+dt. If it isn't, then x(t+dt) is found by integrating the speed from t to t+dt. Let's stick with the assumption of a constant speed over the timestep for now, since it's all we need for Air Hockey.
If you were to implement a perfect prediction system using calculus you would solve the above equations in the usual manner: choose dt and using known values for x(t) and v(t), compute x(t+dt).
What if you didn't know v(t) though, but you had a former position , say x(t-dt), with which you could estimate v(t). Rather simple isn't it? Using a backwards difference estimate (just a fancy name for something you'll recognise)
[x(t) - x(t-dt)]v(t) = ---------------- dt
This should be fairly familiar to most people. If you were implementing a Pong AI you would probably use equations like this to figure out where the puck would cross the axis of movement of the AI paddle. In two dimensions it's no more difficult than adding a second set of equationns for the other dimension, since motion in each dimension is independent of what's happening in the other dimension.
Now, we can rewrite the Linear Dynamical System above so that it is in a linear algebra form. Here
s is a vector with s
1 being the position of the ouck and s
2 being the speed of the puck. So,
|x(t+dt)| | | = s (t+dt) = Fs (t)|v(t+dt)|
where F is the matrix
|1 dt|F = | | |0 1|
Noisy observations
------------------
Now, what would happen if the observations you were making on position were done through blurry glasses? Could you tell exactly what the position of the puck was at any given moment? You might say that, "hang on, my eyes aren't blurry, I can see where the puck is at any moment"! I would answer with this: "what are the exact coordinates of the puck on the table given that you can only glance at it"? Get the idea now? Humans don't have perfect information and indeed most measurement devices we use don't give perfect information either. They provide what we call 'noisy' observations of the environment.
So, let's consider a noisy observation on the state of the puck. If the true (unknown/ usually called 'hidden') state is
s (t) then we can denote the observation as y(t). (My apologies about the choice of notation but it's standard among many papers on Kalman filters that you might read. x or s often denotes state and y normally denotes observation on state. I'm using s for state)
Let's assume that the observation is some function, H, of the state plus some noise, n. (The function represents bias... like if for some reason you always thought the puck was a bit left of where it actually was. In most instances, the bias is zero so the function is just 1).
So, y(t) = H(
s (t)) +
n (t)
and in our situation
H = |1 0|andn = n1
so that H is telling us that we only have an observation on the position of the object and hence noise is only added to this observation. Thus, y is a scalar and not a vector.
So, our full linear dynamical system for the hockey puck is given by
s (t+dt) = Fs (t)y(t) = H(s (t)) + n (t)
We can go even further if we want to (but this choice is up to you) and say that the speed of the puck also has some small fluctuations associated with it, but that the average speed of the ball is v(t) (s
2(t)). I won't worry about this for now, but's it's something I'll add on later so have a think about what it might mean for the predictability of the motion of hte puck and hence its predicted position.
For now, the only other thing I want to mention is the noise we added to the observations. It should have zero mean and it needs certain other qualities as well (which I don't really need to explain). A good - and very common - choice for this noise is white Gaussian noise. In other words, noise that has a Normal (bell shaped) distribution.
That's enough for part 1 of this explanation on Kalman filters. I'll post more tomorrow. For now though, please make sure you understand everything above and please ask any questions you like regarding my explanation. Tomorrow I'll explain the basics of linear least-squares estimation and show you how to do it using only matrix operations!
Cheers,
Timkin
[edited by - Timkin on June 14, 2002 1:58:54 AM]