### Onboard log GPS time format?

I have written a small Java program that uses the Telemetry logs to automatically reject photos that were taken at high bank angles.

I was hoping to get better time resolution with the on-board logs and want to enable the software to use either the on-board logs, or the TLogs.

How do I convert the GPS time in the on-board logs, to a date and time?  The number seems a bit small to be a milisecond time as it wont cover date also.  But then again, it seems to big just for time.

Any suggestions?

Thanks

#### Replies

• sub GPSToEpoch {

my \$week = shift;
my \$miliseconds = shift;

my \$gpstime = GPSEpoch(); #Add in the GPS Epoch
\$gpstime += \$week * 7 * 24 * 60 * 60; #Convert Weeks
\$gpstime += \$miliseconds / 1000; #Add in the Miliseconds

print DEBUG "GPSToEpoch:Week (\\$gpstime): \$week\n" if \$debug;
print DEBUG "GPSToEpoch:Milliseconds (\\$miliseconds): \$miliseconds\n" if \$debug;
print DEBUG "GPSToEpoch:GPS Time is (\\$gpstime): \$gpstime\n" if \$debug;

return \$gpstime;

}

sub GPSEpoch {

my \$g_dd = 6;
my \$g_mo = 1;
my \$g_yy = 1980;
my \$g_hh = 0;
my \$g_mi = 0;
my \$g_ss = 0;

my \$gpsepoch = timegm( \$g_ss, \$g_mi, \$g_hh, \$g_dd, \$g_mo - 1, \$g_yy);

print DEBUG "GPSEpoch:GPS Epoch is (\\$gpsepoch): \$gpsepoch\n" if \$debug;
return \$gpsepoch;

}

• Developer

Etienne,

Sandro on the dev team was looking at this about a week ago.  The conclusion we came to is that it's not possible to convert the time from the gps into a julian date and time.  The time from the gps is the "time since epoch" which is, as far as I know, just some time in the recent past (a few days ago).  The APM also doesn't know what day it is .. it only knows how many milliseconds it's been running.

Of course, I guess if you knew what time the last epoch was you could use that time and then add to it theGPS time and divided by 1000 (to turn it into seconds).