Linear Accelerometer has inaccurate values

Started by Yerst, July 18, 2013, 09:35:08 PM

Previous topic - Next topic

Yerst

Hey!
I have a object infront of my camera that is controlled by the linear accelerometer.
Unfortunaly, the object trembles always, even if i hold my phone completely still and this really hurts my eyes.
Does anyone know how to remove this trembling?
I tried rounding the values given by the sensor, but then it trembles when switching between for example 0.09 and 0.1...

EgonOlsen


Yerst

That's what i need, but i don't know how to implement it.
It is maybe just one or two lines to do it, but i don't get it to work.
Maybe i just think to complicated.

ned flanders

Along similar lines, sounds like you might benefit from that "sensor fusion" stuff all the cool kids are talking about.

I've yet to find any APIs for it yet, but I stumbled across some code somewhere that looks promising.

Anyway, here's a link in case you haven't come across this yet:

http://www.youtube.com/watch?v=C7JQ7Rpwn2k

EgonOlsen

Quote from: Yerst on July 18, 2013, 11:44:39 PM
That's what i need, but i don't know how to implement it.
It is maybe just one or two lines to do it, but i don't get it to work.
I would try to define some threshold (0.xy...) and ignore changes below this value. Once a higher value occurs, i would start to move the model and stop again once i fall below the threshold for some time. I've no idea if this is applicable to this kind of sensor though.

Yerst

I tried it, but then the problem is when my object moves, it trembles while moving...

ned flanders

Have you tried a running average, maybe over a sliding window?

Yerst

Sorry, but i have no idea what you mean^^

ned flanders

Store successive values in a circular (ring) buffer.

This is like an array of limited size, say 10 entries, into which you store values as you receive them.  Once the buffer fills up (reaches 10 entries), as you add each new entry, the oldest entry is removed.  You can easily implement this with a standard array, and an index which resets to zero every time it reaches the end of the array.

Then, rather than use the jittery output values directly, you push them into the circular buffer, and use the buffer's average value.  I called this a running average, but if the average is over a sliding window of data (as with the ring buffer), then it's a moving average....a very simple way to smooth out jittery data a bit.

https://en.wikipedia.org/wiki/Moving_average

Yerst

Thanks, that worked great!
Even much better than expected!  ;D