views:

5398

answers:

8

I have read a number of papers on Kalman filters, but there seem to be few good publically accessible worked examples of getting from mathematical paper to actual working code.

I have a system containing a three-axis accelerometer and a single gyro measuring rotation around one of the accelerometer axes. The system is designed to be held by a human, and much of the time the gyro will be measuring rotation about the gravity vector or close to it. (People working in the same industry will likely recognise what I am talking about from that ;)) I realise this is underconstrained.

The gyros appear to have a near-constant bias that is slightly different for each instance of the system. How would I go about coding a filter to use the accelerometer readings to calibrate the gyro at times when the system is tilted so the gyro axis is not collinear with gravity, and is being rotated about the gyro axis? It seems like there should be enough information to do that, but being told that there isn't and why would be an answer too :)

+3  A: 
Mark T
Bear in mind that gravity is a constant force that the accelerometer senses. I can, and do, use this to deduce the current pitch and roll of the device. What I can't deduce with the accelerometer alone is the yaw; that's what the gyro is for. However, its reading drifts over time, hence my question.
moonshadow
Thanks for the Runga-Kutta suggestion, I will look into that.
moonshadow
+2  A: 

I found good articles about the use of accelerometers and gyroscopes in navigation on this blog. The part on Kalman filtering is a bit hazy, but there seems to be code samples.

You will also find general resources on Kalman filtering at http://academic.csuohio.edu/simond/publications.html. The article referred in (8) is a good, not too scary, introduction to the mathematics behind Kalman filters.

Kena
+4  A: 

Given your interest in the kalman filter, perhaps you intend to augment GPS data with inertial measurements. About your question:

"How would I go about coding a filter to use the accelerometer readings to calibrate the gyro at times when the system is tilted so the gyro axis is not collinear with gravity, and is being rotated about the gyro axis? It seems like there should be enough information to do that"

This sounds like a gyrocompasing alignment. Assuming you are doing a factory calibration, and have the unit on a bench, you will be able to independently measure the alignment. Then run the leveling code you will write and back out the gyro bias error from the difference between the measure and gyrocompased alignments.

If you want to update gyro drift on-the fly, then you will need the kalman filter.

As far as implementation goes I recommend Chapter 7, GPS and Inertial Integration of Global Position System Theory and Applications vol 2 has excellent background on the topic. It has the theory and math, but no source code.

Steve Roe
Thanks! While it is not GPS data I intend to augment, the problem is similar. "Gyrocompassing alignment" looks like a very useful search term, I will research.
moonshadow
Even though you're not using GPS the chapter 7 in GPS Theory and Applications may provide you useful background. I was able to find the chapter on google books.
Steve Roe
+4  A: 

MAV-blog : Kalman demo application
Has source code for Microchip microcontroller that uses Kalman filter to integrate gyro and accelerometer.
nBot, a two wheel balancing robot
Quite a bit of info and links about how this author chose to solve the balance problem for his two wheeled robot.
Parallax Propeller based IMU
Has code that implements Kalman filter for Propeller base microcontroller.
Kalman Filter for LEGO Mindstorms NXT
Very good article about implementation of Kalman filter on LEGO NXT.

Louis Davis
+1  A: 

I too faced the issue of combining accelerometer and gyroscope data. I was able to find an answer here at stack overflow, which it appears that you have as well. However I just wanted to go ahead and link the solution I found in case it helped someone else.

Combining Gyroscope and Accelerometer Data

Dylan Vester
A: 

did anyone of you worked in labview with gyro and accelerometer? and combining these two to identify for exemple an arm movement?

thanks a lot, Anna

Anna
+1  A: 

If you happen to be developing for the Propeller uController, than the Parallax Object Exchange has some code. Great question ;-)

Chris O
A: 

Actually I have an USB 6009 DAQ, with a 2 axes accelerometer and also a gyroscope. And I'm thinking of somethink great, maybe revolutionize the world (kiddin'). In fact i want to try to identify a motion :) Thanks a lot for a so fast reply, Anna

Anna