Android 加速度计精度(惯性导航)

发布于 2024-12-11 01:45:54 字数 425 浏览 2 评论 0原文

我正在考虑为 Android 手机实现惯性导航系统,但我意识到考虑到加速度计的精度和读数的持续波动,这很难。

首先,我将手机放在平坦的表面上,并在 X 和 Y 方向上采样了 1000 个加速度计读数(与桌子平行,因此这些方向上没有重力作用)。然后,我对这些读数进行平均,并使用该值来校准手机(从每个后续读数中减去该值)。

然后,我再次将系统放在桌子上并在 X 和 Y 方向上采样 5000 个加速度计读数来测试系统。我预计,考虑到校准,这些加速度在每个方向上加起来应该为 0(大致)。然而,情况并非如此,超过 5000 次迭代的总加速度远不接近 0(每个轴上平均约为 10)。

我意识到,如果没有看到我的代码,这可能很难回答,但从更一般的意义上来说...

这只是手机(HTC Desire S)上的加速度计读数有多不准确的一个例子,还是更有可能是我我的编码中犯了一些错误?

I was looking into implementing an Inertial Navigation System for an Android phone, which I realise is hard given the accelerometer accuracy, and constant fluctuation of readings.

To start with, I set the phone on a flat surface and sampled 1000 accelerometer readings in the X and Y directions (parallel to the table, so no gravity acting in these directions). I then averaged these readings and used this value to calibrate the phone (subtracting this value from each subsequent reading).

I then tested the system by again placing it on the table and sampling 5000 accelerometer readings in the X and Y directions. I would expect, given the calibration, that these accelerations should add up to 0 (roughly) in each direction. However, this is not the case, and the total acceleration over 5000 iterations is nowhere near 0 (averaging around 10 on each axis).

I realise without seeing my code this might be difficult to answer but in a more general sense...

Is this simply an example of how inaccurate the accelerometer readings are on a mobile phone (HTC Desire S), or is it more likely that I've made some errors in my coding?

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

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

发布评论

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

