Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integrating gyro and accelerometer readings [duplicate]

Possible Duplicate:
Combine Gyroscope and Accelerometer Data

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 :)

like image 913
moonshadow Avatar asked Sep 21 '08 11:09

moonshadow


People also ask

How do you combine accelerometer and gyroscope data?

Combining 3D accelerometers and gyroscopes This can be accomplished with a sensor fusion strategy. Sensor fusion techniques combine sensory data from disparate sources and generate information that has less uncertainty, or more accuracy.

Is accelerometer and gyroscope same?

Accelerometer Versus GyroscopeAccelerometers measure linear acceleration (specified in mV/g) along one or several axis. A gyroscope measures angular velocity (specified in mV/deg/s).

Which is better accelerometer or gyroscope?

Uses of a gyroscope or accelerometer The main difference between the two devices is simple: one can sense rotation, whereas the other cannot. In a way, the accelerometer can gauge the orientation of a stationary item with relation to Earth's surface.

What is a 3 axis gyroscope and accelerometer?

3-axis gyroscopes measure angular rate and are usually combined with an accelerometer in a common package to allow advanced algorithms like sensor fusion (for orientation estimation in 3D space).


2 Answers

You seem to have two (or three) separate problems here.

1. You don't really understand Kalman filters and/or the mathematics behind them. That is going to make it very difficult to correctly implement and use one.

2. You don't seem to understand the basic physics involved in the problem. (Basic physics means underlying physics, not simple physics, because it isn't simple.)

I'd suggest that you try to use a much simpler integrator, such as a Runga-Kutta 4, for which you can find many books with examples of both the implementation and the use. It should be sufficient for this problem. (If the customer specified Kalman, inquire why.)

As for why the problem is under constrained, it seems to me that it is having no way to insure that the device is held vertically and no way to measure the actual orientation. Forget the gyro for the moment and assume the device can not be rotated about a vertical axis. You have three accelerometers, presumably to estimate position in 3D. So if you see an acceleration in the X direction, you increase the estimate of where you are in the X direction. Similarly, if you see an acceleration in the Z direction (which I will assume is "up"), you increase the estimate of where you are in the Z direction. Now rotate the device slightly, say 30 degrees about the Y axis. Now when the device thinks you are accelerating along the X direction, the device is actually accelerating a bit less than indicated in X and it is also accelerating in the Z direction. So your position estimate is now incorrect.

Rotations are much harder to integrate (the equations are more "stiff", requiring a smaller time step to maintain precision). But they will suffer similar problems of computing wrong answers if the device is tipped (because the device can not tell that it is tipped). It will think that the rotation about the vertical axis is larger or smaller than it actually is, because part of the rotation is actually about a different axis (just as part of the acceleration part was along a different axis).

Perhaps you need to hire a consultant (no, I'm not seeking a job) to assist you in formulating the mathematics.

like image 104
Mark T Avatar answered Sep 17 '22 19:09

Mark T


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.

like image 24
Steve Roe Avatar answered Sep 17 '22 19:09

Steve Roe