Reputation: 699
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;
}
}
Upvotes: 15
Views: 15256
Reputation: 5684
I have worked on GPS hardware for more than 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 or about readings taken in bad signal contions. 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:
Upvotes: 32
Reputation: 1
It seemes that most people are assuming that speed information from GPS is based on comparing positions related to time diference. This method is not very good for determining speed, and is worse at lower speeds of travel.
GPS receivers can output speed measurement based on doppler shift from the sattelite measurements. Accuracy of the speed measurement based on doppler is MUCH better compare to speed measurements based on position/time calculations.
Google on gps speed doppler and You will find a lot to read.
One link is here: http://nujournal.net/HighAccuracySpeed.pdf
/Urban Holmdahl
Upvotes: 0
Reputation: 1054
I am experiencing the same problem. I think GPS signal depends on a location, some location may give an exact output of location otherwise a 'not-so-reliable' result. In my case, I was located about 200 meters away from my actual location. How about you?
To add, GPS_PROVIDER does not work here in my area. NETWORK_PROVIDER does, and it's the one that give the 200 meters away result.
Upvotes: 1
Reputation: 2779
GPS devices are positional speedometers, based on how far the receiver has moved since the last measurement. Its speed calculations are not subject to the same sources of error as the vehicle's speedometer (wheel size, transmission/drive ratios). Instead, the GPS's positional accuracy, and therefore the accuracy of its calculated speed, is dependent on the satellite signal quality at the time. Speed calculations will be more accurate at higher speeds, when the ratio of positional error to positional change is lower.
From Wikipedia.
Probably you should try this in place where you have good signal strength.
Upvotes: 1