Kalman filtering

Most all of us who are trying to utilize sensor data of some kind have stumbled across the Kalman filter. I know that I personally don’t currently possess the math skills to pick my way through most descriptions of it let alone start to implement one. In the past couple of days, I’ve been trying to give myself a mathematics crash course for just this purpose.

To this end, I’ve been trying to identify some resources that may be helpful. Hopefully others can contribute as well.

So far, I’ve found:

cs.unc.edu/~welch/kalman/maybeck.html )

academic.csuohio.edu/simond/cour … kalman.pdf

and of course en.wikipedia.org/wiki/Kalman_filter which, while not accessible to the non-mathies in and of itself does allow you to easily drill down to find the areas of math and terms that are unknown and start to build that foundation.

Geez, all I see are small and big letters of the alphabet. I can’s make any sense of it!

I think I will stick with my bot running in to walls from time to time. :laughing:

JK

I wish i payed more attention during math at school :blush:

I haven’t come around on doing the sensor part of my project, but i didn’t think i would need some kind of filtering on the data from the sensors. :confused:

I was hoping that the Neural Network framework i’ve written in java would solve most of my math problems without having to understand a thing :smiley:

Oh well, part of the fun about robotics projects is to stumble on problems and to find a solution :wink:

Exactly Dennis, it’s about solving problems and developing your own technology regardless if it’s been done already.

The reward is the knowledge and sense of accomplishment. It’s all a mater of how far you want to take it. There are virtually no limits with this field, and furthermore, even HONDA and SONY with all it’s money and recourses are still developing their new technology with the ASIMO or Sony with its QIRO.

Just like Andy Lippit, he has been successful in making his pod walk, but he strives to give his pod the latest technology and improving its over all functionality.

The question is: What do you want? and How far do you want to go with it?
What makes this place so great: we have members that get together and share ideas and try to help each other out when ever we can. It feels like an RC club but for robot junkies instead. :laughing:

OK, from what I can tell the first step one needs to take to get one of these running is it craft a state space model ( en.wikipedia.org/wiki/State_space_%28controls%29 ) of whatever your are trying to predict. Fortunately for most of us, we are working with the simplest form :open_mouth:, the discrete time-invariant models.

When I get some idea of how to do this, I’ll let you all know.

Arrrrrrrrrgh!

I opened the wikipedia link, expecting a pleasant plethera of trig and calc jargon, and nearly burned my retinas on what was actually physics.

Ugh!

If you need help with a strictly math-oriented part of that, Andy, let me know.

But, when it comes to physics, I break down and foam at the mouth.

:stuck_out_tongue:

I’ve gotten a little bit further today. I have a simulation running that is running 2 separate filters, estimating X and Y coordinates of my mouse over a form. The model isn’t the best for this data (it incorporates velocity in the same way that the samples all do) which isn’t all that realistic with my mouse (sudden starts and stops).

The good part is that it works. The better part is that I almost get it.

The physics that are involved on that page are actually fairly minimal.

The formula Xk = FXk-1 + GAk is only the coefficient matrix representation of

X = X + deltaT*Velocity + .5 * deltaT^2 * acceleration

Suggesting the relation between position, velocity and acceleration

So they convert this to the discrete time invariant matrix form of a state equation en.wikipedia.org/wiki/System_of_linear_equations ]

The first matrix in the sample (F) is found by creating the coefficient matrix for:

X = X + deltaT * V and
V = V

(X = position, V = velocity)

yielding

1 deltaT ; 0 1 ]

G gets the mapping from acceleration (the control input in this example) to position and velocity in a similar manner.

When comparing this example to the State Space Controls page, the sample F matrix is the State State space A matrix. G = B, and H = C. State Space D matrix is neglected as the inputs are not passed through to the outputs.

I haven’t quite figured out the initialization of the covariance matricies to reasonable values yet, but I’m almost there.

The last line in the Update algo on the wiki Kalman Filter page had me baffled for a long time. If you’re like me, I = Identity Matrix.

^------- Huh??

:laughing:

The Kalman filter is some pretty high level stuff. Like PHD work kind of stuff. Its currently used quit often in INUs to break down errors between gyroscopes and accelerometers to get the most accurate data possible and in some cases even predict what the UAV will do. I have had an education up to vector calculus and differential equations and such and I have a big problem understanding all of it. My suggestion is that if you want to use a filter then try something simpilar like a root filter unless your going the UAV route and are flying with a Xbox(not the game council) or something similar.

Well then it was sheer luck that allowed me to get it running :slight_smile:

I’ve got some code cleanup to do, but will post a small c# library that should be easily ported. All you need is a good matrix math lib. Testing it though also requires a good gaussian random number generator or a real world scenario.

The library cannot encapsulate all the complexity of using the filter however. You still need to be able to create a state space model for your system, sensors and controls. It does help out with the covariance matrix setup and the predict/update loop of the filter itself.

vizlog.com/robot/kalman.zip

c# project using mapack.dll (included) from aisto.com/roeder/dotnet/ for matrix math

There’s a robot (big circle) which moves around (arrows keys) and is tossed around by some random noise (Process Noise)

There are sensor readings (little squares) that are noisy (Noise)

The Kalman filter combines a position and velocity model along with the accelerations you provide (arrow keys) and the noisy sensor data to estimate the position (little circle).

andy, i must say i am thoroughly impressed. i had heard of the Kalman filter but dismissed it for its complexity; you have proved me wrong and i am forced to take another look. and now that someone has done the hard part for us… :smiley:

nick

I don’t get wht the links provide. If I download it, can I run it or do I need a c# compiler to run it? What are you referng to with the squares and circles?

Thanks Nick!

Mike, yea, to run it you’d need to compile it. I’ll put some binaries up later today. All the circles/squares nonsense is referring to the controls and display of the sim.

A couple caveats…

The Gaussian random generator is not very good. So in practice this thing my do a lot better than the sim.

Also, I’m pretty sure I’m not doing a very good job of setting reasonable values in the covariance matricies, so take that part with a big grain of salt.

vizlog.com/robot/kalmanbinaries.zip

requires .net framework

It worked but what exactly is it doing? I understand that the big circle is the bot, the little circle is the projected direction, and the squares are sensor noise. I not sure what it’s demonstrating though. Is moving in a proper direction regardless of the noise it receives from the data? That’s my guess as what it’s doing.