Kalman Filters

hey along with several other elements of control theory I have been researching Kalman Filters. I believe they could be useful on a first robot however i have not yet found an explanation that contains only mathamatics at my level (BC Calculus). So while i understand some of the material i dont understand quite enough to implement one. does anyone know enough about kalman filters to help me out.

I’m in Ap Calculus and I wish I could help you, could you explain this “Kalman Filters” more.

1 Like

This thread has some helpful posts. Particularly that paper at the end.

Didn’t understand most of it :slight_smile: Than again, I’m pretty bad at both programming and math.

ya so am I. heres the top of the wikipedia article on kalman filters.

“The Kalman filter is an efficient recursive filter that estimates the state of a dynamic system from a series of incomplete and noisy measurements. Together with the linear-quadratic regulator (LQR) the Kalman filter solves the linear-quadratic-Gaussian control problem (LQG). The Kalman filter, the linear-quadratic regulator and the linear-quadratic-Gaussian controller are solutions to what probably are the most fundamental problems in control theory.”

…see if this is helpful…
Kalman Filtering

The Kalman filter probably isn’t something you’d really be ready to handle in HS.

I’m getting a Doctorate in controls, so let me see if I can put the KF in more understandable terms…

Basically, the Kalman filter finds an optimal estimator in a noisy environment, but there’s a lot you’d have to know before you get to that.

First off, controls (meaning the mathematical treatment of it) takes a lot of math. I mean Differential Equations, Laplace Transforms, matrices, state space, etc. These concepts don’t come up until at least a second year in college, typically. Usually students encounter controls as a fourth year engineering student, and the Kalman filter is beyond that. Personally, I didn’t come across the KF until I was a second year in Grad. School.

In advanced controls, the focus isn’t on the input and output…it’s about what’s going on inside. We call this the “State” of the system. The state can’t always be measured (think about how many sensors it would take to know the acceleration, speed, and position of a wheel mounted on a motor). But, there’s a little trick…if you know how the system you’re working with behaves (in this case a wheel mounted to a motor), you can “estimate” the state by knowing only a small part of it.

In the case of a wheel mounted to a motor, the state is the angular speed, angular position, and current through the motor. These could all be measured, but that isn’t always possible.

But, using an Estimator or Observer (the same thing) mentioned above, if you know the position, you can find an approximation of the full state. However, noise can be a problem, and the Kalman filter overcomes this by taking features of the noise, combined with features of the system to find an optimal estimator. To create one, you need to know the noise of the input, the noise of the state (noise in the system), and how the two are related to each other and within each other. I won’t go any further, because at this point we get into all sorts of matrix math and probability theory that I don’t want to get into at midnite.

It could be implemented for FRC, but it may not be necessary. As I have heard it put: don’t use a sledge where you need a finishing hammer…it doesn’t look good.

If you want to pursue KF, then I’d suggest learning about lower level controllers, like PID and Lead/Lag (WHY they work, not just how to use them), and build up to it.

Don’t take this as discouragement. I hope you find plenty of fascinating control topics to study.

-Jeff Erickson, FRC 41 Mentor

P.S. if you want a book reference, check out Digital Control System Analysis and Design by Phillips and Nagle.

hey thanks for the help and the book recommendation i got a couple of copies (cheep thanks to amazon) no chance you wanna explain a little of the math thats mostly what i was having trouble with.

I’m a second-year college student, and I haven’t had differential equations yet. If you don’t have Calculus 2 (advanced integrals (including exponential and logarithmic) and series) under your belt, you probably aren’t ready for what’s known as “Difficult” Equations. That’s next semester for me. (After Calc 3 this semester…) So if Calc BC is equivalent to Calc 2, you have a half-chance of undersanding the math. If not, you’ll have to learn on the side.

Truth is, you probably won’t see Kalman filters even in college - only in grad school.

jee7s already gave you a pretty good basic explanation on what a Kalman filter does, so let me tell you about your options. It’s great that you’re interested in an advanced topic, and I don’t mean to disencourage you, but if you’re taking Calculus now, there’s a LONG way ahead, and you’re probably better off going to college to receive a formal training.

