Hi there
I've been tinkering with the HiTechnic Gyro sensor to make a compass. Unfortunately, the analog gyro sensor does give quite a bit of noisy readings.
As several have pointed out, (some of) that could be corrected by using a 'Kalman filter'. LeJOS does include such a filter, but I cannot find a clue to how to use it!
Could someone please point me in a direction where I can get some "hands on" with this filter, without having to understand all the mathematical details of the filter?
Thanks!
Povl
Good Kalman filter example or explanation?
Moderators: roger, imaqine, 99jonathan

 Novice
 Posts: 44
 Joined: Sun Aug 06, 2006 11:57 pm
 Location: California Central Valley
Re: Good Kalman filter example or explanation?
The Samples section of release 0.9.0 has a complete program using the filter under KalmanTest. It uses a different sensor, but at least you can play with a complete program. The whole subject is way over my head..........
Walt
Walt
 kirkpthompson
 leJOS Team Member
 Posts: 305
 Joined: Wed Dec 05, 2007 1:27 am
 Location: New Mexico, USA
Re: Good Kalman filter example or explanation?
Greetings Povl.
Also take a look at the lejos.nxt.addon.GyroDirectionFinder class.
http://lejos.sourceforge.net/nxt/nxj/api/lejos/nxt/addon/GyroDirectionFinder.html
Best,
K
Also take a look at the lejos.nxt.addon.GyroDirectionFinder class.
http://lejos.sourceforge.net/nxt/nxj/api/lejos/nxt/addon/GyroDirectionFinder.html
Best,
K
Leg Godt!
Re: Good Kalman filter example or explanation?
Thank you very much for your replies!
Povl
Povl
Re: Good Kalman filter example or explanation?
Povl,
The idea of a Kalman filter is to fuse several sources of information. If there is only one source, as in your case, then the filter won't be of any help. You might be able to use the tacho's of the motors as an extra source, or a compass. But even then you would need to know the variance (statistical description) of the noise of all sources of information. I think you probably don't know and have to assume it is constant and guess a value. Under these circumstances the filter can be greatly simplified. You'll then end up with a filter that goes like this:
 calculate new heading from old heading and gyro reading.
 calculate new heading from old heading and tacho reading, or get new heading from a compass.
 make a weighted average of the two. The weight should reflect how much you trust the two sources of information.
The difference between the above filter and a real Kalman filter is that in a Kalman filter the weight is based on solid statistics and can vary over time. I hope this demystifies the filter a bit.
On my blog you can read of the proces I went through to understand the filter.
There are other ways to improve gyro output. Some of them also described on my blog as well. The gyrosensor class implements some of these ways.
Oh, my blog is here.
The idea of a Kalman filter is to fuse several sources of information. If there is only one source, as in your case, then the filter won't be of any help. You might be able to use the tacho's of the motors as an extra source, or a compass. But even then you would need to know the variance (statistical description) of the noise of all sources of information. I think you probably don't know and have to assume it is constant and guess a value. Under these circumstances the filter can be greatly simplified. You'll then end up with a filter that goes like this:
 calculate new heading from old heading and gyro reading.
 calculate new heading from old heading and tacho reading, or get new heading from a compass.
 make a weighted average of the two. The weight should reflect how much you trust the two sources of information.
The difference between the above filter and a real Kalman filter is that in a Kalman filter the weight is based on solid statistics and can vary over time. I hope this demystifies the filter a bit.
On my blog you can read of the proces I went through to understand the filter.
There are other ways to improve gyro output. Some of them also described on my blog as well. The gyrosensor class implements some of these ways.
Oh, my blog is here.
My NXT blog: http://nxttime.wordpress.com/
Re: Good Kalman filter example or explanation?
Thank you very much, Aswin  that does take some of the mystery out of the filter, though I'm still a bit puzzled.
Kind regards, Povl
Kind regards, Povl
Who is online
Users browsing this forum: No registered users and 1 guest