评论(6

挽梦忆笙歌 2024-12-18 01:45:54

您可以通过对线性加速度进行两次积分来获得位置,但是误差非常可怕。它在实践中毫无用处。

这是原因的解释(Google 技术讲座) 23:20。我强烈推荐这个视频。

导致问题的不是加速度计噪声,而是 陀螺仪白噪声,参见 6.2.3 误差传播小节。 (顺便说一句,您也需要陀螺仪。)

至于室内定位,我发现这些很有用:

使用 Sigma-Point 卡尔曼进行基于 RSSI 的室内定位和跟踪平滑器

使用安装在鞋上的惯性传感器进行行人跟踪

使用单个加速度计增强计步器的性能

我不知道这些如何方法将在现实应用程序中执行,或者如何将它们变成一个漂亮的 Android 应用程序。

类似的问题是这个

更新:

显然有一个比上述奥利弗·J·伍德曼(Oliver J. Woodman)更新的版本,“惯性导航简介”,他的博士论文:

室内环境行人定位

You get position by integrating the linear acceleration twice but the error is horrible. It is useless in practice.

Here is an explanation why (Google Tech Talk) at 23:20. I highly recommend this video.

It is not the accelerometer noise that causes the problem but the gyro white noise, see subsection 6.2.3 Propagation of Errors. (By the way, you will need the gyroscopes too.)

As for indoor positioning, I have found these useful:

RSSI-Based Indoor Localization and Tracking Using Sigma-Point Kalman Smoothers

Pedestrian Tracking with Shoe-Mounted Inertial Sensors

Enhancing the Performance of Pedometers Using a Single Accelerometer

I have no idea how these methods would perform in real-life applications or how to turn them into a nice Android app.

A similar question is this.

UPDATE:

Apparently there is a newer version than the above Oliver J. Woodman, "An introduction to inertial navigation", his PhD thesis:

Pedestrian Localisation for Indoor Environments

樱&纷飞 2024-12-18 01:45:54

我只是在大声思考,而且我还没有使用过 Android 加速计 API,所以请耐心等待。

首先,传统上,要通过加速度计进行导航,您需要一个 6 轴加速度计。您需要 X、Y 和 Z 方向的加速度,还需要 Xr、Yr 和 Zr 的旋转。如果没有旋转数据,您就没有足够的数据来建立矢量,除非您假设设备永远不会改变其姿态,这将是相当有限的。无论如何,没有人会阅读 TOS。

哦,你知道 INS 会随着地球的自转而漂移,对吗?所以也有这样的。一小时后,您神秘地爬上 15° 的斜坡进入太空。假设你有一个 INS 能够保持位置那么长时间,而手机还无法做到这一点。

利用加速度计(即使是 3 轴加速度计)进行导航的更好方法是尽可能与 GPS 结合来校准 INS。 GPS 的不足之处,INS 可以很好地弥补。 GPS 可能会因为您离树太近而突然将您射出 3 个街区之外。 INS 不太好,但至少它知道你没有被流星击中。

您可以做的是记录手机加速计数据,以及大量数据。就像几周的价值。将其与好的(我的意思是非常好的)GPS 数据进行比较,并使用数据挖掘来建立加速度计数据和已知 GPS 数据之间的趋势相关性。 (专业提示:您需要在几何形状良好且有大量卫星的日子里检查 GPS 年历。有时您可能只有 4 颗卫星,而这还不够)您可能会发现,当一个人当他们把手机放在口袋里走路时,加速计数据会记录一个非常具体的模式。根据数据挖掘,您可以为该设备和该用户建立一个配置文件,以及当它具有 GPS 数据时该模式代表什么样的速度。您应该能够检测转弯、爬楼梯、坐下(校准到 0 速度时间!)以及各种其他任务。手机的握持方式需要完全被视为单独的数据输入。我闻到了神经网络被用来进行数据挖掘的味道。换句话说,有些东西对输入的含义视而不见。该算法只会寻找模式的趋势,而不会真正关注 INS 的实际测量结果。它所知道的只是历史上,当这种模式发生时,设备正在以 2.72 m/s X、0.17m/s Y、0.01m/s Z 的速度移动,因此设备现在肯定正在这样做。 它将相应地向前推进该作品。重要的是,它是完全盲目的,因为只要将手机放入口袋中,就可能会定向到 4 个不同方向之一,如果你切换口袋,则可能会定向到 8 个方向。握持手机的方式也有很多种。我们在这里谈论很多数据。

显然你仍然会有很多漂移,但我认为这样你会运气更好,因为设备会知道你何时停止行走,并且位置漂移不会永久存在。根据历史数据,它知道您处于静止状态。传统的INS系统不具备此功能。这种漂移会以指数方式延续到所有未来的测量和化合物中。对于传统的 INS 来说,极高的精度或定期检查辅助导航绝对至关重要。

每个设备、每个人都必须有自己的个人资料。这是大量的数据和大量的计算。每个人走路的速度、步数都不同,并将手机放在不同的口袋里等等。当然,要在现实世界中实现这一点,需要在服务器端处理数字运算。

如果您确实使用 GPS 作为初始基线,部分问题是 GPS 往往会随着时间的推移而产生自己的迁移,但它们是非永久性错误。将接收器放在一个位置并记录数据。如果没有 WAAS 修正,您可以轻松获得在您周围 100 英尺范围内随机方向漂移的位置修正。使用 WAAS,可能会低至 6 英尺。实际上,如果你在背包上安装亚米级 RTK 系统,那么你的运气可能会更好,至少可以记录下 ANN 的算法。

使用我的方法,INS 仍然会产生角度漂移。这是一个问题。但是,如果您到目前为止构建了一个 ANN,在 n 个用户中倾注了数周的 GPS 和 INS 数据,并且实际上让它工作到了这一点,那么到目前为止您显然不介意大数据。继续沿着这条路走下去,并使用更多数据来帮助解决角度漂移:人是习惯的生物。我们几乎做同样的事情,比如在人行道上行走、穿过门、上楼梯,但不会做疯狂的事情,比如穿过高速公路、穿过墙壁或离开阳台。

假设您正在从“老大哥”那里获取信息并开始存储有关人们去向的数据。您可以开始绘制人们预计行走的位置的地图。可以肯定的是,如果用户开始走上楼梯,她就和她前面的人走在同一个楼梯底部。经过 1000 次迭代和一些最小二乘调整后,您的数据库几乎非常准确地知道这些楼梯在哪里。现在,您可以在人开始行走时纠正角度漂移和位置。当她走上楼梯,或转入大厅,或沿着人行道行走时,任何偏差都可以得到纠正。您的数据库将包含根据一个人走到那里或该用户过去曾经走过那里的可能性进行加权的扇区。空间数据库为此进行了优化,使用分而治之的方式仅分配有意义的扇区。这有点像麻省理工学院的项目,配备激光的机器人从黑色图像开始,通过每次转弯在记忆中绘制迷宫,照亮所有墙壁的位置。

高流量的区域将获得更高的权重,而没有人去过的区域的权重为 0。交通量较高的区域具有较高的分辨率。您最终会得到一张包含任何人去过的任何地方的地图,并将其用作预测模型。

如果您可以使用这种方法确定一个人在剧院中的座位,我不会感到惊讶。如果有足够多的用户去剧院,并且有足够的分辨率,您将获得映射剧院每一行的数据以及每行的宽度。访问某个位置的人越多,您预测该人所在位置的保真度就越高。

另外,如果您对此类内容的当前研究感兴趣,我强烈建议您(免费)订阅《GPS World》杂志。每个月我都会用它来探索。

I am just thinking out loud, and I haven't played with an android accelerometer API yet, so bear with me.

First of all, traditionally, to get navigation from accelerometers you would need a 6-axis accelerometer. You need accelerations in X, Y, and Z, but also rotations Xr, Yr, and Zr. Without the rotation data, you don't have enough data to establish a vector unless you assume the device never changes it's attitude, which would be pretty limiting. No one reads the TOS anyway.

Oh, and you know that INS drifts with the rotation of the earth, right? So there's that too. One hour later and you're mysteriously climbing on a 15° slope into space. That's assuming you had an INS capable of maintaining location that long, which a phone can't do yet.

A better way to utilize accelerometers -even with a 3-axis accelerometer- for navigation would be to tie into GPS to calibrate the INS whenever possible. Where GPS falls short, INS compliments nicely. GPS can suddenly shoot you off 3 blocks away because you got too close to a tree. INS isn't great, but at least it knows you weren't hit by a meteor.

What you could do is log the phones accelerometer data, and a lot of it. Like weeks worth. Compare it with good (I mean really good) GPS data and use datamining to establish correlation of trends between accelerometer data and known GPS data. (Pro tip: You'll want to check the GPS almanac for days with good geometry and a lot of satellites. Some days you may only have 4 satellites and that's not enough) What you might be able to do is find that when a person is walking with their phone in their pocket, the accelerometer data logs a very specific pattern. Based on the datamining, you establish a profile for that device, with that user, and what sort of velocity that pattern represents when it had GPS data to go along with it. You should be able to detect turns, climbing stairs, sitting down (calibration to 0 velocity time!) and various other tasks. How the phone is being held would need to be treated as separate data inputs entirely. I smell a neural network being used to do the data mining. Something blind to what the inputs mean, in other words. The algorithm would only look for trends in the patterns, and not really paying attention to the actual measurements of the INS. All it would know is historically, when this pattern occurs, the device is traveling and 2.72 m/s X, 0.17m/s Y, 0.01m/s Z, so the device must be doing that now. And it would move the piece forward accordingly. It's important that it's completely blind, because just putting a phone in your pocket might be oriented in one of 4 different orientations, and 8 if you switch pockets. And there's many ways to hold your phone, as well. We're talking a lot of data here.

You'll obviously still have a lot of drift, but I think you'd have better luck this way because the device will know when you stopped walking, and the positional drift will not be a perpetuating. It knows that you're standing still based on historical data. Traditional INS systems don't have this feature. The drift perpetuates to all future measurements and compounds exponentially. Ungodly accuracy, or having a secondary navigation to check with at regular intervals, is absolutely vital with traditional INS.

Each device, and each person would have to have their own profile. It's a lot of data and a lot of calculations. Everyone walks different speeds, with different steps, and puts their phones in different pockets, etc. Surely to implement this in the real world would require number-crunching to be handled server-side.

If you did use GPS for the initial baseline, part of the problem there is GPS tends to have it's own migrations over time, but they are non-perpetuating errors. Sit a receiver in one location and log the data. If there's no WAAS corrections, you can easily get location fixes drifting in random directions 100 feet around you. With WAAS, maybe down to 6 feet. You might actually have better luck with a sub-meter RTK system on a backpack to at least get the ANN's algorithm down.

You will still have angular drift with the INS using my method. This is a problem. But, if you went so far to build an ANN to pour over weeks worth of GPS and INS data among n users, and actually got it working to this point, you obviously don't mind big data so far. Keep going down that path and use more data to help resolve the angular drift: People are creatures of habit. We pretty much do the same things like walk on sidewalks, through doors, up stairs, and don't do crazy things like walk across freeways, through walls, or off balconies.

So let's say you are taking a page from Big Brother and start storing data on where people are going. You can start mapping where people would be expected to walk. It's a pretty sure bet that if the user starts walking up stairs, she's at the same base of stairs that the person before her walked up. After 1000 iterations and some least-squares adjustments, your database pretty much knows where those stairs are with great accuracy. Now you can correct angular drift and location as the person starts walking. When she hits those stairs, or turns down that hall, or travels down a sidewalk, any drift can be corrected. Your database would contain sectors that are weighted by the likelihood that a person would walk there, or that this user has walked there in the past. Spatial databases are optimized for this using divide and conquer to only allocate sectors that are meaningful. It would be sort of like those MIT projects where the laser-equipped robot starts off with a black image, and paints the maze in memory by taking every turn, illuminating where all the walls are.

Areas of high traffic would get higher weights, and areas where no one has ever been get 0 weight. Higher traffic areas are have higher resolution. You would essentially end up with a map of everywhere anyone has been and use it as a prediction model.

I wouldn't be surprised if you could determine what seat a person took in a theater using this method. Given enough users going to the theater, and enough resolution, you would have data mapping each row of the theater, and how wide each row is. The more people visit a location, the higher fidelity with which you could predict that that person is located.

Also, I highly recommend you get a (free) subscription to GPS World magazine if you're interested in the current research into this sort of stuff. Every month I geek out with it.

落日海湾 2024-12-18 01:45:54

我不确定你的偏移量有多大,因为你忘记包括单位。 (“每个轴上大约 10 个”并没有说明太多。:P)也就是说,这仍然可能是由于硬件不准确造成的。

加速度计非常适合确定手机相对于重力的方向或检测手势(摇动或碰撞手机等)。

但是,尝试使用加速度计进行航位推算将使您遇到很多复合误差。否则,加速度计需要非常精确,而且这不是常见的用例,所以我怀疑硬件制造商是否正在针对它进行优化。

I'm not sure how great your offset is, because you forgot to include units. ("Around 10 on each axis" doesn't say much. :P) That said, it's still likely due to inaccuracy in the hardware.

