问题
I am working on the GPS part of a project and I would like to get something past the community. I have searched around for all the typical GPS "jumping and drifting" and I have worked on improving what I get but last week I got some really weird data that I cannot put my finger on.
The application basically has a foreground service that tracks the location and then uploads that data on a timer. Of course we have all the proper permissions needed and there is also a filter that weeds out data with really bad accuracy and "detects" stops. All was working well until what you can see here happened. These are some of the data points I got. A "beautiful" pattern drawing. The same happens to another location too but not to this extend. I checked the data to find out why my filter didn't even try to make things better and I found out that it would be unable to. All the points have proper speed, heading, and accuracy and for all intents and purposes I could say that the person actually did the whole thing. The problem is that it didn't happen. The phone, (Samsung J5) might not be the best there is out there, was in a room the whole time. From my understanding of the Fused Location Provider there is no speed reported if there is no GPS involved in the process. And lets assume that where the phone was sitting it could actually get a GPS signal. I can see it jumping around but going for a walk around the neighborhood?
I know and understand that the location in Android (and any other platform) can be a very complicated matter comprised of many different variables that mainly start from the hardware providing these variables, but how can we explain this sudden influx of crazy, even though seemingly proper, data? Can we consider that keeping the location service up and running for a long time actually bogged or "tired" the system? How can the same device that has given OK data to this point suddenly provide this dataset?
To add to the issue. In the data there were also one or two long delays of around 2 minutes (intervals set to 15 and 10 (for fastest) seconds). I am 100% sure that the service did not restart or anything of the kind because I am logging for that.
Any kind of insight would be greatly appreciated and if there is any way/method/algorithm you could recommend looking into to "fix" this kind of behavior would be great. Thank you in advance and sorry for the long question. I needed to provide a proper background.
EDIT: This is not really the answer to my question, why such a behavior suddenly appears, so I am adding it here as a way to try and mitigate the problem, at least a bit. I decided to use the Google's ActivityRecognitionAPI (comes bundled in the location API so no need to have more dependencies) and merged its output with my existing filter to hopefully "fix" the "false" location data.
If someone could still, though, give me a good answer (help me understand) on whether there are factors like long running times, or other hardware (or software) factors (excluding the typical knowledge that GPS chips on phones are bad) that can cause weird and unexpected behaviors like the mentioned one would be rather appreciated.
(We can of course always say - "It is the phones fault" - and be done ;) )
回答1:
The GPS has errors, so even if you stand still at the same point you will get different readings. There's a couple of things you can do:
- Use the accuracy value of the GPS - if the distance between the new reading and the previous one is lower than the accuracy - ignore it.
- Use the device's accelerometer in order to determine if it's moving or not.
来源:https://stackoverflow.com/questions/41805990/android-location-going-for-a-walk-by-itself