Android的GPS定位速度不可靠 [英] Android GPS Location Speed Unreliable
问题描述
写一个GPS记录应用程序〜
我发现关于位置
报道<$ C $由 getSpeed()
方法的返回值C> LocationManager 有大量不可靠的。我使用 LocationManager.GPS_PROVIDER
,过滤通过 onLocationChanged
以获得最佳的精度提供的位置。即使在个位数的精度水平恢复速度一般高的离谱。我们谈论最多200 MP /小时(是的,我知道这是记录在米/秒)的时候,手机是静止的。
我测试两种不同型号的Android手机一样code基,运行两个不同的操作系统版本,并看到了同样的问题,所以我希望这是一个code问题。
我在想什么?我已经试过了一个时间窗口平均位置,但没有成功。我是不是有根据距离制定出自己的速度值行驶/时间?这将是令人失望的。
正如你所看到的,我没有做什么特别的东西 - 一个小的过滤精度,即使这两个 AverageSpeed
和 _bestLocation.getSpeed ()
定期unfeasibly高,即使在定位精度还是不错的。
公共无效onLocationChanged(位置定位){
如果(location.getAccuracy()&其中; 25F){
_recentLocations.add(位置);
如果(_bestLocation == NULL || location.getAccuracy()&LT; = _bestLocation.getAccuracy())
_bestLocation =位置;
}
如果((_bestLocation = NULL和放大器;!&安培; _bestLocation.getAccuracy()&LT; 10F和放大器;&安培; _recentLocations.size()&GT; = 10)
|| _recentLocations.size()&GT; = 25)
{
诠释计数= 0;
浮TotalSpeed = 0F;
浮AverageSpeed = 0F;
的for(int i = 0; I&LT; _recentLocations.size();我++){
如果(_recentLocations.get(ⅰ).hasSpeed()){
伯爵++;
TotalSpeed + = _recentLocations.get(ⅰ).getSpeed();
}
}
如果(计数大于0)
AverageSpeed = TotalSpeed /计数;
}
}
因为更多的则7年来我对GPS硬件工作过。精度读数也并非100%准确。 厂家说明准确性以及用于测量它的系统。 CEP,RMS,2DRMS,和R95是一些系统。 阅读这篇文章的详细信息: http://en.wikipedia.org/wiki/Circular_error_probable
精度数字不包括异常值。例如,如果规定的精度5米然后在良好信号条件下拍摄的读数将具有5米,95%的时间最大误差。没有什么可以说对剩下的5%的读数。防止这些 异常值是特制的酱汁,使一个良好的基于位置的应用程序从休息站出来。
有些事情你可以做的是:
- 筛选出疯狂的高速度。利用高度作为提示用于在飞机之中。
- 从运动传感器的信息关联起来,并看看他们是否认同 全球定位系统。运动传感器特征将处于稳定状态非常不同 而在运动。
- 在GSM / 3G小区的典型尺寸是下在城市一公里 地区和人口稀少地区5-10公里。如果 车辆正在高速移动时的一段时间和小区发射塔 信息仍然是一样的,你知道什么是错的。
- 是否需要GPS定位阅读北部一个时刻和南部的下一个太 高速?如果是的话,它很可能是全球定位系统错误。
- 检查GPS caluclation使用的卫星数量。 12表现突出,9是健康的,5个或更少的差,4为最低限度的纬度,经度+高度 计算,3是最低限度的纬度,经度计算。点儿小于3不是有效的读数。你可以更自信数据的有效性,如果staellites数是很高的。
Writing a GPS logging application~
I'm finding the values returned by the getSpeed()
method on Locations
reported by LocationManager
are massively unreliable. I'm using LocationManager.GPS_PROVIDER
, filtering the Locations provided through onLocationChanged
for best accuracy. Even at single digit accuracy levels the speed returned is generally ridiculously high. We're talking up to 200 mp/h (yes I know it's logged in metres/sec) when the phone is stationary.
I'm testing the same code base on two different model Android phones, running two different OS versions, and seeing the same issues so I expect this is a code issue.
What am I missing? I've tried averaging locations over a window of time, to no avail. Am I going to have to work out my own speed values based on distance travelled / time? This would be disappointing.
As you will see, I'm not doing anything special - a little filtering for accuracy, even after this both AverageSpeed
and _bestLocation.getSpeed()
are regularly unfeasibly high, even when accuracy of the location is good.
public void onLocationChanged(Location location) {
if (location.getAccuracy() < 25f) {
_recentLocations.add(location);
if (_bestLocation == null || location.getAccuracy() <= _bestLocation.getAccuracy())
_bestLocation = location;
}
if ((_bestLocation != null && _bestLocation.getAccuracy() < 10f && _recentLocations.size() >= 10)
|| _recentLocations.size() >= 25)
{
int Count = 0;
float TotalSpeed = 0f;
float AverageSpeed = 0f;
for (int i = 0; i<_recentLocations.size(); i++) {
if (_recentLocations.get(i).hasSpeed()) {
Count++;
TotalSpeed += _recentLocations.get(i).getSpeed();
}
}
if (Count > 0)
AverageSpeed = TotalSpeed / Count;
}
}
I have worked on GPS hardware since more then 7 years now. The accuracy reading is also not 100% accurate. Manufacturers state accuracy along with the system used for measuring it. CEP, RMS, 2DRMS, and R95 are some of the systems. Read this article for more information: http://en.wikipedia.org/wiki/Circular_error_probable
The accuracy figure does not include outliers. For example, if stated accuracy 5 meters then readings taken in good signal conditions will have maximum error of 5 meters, 95% of the time. Nothing can be said about the remaining 5% readings. Protection against these outliers is the special sauce that makes a good location based app stand out from the rest.
Some things you can do are:
- Filter out insanely high speeds. Make use of altitude as hint for being in a airplane.
- Correlate information from motion sensors and see if they agree with GPS. Motion sensor signatures will be very different in steady state and in motion.
- The typical size of a GSM/3G cell is under a kilometer in urban areas and 5-10 kilometers in sparsely populated areas. If the vehicle is moving at high speed for some time and the cell tower information is still the same, you know something is wrong.
- Does the GPS fix read north one moment and south the next that too at a high speed? If yes, it is most likely a GPS error.
- Check the number of Satellites used in GPS caluclation. 12 is outstanding, 9 is healthy, 5 or less is poor, 4 is bare minimum for lat,lon + altitude calculation, 3 is bare minimum for lat,lon calculation. Anyting less than 3 is not a valid reading. You can be much more confident about the validity of data if number of staellites is high.
这篇关于Android的GPS定位速度不可靠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!