加速度计测量速度的负峰值

发布于 2024-11-19 14:32:46 字数 275 浏览 1 评论 0原文

我正在为 iphone4 编写一个应用程序,我正在从加速度计获取值来计算从已知初始位置开始的当前运动。

我注意到一种非常奇怪的行为:很多时候,当我拿着手机行走几米然后停下来时,当手机减速时,我会记录到总速度的负峰值。如果我继续朝同一个方向前进,这怎么可能呢?

为了计算速度的变化,我这样做:

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

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 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))

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

心碎的声音 2024-11-26 14:32:46

假设您以 10 m/s 的恒定速度移动。你的加速度为零。假设为了简单起见,您每 1 秒采样一次。

如果您在 0.1 秒的时间内平稳减速,您可能会得到 100 m/s/s 的读数,或者您可能根本得不到读数,因为减速度可能落在两个窗口之间。您的公式很可能不会检测到任何减速,或者如果检测到,您将得到两个 -50 m/s/s 的值:(0 - 100) / 2,然后是 (-100 + 0) / 2。无论哪种方式,您会得到错误的最终速度。

类似的事情几乎可以在任何规模上发生,你所需要的只是你碰巧采样的短时间内的高加速或减速,你的数字就被搞砸了。

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.

青衫负雪 2024-11-26 14:32:46

数值积分很难。噪声信号的简单数值积分本质上总是会产生显着的误差和漂移(就像您所看到的那样)。人们想出了各种巧妙的方法来处理这个问题,其中大多数都需要除了加速度计之外的一些参考信息源(想想 Wii 控制器,它不仅有加速度计,而且还有顶部的东西)电视)。

请注意,任何 MEMS 加速度计都必然限于仅报告特定范围的加速度;如果加速度超出该范围,那么您绝对会得到显着的漂移,除非您有某种方法来补偿它。最重要的是,加速度是作为离散量报告的,因此即使您不超出窗口,也必然存在一些近似误差和噪声。当您将所有这些因素加在一起时,一定程度的漂移是不可避免的。

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.

◇流星雨 2024-11-26 14:32:46

如果你向一个方向移动任何物体,就会产生一个使物体加速的力。

为了让物体再次停下来,需要在完全相反的方向上施加相同的力 - 或者更准确地说,需要将之前发生的加速度事件的向量乘以 -1 。那是你的负峰值。

严格来说,这不是一个编程问题,但话又说回来,您的问题并不是严格意义上的编程问题:)

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 :)

浊酒尽余欢 2024-11-26 14:32:46

如果它的行驶速度为每小时 1000 英里,则其加速度为 0。如果它正在超速行驶,则加速度为正。如果减速,则加速度为负。

如果需要,您可以使用速度的绝对数来反转任何负加速度:

fabs(delta_v); // use abs for ints

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文