The accelerometer is fine for things like determining the phone's orientation relative to gravity, or detecting gestures (shaking or bumping the phone, etc.)

However, trying to do dead reckoning using the accelerometer is going to subject you to a lot of compound error. The accelerometer would need to be insanely accurate otherwise, and this isn't a common use case, so I doubt hardware manufacturers are optimizing for it.

手心的海 2024-12-18 01:45:54

Android 加速度计是数字的,它使用相同数量的“桶”对加速度进行采样,假设有 256 个桶,并且加速度计能够感应 -2g 到 +2g。这意味着您的输出将根据这些“桶”进行量化,并且会围绕某些值集跳跃。

要校准 Android 加速计,您需要对 1000 多个点进行采样,并找到加速计波动的“模式”。然后根据输出波动的程度找到数字点的数量,并将其用于过滤。

一旦获得众数和 +/- 波动,我建议进行卡尔曼滤波。

Android accelerometer is digital, it samples acceleration using the same number of "buckets", lets say there are 256 buckets and the accelerometer is capable of sensing from -2g to +2g. This means that your output would be quantized in terms of these "buckets" and would be jumping around some set of values.

To calibrate an android accelerometer, you need to sample a lot more than 1000 points and find the "mode" around which the accelerometer is fluctuating. Then find the number of digital points by how much the output fluctuates and use that for your filtering.

