APM:Copter log file : how to retrieve timestamps for GPS & CAM messages

1,261 views
Skip to first unread message

Hugues D

unread,
Aug 30, 2015, 4:05:18 PM8/30/15
to drones-discuss
Hi,

In an objective to georeference images, I'd like to export from a .bin log file the CAM & GPS messages with corresponding timestamps (the time that is displayed in the second column of the mission planner "review log" screen). However when importing the log file in excel, this column is not present (apparently the .log version of the flight log starts at column 3).
Questions that I have are :
-the timestamp that appears in the second column in mission planner review log corresponds to what time ? GPS time or internal Pixhawk time or else ?
-How can I export ALL columns of the .bin log to a csv type of file ? (using the PX4 . bin to .log button in mission planner does not export the first two columns) ?

Thx
Hugues

Hugues D

unread,
Sep 6, 2015, 6:15:01 AM9/6/15
to drones-discuss
I collected answers elsewhere and copy them here for memo & whoever else it might help:

-GPS time in the CAM and GPS messages in the pixhawk log files is not a date:hour:min:sec format but a duration since an arbitrary chosen T0. This duration is in microseconds. The arbitrary T0 was chosen as the UTC time on 6 january 1980. Every so often, it is decied to resynchronize the GPS time with the UTC time, thus resetting the "duration" or offset to zero.

-To make things a bit more complicated, the GPS time is not corrected for the Earth rotation speed which forces , once a year to correct by one second the UTC time. It is what they call a "leap second". At this moment in september 2015 (since July 2015), they are 17 cumulated leap seconds.

-The formula to calculate the UTC time on the basis of the GPS cumulated microseconds is : 6 jan 1980 + GPS microseconds - minus 17 leap seconds = UTC time.

-There are function in python and other programming languages who can do this conversion from GPS time to UTC time (be careful, some do not take the leap seconds in consideration)

-The second column displayed in mission planner is thus a calculated UTC time on the basis of the GPS "duration" field.

-This field CANNOT thus be exported in a .log file to excel since it does not exist as a field in the log. It must be recalculated after the excel export to be used outside mission planner.

Jesus Alvarez

unread,
Sep 6, 2015, 11:49:51 AM9/6/15
to drones-discuss
Hi Hugues

The time saved in the APM/Pixhawk logs is GPS time, with its good and bad things.

Mission planner in the Geotag code added a funtion as this

public DateTime GetTimeFromGps(int weeknumber, int milliseconds)
        {
            int LEAP_SECONDS = 17;

            DateTime datum = new DateTime(1980, 1, 6, 0, 0, 0, DateTimeKind.Utc);
            DateTime week = datum.AddDays(weeknumber * 7);
            DateTime time = week.AddMilliseconds(milliseconds);

            return time.AddSeconds(-LEAP_SECONDS);

        }

So If you want UTC time from GPS Week and Milliseconds you need to take those two numbers and do the math manually, in python or any other method.

cheers
Reply all
Reply to author
Forward
0 new messages