Here’s the most likely course route, after Calculus:

Linear Algebra (basic course, I wish someone told me back then how important it would be)
Differential Equations
An Applied Math course (Laplace and Fourier transforms)
Signals and Systems
Classical Control
Linear System Theory
(So-called) Modern Control - state space approach
Intro to Stochastic Processes
Optimal Control (finally you’re gonna hear about the Kalman filter)

The last four courses are probably graduate level, depending on where you go to school. As you can see, you’re looking at four to six years of college education. It won’t be easy, but as a FIRST student you already have a competitive advantage over your future peers: to be curious as hell (and I say that from experience - not too long ago I was in your position). :wink:

Let us know if you have further questions.

thanks for the help everyone.

The first I heard of Kalman Filters was in articles related to the Darpa challenge … it was my impression it was a means to process signal inputs AND combine inputs from multiple sensors (like wheel encoders plus gyro plus accelerometer) into some sort of matrix which would evaluate the most correct decision data.

From reading this thread I now understand that the Kalman Filter is a means to extract a good signal (opinion/estimate) from a noisy one - usually from ONE sensor.

Since it seems that the Kalman Filter is a very advanced topic, in First we can use simpler filtering techniques such as moving averages, throwing out “obviously bad” minimum and maximum sensor readings, and more advanced filters such as FIR and FFT. Some more discussion about filtering sensor inputs, and combining multiple sensors into decision-making software, can be found at http://www.servomagazine.com/search.php and searching for filter.

Searching for sensor fusion on the same site produces some interesting articles about combining multiple sensors to make decisions, particularly the July and August 2006 articles entitled “Autonomous Robots and Multiple Sensors”.

Actually, because the Kalman filter is based on matrix operations, it is very flexible and can be used for varying numbers of sensors and state variables. For a comprehensive set of links see http://www.cs.unc.edu/~welch/kalman/

Several summers ago, a college mentor from FRC 931 built a low cost self-balancing scooter as a demonstration project while working as an intern in my lab at Emerson. His creation looked very much like one built earlier by Trevor Blackwell. Both versions employ Kalman filters to correct for drift in the tilt angle estimated by integrating a gyro’s output.

While that student has gone on to pursue PhD level work since then, he had never heard of a Kalman filter before starting the project. Full comprehension of the Kalman filter’s mathematical beauty requires the kind of study that previous posters in this thread have described – and that study is rewarding for its own sake. However, you can apply what others have done without getting to that depth.

Yes, the mathematical basis for balancing an inverted pendulum really is rocket science. Be encouraged by the evidence that the math works, not intimidated by its beautiful details.

its true i can utilize someone else’s implementation but i don’t like to do that unless i at least understand their implementation myself. and typically apart from basic framework code (which is a pain) i like to implement code myself (or use code implemented by my teammates) its just hard to properly use code that you don’t understand. for example i was looking at the code for an old robot fixing it up and i found the PID loop was adding the D term to the output which is exactly the opposite of what you want so i like to at least understand the basics (including the basic math) behind the code i write. Anyone can use someone else’s algorithms but if they don’t try to understand them they get nothing from it. so when i wrote a auto tune loop for a PID earlier this year based on zigler-nicoles it was only after reading an entire text book from a cal tech course (which was fascinating and free btw i recommend it http://www.cds.caltech.edu/~murray/amwiki/index.php?title=Main_Page)

OK, so you like the beautiful details. I do too. :slight_smile:

BTW, the former FRC 931 college mentor that I mentioned above is Brandon Heller. He is a PhD student at Stanford now. I think he also was one of the mentors for FRC 8 (your team) last year.

As Sam mentioned a couple of posts up, Kalman filters are good for much more than just figuring out which way is up (whatever your frame of reference). Your exploration of the details might lead to applications beyond balancing an inverted pendulum, and one of those might find its way onto your team’s next robot. Have fun with it.

ya he was a mentor of ours last year. Im not sure of his status this year but thanks i’ll ask him about it. but first for research into the beautiful details and some other concepts in control theory, beyond what i already know. thanks all for your help and support.