检测汽车加速度(iPhone加速度计) [英] Detecting Acceleration in a car (iPhone Accelerometer)

查看:301
本文介绍了检测汽车加速度(iPhone加速度计)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一款iPhone应用程序,我们正在尝试计算移动汽车的加速度。类似的应用程序已完成此操作(Dynolicious),但不同之处在于此应用程序旨在用于一般城市驾驶,而不是拖动条。

I am working on an iPhone app where we are trying to calculate the acceleration of a moving car. Similar apps have accomplished this (Dynolicious), but the difference is that this app is designed to be used during general city driving, not on a drag strip.

这引导我们令人担忧的是,Dynolicious幸运地能够避免:丘陵。是的,丘陵。

This leads us to one big concern that Dynolicious was luckily able to avoid: hills. Yes, hills.

这有两个重要的阶段:校准和实际驾驶。

There are two important stages to this: calibration, and actual driving.

我们的初始奔跑很简单并且遭受了后果。在校准阶段,我在手机上取平均力,在跑步过程中,我只是从当前力中减去平均力,以获得此帧的当前加速度。问题在于,典型的汽车获得的力量远远超过向前的力量 - 从转向坑洼的一切都导致价值与实际发生的事情不同步。

Our initial run was simple and suffered the consequences. During the calibration stage, I took the average force on the phone, and during running, I just subtracted the average force from the current force to get the current acceleration this frame. The problem with this is that the typical car receives much more force than just the forward force - everything from turning to potholes was causing the values to go out of sync with what was really happening.

下一步是为了增加iPhone必须以屏幕朝向汽车后部的方式定向的条件。使用这种方法,我试图仅在z轴上使用力,但这显然会导致问题,除非iPhone由于重力而直接朝向直立。

The next run was to add the condition that the iPhone must be oriented in such a way that the screen was facing toward the back of the car. Using this method, I attempted to follow only force on the z-axis, but this obviously lead to problems unless the iPhone was oriented directly upright, because of gravity.

一些三角运动之后,我已经设法将重力运转到了等式之外,因此iPhone实际上正在非常,非常好地读取汽车。

Some trigonometry later, and I had managed to work gravity out of the equation, so that the car was actually being read very, very well by the iPhone.

直到我击中了坡。一旦汽车的角度发生变化,我突然接到了没有意义的加速和减速,我们又一次不同步。

Until I hit a slope. As soon as the angle of the car changed, suddenly I was receiving accelerations and decelerations that didn't make sense, and we were once again going out of sync.

说话与数学上比我更聪明的人导致我一直试图实施的解决方案比我想承认的更长。它的步骤如下:

Talking with someone a lot smarter than me at math lead to a solution that I have been trying to implement for longer than I would like to admit. It's steps are as follows:

1)在校准过程中,将重力测量为矢量而不是大小。存储该矢量。
2)当汽车最初向前移动时,采取运动矢量并减去重力。将此作为前进动力。 (暂时忽略那些困难的用户案例,让我们专注于数学:)
3)从前向量和重力向量构造一个平面。
4)每当收到一支部队时,将其投射到所述飞机上以摆脱侧向力/等。
5)然后,使用该力,已知的重力大小和已知的前向运动方向来基本上求解三角形以获得前向矢量。

1) During calibration, measure gravity as a vector instead of a size. Store that vector. 2) When the car initially moves forward, take the vector of motion and subtract gravity. Use this as the forward momentum. (Ignore, for now, the user cases where this will be difficult and let's concentrate on the math :) 3) From the forward vector and the gravity vector, construct a plane. 4) Whenever a force is received, project it onto said plane to get rid of sideways force/etc. 5) Then, use that force, the known magnitude of gravity, and the known direction of forward motion to essentially solve a triangle to get the forward vector.

在这个新系统中造成最大困难的问题不是第5步,我已经达到了所有数字看起来应该如此的程度。困难的部分实际上是前向矢量的检测。我正在选择幅度超过重力的矢量,并从那里平均它们并减去重力。 (我正在做一些错误检查,以确保我没有使用强制因为iPhone加速度计稍微关闭,这比我想要的更频繁)。但是,如果我绘制我正在使用的这些矢量,它们实际上会以大约20-30度的角度变化,这可能会导致一些强烈的不准确性。最终的结果是应用程序现在比以前更加不准确。

The problem that is causing the most difficulty in this new system is not step 5, which I have gotten to the point where all the numbers look as they should. The difficult part is actually the detection of the forward vector. I am selecting vectors whose magnitude exceeds gravity, and from there, averaging them and subtracting gravity. (I am doing some error checking to make sure that I am not using a force just because the iPhone accelerometer was off by a bit, which happens more frequently than I would like). But if I plot these vectors that I am using, they actually vary by an angle of about 20-30 degrees, which can lead to some strong inaccuracies. The end result is that the app is even more inaccurate now than before.

所以基本上 - 你所有的数学和iPhone都在那里 - 任何明显的错误?还有更好的解决方案吗任何可能有用的经验?

So basically - all you math and iPhone brains out there - any glaring errors? Any potentially better solutions? Any experience that could be useful at all?

奖励:在第一个答案中提供250美元的赏金,以获得解决方案。

Award: offering a bounty of $250 to the first answer that leads to a solution.

推荐答案

你需要一个陀螺仪。否则,在山坡上有多种加速汽车的配置,可以在加速度计上产生完全相同的读数。他们将完全无法区分。这就是惯性导航系统结合陀螺仪和加速度计的原因。

You need a gyro. Otherwise there are multiple configurations of an accelerating car on a hill that can give rise to exactly the same readings on an accelerometer. They will be completely impossible to distinguish. That's why inertial navigation systems combine a gyro and accelerometer.

爱因斯坦给出了你无法做到这一点的原因!使用局部测量,您无法区分重力和加速度。你确实有一些有用的非本地信息 - 假设这里的引力和那里几码的引力具有相同的值。但你无法在两个不同的位置比较重力,而无法进行所谓的平行运输。这就是陀螺仪所做的事情。

The reason you can't do this was given by Einstein! Using a local measurement, you can't distinguish between gravity and acceleration. You do have some useful non-local information - the assumption that gravity here, and gravity a few yards over there, have the same value. But you can't compare gravity in two different locations without a means to carry out what's called "parallel transport". This is what a gyro does.

忘记250美元,但我认为你应该给我一杯啤酒,因为我节省了你的研发时间。 : - )

Forget the $250, but I think you should give me a beer for the amount of R&D time I'm saving you. :-)

这篇关于检测汽车加速度(iPhone加速度计)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