简体   繁体   English

如何检测手机相对于移动方向的方向

[英]How to detect phone orientation relative to direction of movement

Problem: Consider an Android device mounted in a vehicle.问题:考虑安装在车辆中的 Android 设备。 We want to measure various things using the accelerometer.我们想使用加速度计测量各种事物。 These measurements should be relative to the vehicle's coordinate system.这些测量值应与车辆的坐标系相关。 Thus we need to figure out how the device is oriented in relation to the vehicle.因此,我们需要弄清楚设备相对于车辆的方向。 The simple solution would be to just average the "early" acceleration after startup, but I'm worried that the first thing the driver will do is leave a parking lot or a turning left onto the road, thus describing a curve.简单的解决方案是在启动后平均“早期”加速度,但我担心司机会做的第一件事是离开停车场或左转上路,从而描述曲线。 It would be feasible to ask the user to start measuring after getting on the road, but what if there is no acceleration at that point?让用户上路后开始测量是可行的,但如果此时没有加速度怎么办?

Question: Can someone suggest a strategy or an algorithm that would do a reasonable job of telling how the phone is oriented in relation to the vehicle?问题:有人可以提出一种策略或算法来合理地判断手机相对于车辆的方向吗? A pointer to some FOSS source that solves a similar problem would be even better.指向一些解决类似问题的 FOSS 源的指针会更好。

Notes:笔记:

  • I do not want to use GPS for this as it would complicate things for the user.我不想为此使用 GPS,因为这会使用户的事情变得复杂。
  • We can interact with the user, for example by requesting that the user starts measurements before starting out.我们可以与用户交互,例如通过请求用户在开始测量之前开始测量。

The accelerometer alone would not provide sufficient information for your purpose, I would hazard: The vectors acting upon the device, besides vehicle acceleration, will be the vibration of the vehicle itself, road inclines, braking and centripetal force from turns.单独的加速度计无法为您的目的提供足够的信息,我会冒险:除了车辆加速度之外,作用在设备上的矢量将是车辆本身的振动、道路坡度、制动和转弯产生的向心力。

The amount of data from sensors due to all those forces would be impractical to aggregate on a phone, hence moving averages or other cumulation approaches would not give even vaguely precise results.由于所有这些力,来自传感器的数据量在手机上汇总是不切实际的,因此移动平均值或其他累积方法甚至不会给出模糊精确的结果。

Also, a lot of the acceleration data would be lost between sensor sampling times, even if you were to use the highest available sensor rate.此外,即使您要使用最高可用传感器速率,传感器采样时间之间也会丢失大量加速度数据。

Recommendation: Use GPS or network positioning information, generate moving averages to account for minor aberrations, and use the result.建议:使用 GPS 或网络定位信息,生成移动平均值以解决轻微偏差,并使用结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM