Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 984
Registered: ‎03-20-2013
My Device: Red LE Developer Z10

Accelerometer jitter smoothing

[ Edited ]

I am starting initial experimentation for a new app, and this one will use several sensors, including the accelerometer. This sensor has significant jitter, even at perfect rest. so I am looking at ways to minimize this.

 

The accelerometer class has a skipDuplicates property, that when set to true not only doesn't report subsequent identical readings, but also similar readings, providing a measure of jitter reduction. The problem is this setting is too heavy-handed for my needs. Enabling it means that you have to change the device orientation in fairly large steps before the sensor reports any change.

 

I am considering using a sliding window average to smooth out the jitter. This way every reading is obtained from the sensor and inserted into a queue, then a fixed number of previous readings (say 10 or 100) are averaged with the new one, and the average value is used rather than the latest. This way instantaneous jitter is swamped out by the weight of the previous 10 or 100 readings.

 

Alternately the raw readings could be fed to a digital low-pass filter to achieve a similar effect. My question is, has anyone else wrestled with this question and come up with a better solution?

 

EDIT: I referred to this problem as "jitter" because I found several posts and articles online that described it thus, but it occurred to me that calling this jitter is not really correct, the artifact that needs cleaning is more correctly described as "noise" so this is really a case of noise reduction.



Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.  multiFEED Icon

Play nice: Clicking Like Button on posts that helped you not only encourages others to continue sharing their experience, but also improves your own rating on this board. Also, don't forget to accept a post if it solves your problem or answers your question.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Accelerometer jitter smoothing

[ Edited ]

Try holding your hand steadier. :smileywink:

 

Sorry, couldn't resist, not my area of expertise however your 2nd approach looks good as long as you can accept the small loss in reaction time and accuracy that obviously comes from this approach.

 

... and if you can accept the above then have you experimented with just slowing down the reading anyway, say 1 out of 10 or 100.

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 984
Registered: ‎03-20-2013
My Device: Red LE Developer Z10

Re: Accelerometer jitter smoothing

 

@BBSJdev...I know your first line was a joke, but I do want to point out to other readers that the accelerometer turns out to be very noisy, and even sitting it stationary on a hard surface will produce readings that look like it is jumping slightly in all dimensions. (well, maybe not temporal.) :smileywink:

 

Regarding your final suggestion, the problem with just sampling less often is that the values will still jump all over the place even when stationary, you'll just get less frequent updates. Intuitively I'm leaning to the "sliding window average" approach since the fluctuations are all centred around the "correct" value and averaging should smooth them out. I'm going to test it and report back on the result, but I was hoping somebody might have done this before and save me from going down a blind alley (or two).

 

Hope you had a great Christmas.



Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.  multiFEED Icon

Play nice: Clicking Like Button on posts that helped you not only encourages others to continue sharing their experience, but also improves your own rating on this board. Also, don't forget to accept a post if it solves your problem or answers your question.