如何从GPS得到最准确的可能速度的Andr​​oid [英] How to get the most accurate possible speed from GPS in Android

查看:103
本文介绍了如何从GPS得到最准确的可能速度的Andr​​oid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能从GPS Android中一个精确的速度?
是的,我知道在位置类的<​​code> location.getSpeed​​()的方法。问题是,默认的实现返回0.0的速度:显然这是默认行为

目前什么我做,如下,考虑位置对象A和B,其中A为第一考虑,B后:

  a.distanceTo(B)/(b.getTime() -  a.getTime());

(简化可读性,历史原来的code的价格的ArrayList

问题是,这是有些不精确:在正常情况下,数据点是如此接近彼此,该全球定位系统误差确实成为一个问题。要么我需要减少更新频率或计算相对于一个点的速度渐行渐远。前者我并不想这样做,因为我想获得尽可能高的频率可能的,但也许我可以过滤点来计算对基于它们彼此的距离速度?
最佳的解决方案,这是我所承担的 getSpeed​​()方法会做,是计算速度对GPS卫星本身,从而获得更精确​​的结果。
我使用了 getSpeed​​()错不知何故?


解决方案

  

模拟器显然总是回答:0速度,但真正的设备
  不应该。你有没有在实际设备上同样的问题? - 斯特凡
  在8:21 3月20日


Stefan的回答竟是正确的。显然,模拟器不给速度,这不是在GPX文件输入作为测试数据包含。所以,如果你想展示一个真实的设备上的速度,测试和去慢跑,它会工作(对于大多数器件)。

下面是一些想法的检测速度等方法,但并非严格相关的,但如果你有GPS的工作可能是有趣的。

由于GPS的相对误差,尤其是在低速或弯曲道路的车速是很难计算:要么数据点之间的距离是如此之短的GPS误差来玩,还是那么长时间不用时,直动变得不准确。此外,如果数据点之间的最小距离来计算速度很长,在缓慢的速度更新间隔成为问题。
有解决此问题的方法,如使用getAccuracy()方法来计算数据点之间的最小安全距离,并动态使用它,基于最大加速度和减速度值,移动方向等过滤数据点。您还可以计算的滚动平均值平复的变化一点,得到的是什么什么是pretty好主意。

以上方法可能也有用,即使你基于覆盖的距离不计算速度,有时GPS似乎返回速度为0,甚至当你移动。我用从F1赛车的加速/减速人物如过滤器:)

How can I get an accurate speed from GPS in Android? Yes, I am aware of the location.getSpeed() method in the Location class. Problem is, the default implementation returns 0.0 as speed: apparently that is the default behavior.

What I'm currently doing, is as follows, consider location objects a and b, where a is taken first, b later:

a.distanceTo(b)/(b.getTime()-a.getTime());

(simplified for readability, original code deals with history ArrayList)

Problem is that this is somewhat inaccurate: under normal circumstances, the data points are so close to one another that the GPS inaccuracy really becomes an issue. Either I would need to reduce the update frequency or calculate the speed relative to a point further away. The former I don't want to do, as I want to get as high a frequency as possible, but perhaps I could filter the points to calculate speed against based on their distance to one another? The optimal solution, which I assumed the getSpeed() method would do, would be to calculate the speed against the GPS satellites themselves, thus getting a more accurate result. Am I using the getSpeed() wrong somehow?

解决方案

The emulator apparently always answers 0 as speed, but the real device should not. Do you have the same issue on the real device? – Stefan Mar 20 at 8:21

Stefan's answer was actually correct. Apparently the emulator does not give the speed, as that's not contained in the GPX file input as the testing data. So if you want to show speed, test on a real device and go for a jog, it'll work (for most devices).

Below are some thoughts for other methods of detecting speed, but not strictly relevant, but might be interesting if you're working with GPS.

Due to the relative inaccuracy of GPS, particularly at slow speeds or curvy roads the speed is hard to calculate: either the distance between data points is so short GPS inaccuracy comes to play, or so long it becomes inaccurate when not moving straight. Also, if the minimum distance between data points to calculate speed is long, at slow speeds the update interval becomes a problem. There are ways around this problem, such as using the getAccuracy() method to calculate minimum safe distance between data points and using it dynamically, filtering data points based on maximum acceleration and deceleration values, movement direction and so on. You can also calculate a rolling average to calm down the changes a little and get a pretty good idea of what's what.

The above methods may be useful also even if you don't calculate speed based on distance covered, as sometimes the GPS seems to return speed as 0, even when you're moving. I used acceleration/deceleration figures from F1 cars as filters :)

这篇关于如何从GPS得到最准确的可能速度的Andr​​oid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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