How to/Should I implement a Kalman filter to get accurate Accelerometer data?

26,899

A Kalman filter applies when all measurements (of acceleration in this case) are equal to the true value plus a measurement error. The measurement error is the process noise. For for the original Kalman filter to apply the noise must be normally distributed, i.e. sometimes the error will be positive, sometimes negative, and on average zero.

If you jerk your android phone quickly back and forth, there'll be large accelerations. I'd suggest recording the accelerometer readings in that kind of action, and reviewing by eye to see whether it looks like there's the readings are indeed subject to some kind of normally distributed process noise. My guess is that the answer will be "No", i.e. I expect they readings when plotted on a graph will be smooth-ish. But if they're not smooth, a Kalman filter could be useful.

If you're trying to use accelerometer readings to work out location, I think your project is doomed to failure. Acceleration is the 2nd derivative of position with respect to time, and I've never heard of anyone being able to integrate the readings with sufficient accuracy to be at all useful.

I have applied a Kalman filter successfully to GPS readings on an Android phone to improve the location estimate. See Smooth GPS data for code that implements a Kalman filter for that. I subsequently wondered whether velocity and perhaps acceleration data could be used to improve the location estimate. Although I never followed up on that idea, see https://dsp.stackexchange.com/questions/8860/more-on-kalman-filter-for-position-and-velocity for the maths that I was considering using.

The optimal way of using all the sensor inputs (GPS, accelerometer, gyroscope, etc) to get a good estimate of location is a very hard (and interesting) problem. To find out more, the key phrase to search for is "Sensor fusion". On this subject, there's an old youtube video at http://www.youtube.com/watch?v=C7JQ7Rpwn2k .

Share:
26,899
Kersch
Author by

Kersch

Updated on July 17, 2022

Comments

  • Kersch
    Kersch almost 2 years

    I want to get as accurate data from the built in accelerometer in an Android phone as possible. I want to track two dimensional movement in x and y axis and even the small movements must be registered.

    When I look at the data from the accelerometer / linear acceleration when the phone is flat on a table it changes a lot when i should be zero.

    I have looked at Kalman filters, it seems like a good approach but I am having problems setting up a model.

    1. Is a Kalman filter the way to go to get as accurate data as possible from an accelerometer?

    2. Will a Kalman filter work? Maybe i have misunderstood but it seems like the acceleration or the velocity must be constant?

    3. How do I set up the model for using Kalman filter? I'm having trouble understanding (among other things) what the process noise is?

  • Kersch
    Kersch about 10 years
    Hello! Thank you for your answer. This is the output from the x-axis on the accelerometer sensor when it is lying flat on a table. s15.postimg.org/amcypa83v/Fig1.jpg The right plot is the raw output data and the left is when I try applying a simple kalman filter to the output. The left output does not seem very smooth or what do you think?
  • Stochastically
    Stochastically about 10 years
    I'm not sure what motion the device was experiencing to give those readings, but presumably many many quick flicks back and forth. For that kind of motion, the acceleration would have been positive and negative, which is what the graph on the right shows. If so, that means that your filter isn't doing anything sensible, because it's smoothing out your data to something that's always slightly positive.
  • Kersch
    Kersch about 10 years
    There was no motion added to the device in that Reading. The device was laying still on a table. So the Reading should hade been zero.
  • Stochastically
    Stochastically about 10 years
    @Kersch in which case, the readings are exactly what process noise is, i.e. random fluctuations that (to my eye at least) look as though they're approximately zero on average. Also, relative to the maximum readings, the Kalman filtered value is roughly zero too. The thing that's unclear to me is how significant that noise is, because I'm not sure how big the accelerometer values are when it's moving. If they're of the order of 100, then noise which is of the order of 0.3 is reasonable. but if the accelerometer values are around 5, then the noise is much more problematic!