I recommend Kalman filtering once you get the mode and +/- fluctuation.

那片花海 2024-12-18 01:45:54

我意识到这已经很老了,但是所给出的任何答案都没有解决当前的问题。

您看到的是设备的线性加速度,包括重力的影响。如果您将手机放在平坦的表面上,传感器将报告重力加速度,约为 9.80665 m/s2,因此给出您所看到的 10。传感器不准确,但也不是那么不准确!请参阅此处,获取有关您可能需要的传感器的一些有用链接和信息。

I realise this is quite old, but the issue at hand is not addressed in ANY of the answers given.

What you are seeing is the linear acceleration of the device including the effect of gravity. If you lay the phone on a flat surface the sensor will report the acceleration due to gravity which is approximately 9.80665 m/s2, hence giving the 10 you are seeing. The sensors are inaccurate, but they are not THAT inaccurate! See here for some useful links and information about the sensor you may be after.

岁月静好 2024-12-18 01:45:54

您假设 X 和 Y 方向上的加速度计读数(在本例中完全是硬件噪声)将在平均值周围形成正态分布。显然事实并非如此。

您可以尝试的一件事是将这些值绘制在图表上,看看是否出现任何模式。如果不是,那么噪声在统计上是随机的,并且无法校准——至少对于您的特定手机硬件而言。

You are making the assumption that the accelerometer readings in the X and Y directions, which in this case is entirely hardware noise, would form a normal distribution around your average. Apparently that is not the case.

One thing you can try is to plot these values on a graph and see whether any pattern emerges. If not then the noise is statistically random and cannot be calibrated against--at least for your particular phone hardware.

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