Author Topic: Kalman Filter  (Read 7413 times)

0 Members and 1 Guest are viewing this topic.

Offline AdminTopic starter

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Kalman Filter
« on: April 16, 2007, 11:19:30 AM »
A question to the experts . . .

Can someone explain to me exactly what a Kalman filter is and pratical uses for it? Ive found tons of mathematical explanations for it (such as on wikipedia: http://en.wikipedia.org/wiki/Kalman_filter ), but none relating to robotics . . . Im still confused . . .

I think its what you use to merge data from sensors, such as sonar and a rangefinder on a single robot. But really not sure . . .

Offline JonHylands

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 562
  • Helpful? 3
  • Robot Builder/ Software Developer
    • Jon's Place
Re: Kalman Filter
« Reply #1 on: April 16, 2007, 11:29:41 AM »
Well, its a pretty generalized filter that allows you to take a certain class of noisy data and filter out the noise, as well as compensating for certain types of error. It is provably optimal at that for specific types of data.

For robotics, typically people use a Kalman filter for fusing 6-axis IMU data. A well-done Kalman filter can compensate for rate gyro drift automatically.

I really don't understand much of how they work, but I've certainly read enough papers and pages on them that I should. The whole topic is incredibly arcane, and filled with enough mathematical hieroglyphics to make your head spin.

- Jon

Offline AdminTopic starter

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Kalman Filter
« Reply #2 on: April 16, 2007, 12:55:18 PM »
Quote
and filled with enough mathematical hieroglyphics to make your head spin
yea it was definitely spinning <insert spinning head smiley face here>

its still spinning . . .

Offline Kohanbash

  • Supreme Robot
  • *****
  • Posts: 430
  • Helpful? 1
Re: Kalman Filter
« Reply #3 on: April 16, 2007, 08:23:00 PM »
I agree they are definitely difficult. Kalman filter are based from Bayesian statistics using markovian techniques. You need to develop a model for your system (ie. robot or component) and also be able to predict the next state of the robot.
   For example if were using GPS we can say that our model is:
                                PercievedLocation = RealLocation + e   : where e is some error variance
   the next state is:
                                RealLocation = PercievedLocation + CommandedLocation
   through observation as you keep integrating your location your error increases drastically.

   the error is basically computed by saying:
                                e=RealLocation - ExpectedRealPosition
   computing the error always assumes that you know the prior error so that you can compute PercievedLocation.
There is also a statistical part that takes the error that you calculated beforemoving and the error that you calculated after moving to create a more accurate error variance value.

Hope that helps, I’m not a kalman expert, but I have managed to overhear PhD’s while they were developing kalman filters

I have never heard of a kalman filter doing the actual sensor fusion, however it can help fix some of the numbers before the data is fused.

Admin if you have any other specific questions I can try to get the answers for you.

« Last Edit: April 16, 2007, 09:43:02 PM by sdk32285 »
Robots for Roboticists Blog - http://robotsforroboticists.com/

Offline Kohanbash

  • Supreme Robot
  • *****
  • Posts: 430
  • Helpful? 1
Re: Kalman Filter
« Reply #4 on: March 10, 2008, 10:16:18 PM »
I am finally implementing my own kalman filter (on two separate projects) and I realized that my last post was pretty bad.

I am using a kalman filter for sensor fusion in order to take wheel odometry data and merge it with my IMU data to get an accurate heading, and also I am trying to use a kalman filter to "correct" my velocity (I am integrating acceleration to get velocity so it is incredibly noisy IMU data.

The main steps are:
1. Build a mathematical model of your system (kinematics / dynamics) and of its error.
2. Estimate your current state by running your prior state through your mathematical model.
3. KalmanGain=Error * (Weight + Error)   (you can use the weighted error to say that you trust one sensor more than another).
4. CurrentState= CurrentState + (WhatYouMeasuredHappened-(KalmanGain * Weight * CurrentState))
5. NewError= (1-KalmanGain)* Error
6. goto step 2

The actual math is not to bad, the hard part is accuratly building the system model, the error model, and tweaking the Weights to get accurate results.

« Last Edit: March 10, 2008, 10:25:53 PM by sdk32285 »
Robots for Roboticists Blog - http://robotsforroboticists.com/

Offline Centaur

  • Jr. Member
  • **
  • Posts: 41
  • Helpful? 0
Re: Kalman Filter
« Reply #5 on: March 10, 2008, 10:34:15 PM »
I am finally implementing my own kalman filter (on two separate projects) and I realized that my last post was pretty bad.

I am using a kalman filter for sensor fusion in order to take wheel odometry data and merge it with my IMU data to get an accurate heading, and also I am trying to use a kalman filter to "correct" my velocity (I am integrating acceleration to get velocity so it is incredibly noisy IMU data.

The main steps are:
1. Build a mathematical model of your system (kinematics / dynamics) and of its error.
2. Estimate your current state by running your prior state through your mathematical model.
3. KalmanGain=Error * (Weight + Error)   (you can use the weighted error to say that you trust one sensor more than another).
4. CurrentState= CurrentState + (WhatYouMeasuredHappened-(KalmanGain * Weight * CurrentState))
5. NewError= (1-KalmanGain)* Error
6. goto step 2

The actual math is not to bad, the hard part is accuratly building the system model, the error model, and tweaking the Weights to get accurate results.



I can imagine that confirming your results as accurate could also be very difficult...

I've used Kalman filters at work for filtering accelerometer data so you can visually see what's happening.  The data we use is taken at 10-20 thousand herts, so as you can imagine it's very noisy.  Unfortunately I had nothing to do with developing the program that does the filtering, so I have no idea how to implement it, unlike sdk.  At some point in the future I'd like to learn though.  The nice thing is that data taken at that rate is pretty darn accurate once it's integrated for velocity and then position. 
Any intelligent fool can make things bigger, more complex, and more violent.  It takes a touch of genius - and a lot of courage - to move in the opposite direction.  ~E.F. Schumacker

Offline Kohanbash

  • Supreme Robot
  • *****
  • Posts: 430
  • Helpful? 1
Re: Kalman Filter
« Reply #6 on: March 11, 2008, 06:11:14 AM »
I can imagine that confirming your results as accurate could also be very difficult...
Its actually not that bad. I have a GPS with omnistar correction that I use for groundtruthing.
The data we use is taken at 10-20 thousand herts, so as you can imagine it's very noisy. 
WOW that's some super fast data. I have never heard of an accelerometer that outputs data that fast...
The nice thing is that data taken at that rate is pretty darn accurate once it's integrated for velocity and then position. 
So usually when you integrate that many times your error actually builds up quicker since you are also integrating the error at each time step.

« Last Edit: March 11, 2008, 06:13:07 AM by sdk32285 »
Robots for Roboticists Blog - http://robotsforroboticists.com/

Offline AdminTopic starter

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Kalman Filter
« Reply #7 on: March 15, 2008, 02:03:33 PM »
Quote
I am using a kalman filter for sensor fusion in order to take wheel odometry data and merge it with my IMU data to get an accurate heading, and also I am trying to use a kalman filter to "correct" my velocity (I am integrating acceleration to get velocity so it is incredibly noisy IMU data.
Could you post your kalman source code when you're done? I understand the concept, but not entirely sure where to put in all the sensor data into the equations . . . My bots are getting advanced enough to where I don't think I can avoid using this filter any longer . . .


Quote
Quote from: Centaur on March 11, 2008, 12:34:15 AM
Quote
The data we use is taken at 10-20 thousand herts, so as you can imagine it's very noisy.


WOW that's some super fast data. I have never heard of an accelerometer that outputs data that fast...
An analog accelerometer could . . . the very expensive high frequency kind . . . Centaur, what exactly are you measuring?!

Offline Kohanbash

  • Supreme Robot
  • *****
  • Posts: 430
  • Helpful? 1
Re: Kalman Filter
« Reply #8 on: March 15, 2008, 07:10:41 PM »
Hi
I am working on a filter for two projects, one is for my job and the other is for course work.
While I can not post the one from my job, I can post the one from my class work.

The assignment is to develop the kinematics, dynamics, and a simulator for a planer bipedal robot, create "noisy sensor" data that needs to be filtered with a kalman filter and to have "missing" velocity data so that we need to use a kalman filter to estimate the current state based from the previous state.

Ill post my code but the hard part is in the derivation of the model (Ill try and post my design notes).
Ill try to make a kalman filter tutorial in May.
Robots for Roboticists Blog - http://robotsforroboticists.com/

Offline Centaur

  • Jr. Member
  • **
  • Posts: 41
  • Helpful? 0
Re: Kalman Filter
« Reply #9 on: March 17, 2008, 10:55:58 PM »
Quote
Quote from: Centaur on March 11, 2008, 12:34:15 AM
Quote
The data we use is taken at 10-20 thousand herts, so as you can imagine it's very noisy.


WOW that's some super fast data. I have never heard of an accelerometer that outputs data that fast...
An analog accelerometer could . . . the very expensive high frequency kind . . . Centaur, what exactly are you measuring?!

Without getting to specific, I'm measuring automotive impacts and the resulting accelerations throughout the vehicle.  The accelerometers cost between 500 and 1000 a piece and they are often destroyed in the testing.

The nice thing is that data taken at that rate is pretty darn accurate once it's integrated for velocity and then position. 
So usually when you integrate that many times your error actually builds up quicker since you are also integrating the error at each time step.

So are you suggesting that sampling at a lower rate would actually yield more accurate results?  Please explain because I don't understand how that would be possible.
« Last Edit: March 17, 2008, 11:24:21 PM by Centaur »
Any intelligent fool can make things bigger, more complex, and more violent.  It takes a touch of genius - and a lot of courage - to move in the opposite direction.  ~E.F. Schumacker

Offline JesseWelling

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 707
  • Helpful? 0
  • Only You Can Build A Robot!
Re: Kalman Filter
« Reply #10 on: March 17, 2008, 11:58:50 PM »
Quote
So usually when you integrate that many times your error actually builds up quicker since you are also integrating the error at each time step.

I think what he is saying is that if you rely only on the integration of accelerometers for position, your error will build up really quick. But accelerometer only is not a Kalman filter  ;)

But for the application of impact characterization, I doubt you need to integrate the acceleration, you just want to know the forces involved and what takes the most beating...

Offline Kohanbash

  • Supreme Robot
  • *****
  • Posts: 430
  • Helpful? 1
Re: Kalman Filter
« Reply #11 on: March 18, 2008, 01:08:49 AM »
Just adding to what JesseWelling said if you are doing impact testing than you are more concerned with the maximum accelerations values and you do not need a fancy filter (maybe just a sliding average to remove some noise).

If this is all you are concerned with than you want a fast rate since critical accelerations can exist for fractions of a second which would still be harmful to a person inside the vehicle (I know you are at 10+kHz which is faster than you need).

How are you calibrating your Accelerometers?
Robots for Roboticists Blog - http://robotsforroboticists.com/

Offline Centaur

  • Jr. Member
  • **
  • Posts: 41
  • Helpful? 0
Re: Kalman Filter
« Reply #12 on: March 18, 2008, 10:03:35 AM »
I'm not sure on how we calibrate them.  I'll have to look into that.

As far as for robot positioning, I do agree that using a kalman filter to remove errors would be more accurate than accelerometers alone. 

I was just confused because I thought you were saying that if you are using a kalman filter with lower frequency accelerometers it would be more accurate than using a kalman filter with a higher frequency accelerometer.  If that is what you are saying, please explain because I don't understand how that would be possible, and I'd love to know.  That means you can use cheaper accelerometers etc and actually get better accuracy for robot position which would be awesome!

I understand there's a trade off between accuracy, price, and processor resources.  I was just talking strictly about accuracy on high frequency vs low frequency when both are used with a kalman filter.
Any intelligent fool can make things bigger, more complex, and more violent.  It takes a touch of genius - and a lot of courage - to move in the opposite direction.  ~E.F. Schumacker

Offline JesseWelling

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 707
  • Helpful? 0
  • Only You Can Build A Robot!
Re: Kalman Filter
« Reply #13 on: March 21, 2008, 12:35:04 PM »
I would say you don't need to update your Kalman filter any faster than twice the speed at which your robot makes decisions on it. Any faster would be a waste of processing power that you could use on the AI decision making subsystem, or if you have so much frequency on measurements to do some filtering before you put it into the Kalman filter... but I'm not expert at this by any means, it's just a whisper from my ghost  :P

Offline Kohanbash

  • Supreme Robot
  • *****
  • Posts: 430
  • Helpful? 1
Re: Kalman Filter
« Reply #14 on: April 06, 2008, 01:33:10 PM »
See the below link for the continuation of this thread which deals with actually implementing a kalman filter

 http://www.societyofrobots.com/robotforum/index.php?topic=3823.0
Robots for Roboticists Blog - http://robotsforroboticists.com/

 


Get Your Ad Here

data_list