Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kalman filter and quality of internal state variables

I am trying to develop motion detection application for Android. App should be able to track motion of phone in space and map it to motion on computer screen. I am using 3-axis accelerometer and since data is very noisy I am using Kalman filter.

Internal state is 6 component vector [speed-x, speed-y, speed-z, accel-x, accel-y, accel-z] and measured state is 3 component vector [accel-x, accel-y, accel-z].

Filter works very well on measured values, but speed is still very noisy.

Plotted values

Now I am wondering if this is normal behavior or am I doing something wrong, since my understanding of Kalman filter is very basic. I am using JKalman library and following state-transition matrix (dt is 1/15 which is approximate sensor refresh rate)

double[][] A = { { 1, 0, 0, dt, 0, 0 }, { 0, 1, 0, 0, dt, 0 }, { 0, 0, 1, 0, 0, dt }, { 0, 0, 0, 1, 0, 0 }, { 0, 0, 0, 0, 1, 0 }, { 0, 0, 0, 0, 0, 1 } };

I have also set up my own covariance matrices with covariances calculated from test data. This improved acceleration signal a bit, but had no effect on speed.

Currently I am able to achieve stdvar

[0,0632041857 0,0607274545 0,0886326602] for speed [x, y, z]

[0,0041689678 0,004423822 0,0074808552] for acceleration [x, y, z].

I am quite happy with acceleration signal and I guess i cannot improve it much more, but I would love to improve quality of speed signal.

like image 645
Andraz Avatar asked Feb 10 '12 15:02

Andraz


2 Answers

Won't work.

No matter what you do, the velocity will become extemely inaccurate in seconds. Although the answer at the above link is about position, the same holds for velocity. As for the Kalman filter see also here.

You should either try the GPS to get velocity or (if applicable) just use orientation of the phone in your app and give up on getting the velocity.

like image 67
Ali Avatar answered Oct 08 '22 05:10

Ali


I don't know much about Kalman filters except what I just read on Wikipedia, but I would say you are trying to apply Kalman filters in an inappropriate way.

The stdvars should represent only the noise, but I doubt that is what you computed. But more fundamentally, I think you lack some input data: Kalman filters are used when you have many different inputs, e.g. accelerometer + GPS.

It seems impossible --with Kalman or anything else-- that you could read in noisy accelerometer input and somehow get a smooth accurate trajectory. You could always do some kind of time-averaging of the accelerometer data, which would give you a smooth trajectory, but the trajectory would be different from the actual one. (If you want to try time-averaging: for example, a_smooth{i} = 0.6 a{i} + 0.3 a{i-1} + 0.1 a{i-2}.)

And there is the bigger problem that the precision of the accelerometer is very poor and you probably can't do much with it, especially keeping track of position, as answered by @Ali.

EDIT: I found some references on the web that have similar equations to yours, however those were for a Kalman filter used on a model with constant acceleration, which is obviously not what you want.

like image 40
toto2 Avatar answered Oct 08 '22 05:10

toto2