- Home /
GPS timestamp help. Android device synchronization fails.
Hello everyone! I've encountered a problem, and need help to figure out what's happening. The idea is to synchronize 2 or more android devices with respect to a GPS location timestamp. I've heard that GPS time is very accurate, unlike system time, which may vary across few seconds. However the results I get are not what I expected.
void Start() {
Input.location.Start ();
double UTC_timestamp = Input.location.lastData.timestamp;
Input.location.Stop ();
}
So in this case, UTC_timestamp represents the total number of seconds since January 1st 1970, 00:00:00.
But if I request a timestamp on 2 different devices, I am getting quite a sure difference, and my attempts to synchronize them via satellite's timestamp fails.
Here is how I tested that:
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class GPSTime: MonoBehaviour {
double UTC_timestamp;
public Text txt_UTC;
IEnumerator Start() {
UTC_timestamp = getGPSTime ();
while (Application.isPlaying) {
yield return new WaitForSeconds (1);
UTC_timestamp ++;
}
}
void Update() {
print("UTC: "+ UTC_timestamp);
txt_UTC.text = "UTC: " + UTC_timestamp;
}
private double getGPSTime() {
Input.location.Start ();
UTC_timestamp = Input.location.lastData.timestamp;
Input.location.Stop ();
return UTC_timestamp;
}
}
I run this on two different devices, and the timestamp I am getting differs quite significantly:
So out of three app launches I get the following:
DEVICE 1
1) 1438782375.605
2) 1438782610.260
3) 1438782681.926
4) 1438782960.266
DEVICE 2
1) 1438782505.306
2) 1438782680.011
3) 1438782675.226
4) 1438782967.400
So first launch differs by ~130 seconds!!! Second trial differs by ~70 seconds, and third trial differs by 6-7 seconds. Fourth trial differs by around 7 seconds.
Why such strange differences? What can I do to get the best results possible?
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How to display a video behind gui on mobile 2 Answers
Access android IR blaster 0 Answers
Changing view based on device 0 Answers