DSPRelated.com
Forums

Kalman filter with accelerometer

Started by blackmangoes May 30, 2005
I only have an 2d accelerometer availabe but it is noisy, so I want to do
better than just doing low pass filtering. I am wondering if it is
possible to do kalman filtering with just an accelerometer. Let's say I am
just concerning in position and velocitly in 1d space for now.

I am a little confused what ithe input u in x(t+1) = Ax(t) + Bu(t) + w
equation and what the output y in y(x) = Cx(t) + n should be.

People said y is supposed to be the measurement, so is it the
accelerometer reading? If my x(t) is [pos vel], then what is u(t)?

Would be nice if someone can tell me what is A, B, C, x and y be
Your reply is greatly appreciated








		
This message was sent using the Comp.DSP web interface on
www.DSPRelated.com
Don't know anything about Kalman filters, but I have used oversampling
+ averaging to decrease the noise of accelerometers while maintaining
the required bandwidth. You have to have a fast A/D and CPU though, I
use 64 samples.

steve wrote:
> Don't know anything about Kalman filters, but I have used oversampling > + averaging to decrease the noise of accelerometers while maintaining > the required bandwidth. You have to have a fast A/D and CPU though, I > use 64 samples. >
Noise tends to become more correlated as you sample faster, unless you have a real crappy analog front end. Averaging doesn't do much for correlated noise.
blackmangoes wrote:

> I only have an 2d accelerometer availabe but it is noisy, so I want to do > better than just doing low pass filtering. I am wondering if it is > possible to do kalman filtering with just an accelerometer. Let's say I am > just concerning in position and velocitly in 1d space for now. > > I am a little confused what ithe input u in x(t+1) = Ax(t) + Bu(t) + w > equation and what the output y in y(x) = Cx(t) + n should be. > > People said y is supposed to be the measurement, so is it the > accelerometer reading? If my x(t) is [pos vel], then what is u(t)? > > Would be nice if someone can tell me what is A, B, C, x and y be > Your reply is greatly appreciated
Your x vector should probably be acceleration velocity position (assuming 1D, otherwise, for 2D you'll need two of each). Your model is then: position_{k+1} = position_{k} + velocity_{k} + 1/2*acceleration_{k} velocity_{k+1} = velocity_{k} + acceleration_{k} acceleration_{k+1} = acceleration_{k} assuming unit time intervals between samples, otherwise it's more like position_{k+1} = position_{k} + T*velocity_{k} + T^2/2*acceleration_{k} velocity_{k+1} = velocity_{k} + T*acceleration_{k} acceleration_{k+1} = acceleration_{k} That makes your state transition matrix (A): [ 1 1 1/2 ] [ 0 1 1 ] [ 0 0 1 ] or [ 1 T T^2/2 ] [ 0 1 T ] [ 0 0 1 ] Note that I'm taking a discrete-only approach to this, rather than correctly modelling the underlying continuous-time system. Depending on your application, you might have to do this for better fidelity. What should be your B matrix? That depends on whether you expect your object to have abrupt changes in position and velocity that are NOT driven by acceleration directly. One choice is: [ 1 ] [ 1 ] [ 1 ] If you're measuring the acceleration, then this makes the C matrix [ 1 0 0 ] that makes y look like acceleration + noise, which is probably what you're after. Ciao, Peter K.
Thanks for your post.

It is very helpful

If B is [1 1 1], then p = p + vt + 1/2 a t^2 + u? What is u?

> What should be your B matrix? That depends on whether you expect your
object to have abrupt changes in position and velocity that are NOT driven by acceleration directly. One choice is: Can you elabarate more? Terence This message was sent using the Comp.DSP web interface on www.DSPRelated.com
blackmangoes wrote:

> > Thanks for your post. > > It is very helpful >
No wuckers.
> If B is [1 1 1], then p = p + vt + 1/2 a t^2 + u? What is u?
u is (are? :-) the process noise. This is the "driving force" behind your underlying process. If your object is just being accelerated by its own drive, then a B of [0 0 1] would probably be OK. If your object is having its velocity affected by outside influences ONLY, then a B of [0 1 0] would be OK. If your object is hitting obstacles at particular places and this is the ONLY effect on p/v/a, then [1 0 0]. A more likely scenario is that your system is being influenced by all three (to a greater or lesser extent). Choosing B as [1 1 1] allows you to change the relative importances of each noise term by judicious choice of the covariance of u (which you will need to know in order to implement the Kalman filter).
> > What should be your B matrix? That depends on whether you expect your > object to have abrupt changes in position and velocity that are NOT > driven by acceleration directly. One choice is: > > Can you elabarate more?
See above. Ciao, Peter K.
but what are the sources of the correlation, typically?

I'm not (on purpose) bandlimiting the 64x signal BW noise in the analog
front end so consecutive samples shouldn't be identical, is there other
correlations I should be considering?

Don't ya hate following up to your own post?

Peter K. wrote:

> Choosing B as [1 1 1] allows you to change the relative importances of > each noise term by judicious choice of the covariance of u (which you > will need to know in order to implement the Kalman filter).
I'm wondering whether it might be better to have B as a square matrix, and u as a 3 x 1 vector of noises.... Hmm. Ciao, Peter K.
Okay
Somehow I thought wk is the noise with mean equal to 0

Are we comparing the the old estimated acceleration and the measured
acceleation from accelerometer? If so, the state will just be acceleration
then. 

Is B in my Kalman Gain equation? where B is

x_{k+1} = A x_{k} + B u_{k} + w_{k}

then the next estimation is 
\hat x_{k+1} = A \hat x_{k} +B \hat u_{k} + K (y - C \hat x_{k})

So if u_{k} is the noise, what do I put there?
If w_{k} is the noise, what is u_{k} and B?

		
This message was sent using the Comp.DSP web interface on
www.DSPRelated.com
steve wrote:
> but what are the sources of the correlation, typically? > > I'm not (on purpose) bandlimiting the 64x signal BW noise in the analog > front end so consecutive samples shouldn't be identical, is there other > correlations I should be considering?
You better bandlimit the signal to conform to the higher sample rate. And if you rely only on the averager to bring the bandwidth down to the final sample rate, aliasing will be pretty evident. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������