如何从Android GPS位置获取准确的时间戳

时间:2023-02-05 18:10:10

I'm trying to get the GPS time for a location using location.getTime on a location listener using GPS_PROVIDER in my requestLocationUpdates. I was expecting the provided time to be the time from the GPS clock - accurate to billionths of a second, but rounded to the millisecond. What I am getting depends on the platform, but certainly doesn't seem to be what I'm expecting.
On SGS 11 - Android 2.3.3, the returned value is always an exact second, with the millisecond portion always .000. From my experience with GPSs, it seems to me unlikely that every polling of the GPS will occur exactly on the whole second interval.
On an HTC-A7275 Android 2.3.3 - I'm getting the phone's system time, certainly not the GPS time.
I confirmed these findingsby messing with the phone's time and examining the location time.
The time stamps in NMEA sentences on the SGS 11 are provided to 3 decimals of a second, but on the HTC, they're all xxx.0. The problem using NMEA is that it's really messy getting the date and time and full position from MNEA: It is only in the GPGGA sentence that has altitude, but it has no date stamp so it get's tricky around midnight UTC.
I am looking for precise times - preferably to the millisecond for my track logger, so that I can reliably compare tracks from different players. Has anyone done any more work on this?

我正在尝试使用locationLatUpdates中使用GPS_PROVIDER的位置监听器上的location.getTime来获取位置的GPS时间。我期待所提供的时间是从GPS时钟开始的时间 - 精确到十亿分之一秒,但是四舍五入到毫秒。我得到的东西取决于平台,但肯定似乎不是我所期待的。在SGS 11 - Android 2.3.3上,返回的值始终是精确的秒,毫秒部分始终为.000。根据我对GPS的经验,我似乎不太可能每次轮询GPS都会在整个第二个时间间隔内完全发生。在HTC-A7275 Android 2.3.3上 - 我得到了手机的系统时间,当然不是GPS时间。我通过弄乱手机的时间和检查位置时间来证实这些发现。 SGS 11上的NMEA句子中的时间戳提供给3个小数秒,但在HTC上,它们都是xxx.0。使用NMEA的问题在于,从MNEA获取日期和时间以及完整位置真的很麻烦:只有GPGGA句子中有高度,但它没有日期戳,所以它在UTC午夜左右变得棘手。我正在寻找精确的时间 - 最好是我的轨道记录器的毫秒,这样我就可以可靠地比较来自不同玩家的曲目。还有人在这方面做过更多的工作吗?

1 个解决方案

#1


1  

Expensive GPS units use "pulse-per-second" protocols to achieve sub-millisecond accuracy, however I haven't heard of this protocol or interface available on cheap GPS receivers we have in our phones. So the best accuracy you can achieve with GPS messages is within a 1-2 seconds range.

昂贵的GPS装置使用“每秒脉冲”协议来达到亚毫秒级的精度,但是我没有听说过我们手机中便宜的GPS接收器上提供的这种协议或接口。因此,使用GPS消息可以获得的最佳准确度在1-2秒范围内。

Re:NTP on Android, it's much better solution, but unlikely to achieve clock accuracy beyond 50-100ms on contemporary wireless networks.

Re:Android上的NTP,它是更好的解决方案,但在当代无线网络上不太可能实现超过50-100ms的时钟精度。

#1


1  

Expensive GPS units use "pulse-per-second" protocols to achieve sub-millisecond accuracy, however I haven't heard of this protocol or interface available on cheap GPS receivers we have in our phones. So the best accuracy you can achieve with GPS messages is within a 1-2 seconds range.

昂贵的GPS装置使用“每秒脉冲”协议来达到亚毫秒级的精度,但是我没有听说过我们手机中便宜的GPS接收器上提供的这种协议或接口。因此,使用GPS消息可以获得的最佳准确度在1-2秒范围内。

Re:NTP on Android, it's much better solution, but unlikely to achieve clock accuracy beyond 50-100ms on contemporary wireless networks.

Re:Android上的NTP,它是更好的解决方案,但在当代无线网络上不太可能实现超过50-100ms的时钟精度。