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