Android 中有没有一种方法可以在没有 GPS 的情况下获取速度?
Android 中有没有一种方法可以在没有 GPS 的情况下获取速度?我不需要准确的值。
Is there a way to get the velocity without GPS in Android? I don't need the accurate values.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯,有点,但你需要做很多处理..
你可以频繁读取加速度计读数和将这些值积分一次即可获得速度。这不会为您提供准确的启动速度,但一段时间后它可能会起作用(除非您在手机在汽车中行驶时启动)。另请参阅这篇文章。
现在,一些伪代码:
我们从
t=0
开始并测量所有三个轴的加速度。这样做几秒钟后,所有加速度值的总和(如果采样频繁,即 50Hz)应该是速度。您还需要计算出您的设备处于哪个方向,因此您正在读取的加速度分量有多少是由于重力和补偿造成的。
Well, sort of, but you will need to do alot of processing..
You can make frequent accelerometer readings and integrate the values once to get velocity. This won't get you an accurate starting velocity but after a while it will probably work (unless you start when the phone is driving along in a car). See also this post.
Now, some pseudo code:
We start at
t=0
and measure acceleration in all three axis.After doing this for a few seconds, the sum of all the acceleration values (if you sample frequently, ie, 50Hz) should be velocity. You will also need to work out which way up your device is and therefore how much of the acceleration components you are reading is due to gravity and compensate.