开发者

accelerometer measuring negative peaks of velocity

开发者 https://www.devze.com 2023-03-19 15:17 出处:网络
I\'m writing an application for iphone4 and I\'m taking values from the accelerometer to compute the current movement from a known initial position.

I'm writing an application for iphone4 and I'm taking values from the accelerometer to compute the current movement from a known initial position.

I've noticed a very strange behavior: often 开发者_Python百科times when I walk holding the cellphone for a few meters and then I stop, I register a negative peak of overall velocity when the handset decelarates. How is that possible if I keep moving in the same direction?

To compute the variation in velocity I just do this:

delta_v = (acc_previous + acc_now)/2 * (1/(updating_frequency))


Say you are moving at a constant 10 m/s. Your acceleration is zero. Let's say, for the sake of simplicity, you sample every 1 second.

If you decelerate smoothly over a period of 0.1 seconds, you might get a reading of 100 m/s/s or you might not get a reading at all since the deceleration might fall between two windows. Your formula most likely will not detect any deceleration or if it does, you'll get two values of -50 m/s/s: (0 - 100) / 2 and then (-100 + 0) / 2. Either way you'll get the wrong final velocity.

Something similar could happen at almost any scale, All you need is a short period of high acceleration or deceleration that you happen to sample and your figures are screwed.


Numerical integration is hard. Naive numerical integration of a noisy signal will essentially always produce significant errors and drift (like what you're seeing). People have come up with all sorts of clever ways to deal with this problem, most of which require having some source of reference information other than the accelerometer (think of a Wii controller, which has not only an accelerometer, but also the thingy on top of the TV).

Note that any MEMS accelerometer is necessarily limited to reporting only a certain band of accelerations; if acceleration goes outside of that band, then you will absolutely get significant drift unless you have some way to compensate for it. On top of that, there is the fact that the acceleration is reported as a discrete quantity, so there is necessarily some approximation error as well as noise even if you do not go outside of the window. When you add all of those factors together, some amount of drift is inevitable.


Well if you move any object in one direction, there's a force involved which accelerates the object.

To make the object come to a halt again, the same force is needed in the exact opposite direction - or to be more precise, the vector of the acceleration event that happened before needs to be multiplied with -1. That's your negative peak.

Not strictly a programming answer, but then again, your question is not strictly a programming question :)


If it's going a thousand miles per hour, its acceleration is 0. If it's speeding, the acceleration is positive. If it's slowing down, the acceleration is negative.

You can use the absolute number of the velocity to invert any negative acceleration, if that's needed:

fabs(delta_v); // use abs for ints
0

精彩评论

暂无评论...
验证码 换一张
取 消