Units for time variable in MATLAB files

Mission Planner has a button to create MATLAB files from telemtry logs. What are the units of the time variable in the created MATLAB variables?

Thanks!

probably microseconds

I figured it out. It’s not microseconds, it’s a MATLAB datenum, which is the number of days since Jan 0, 0000. But there is an error/bug - the value is one day off (too small). I’ll file a bug report if I can figure out where and how…

off by one? or is it GMT?

Nope, off by exactly one day. (plus a few seconds…) Offset to GMT from my localtime (EDT) is 4 hours.

Best proof is probably to look at the mavlink SYSTEM_TIME message. I have telemetry log files from a test performed on Tuesday, Aug 28, 2018 at approximately 4:00 - 4:30 pm local time (EDT). The unix system time in the mavlink SYSTEM_TIME message becomes the variable, time_unix_usec_mavlink_system_time_t, in the created mat-file. Here’s a snippet of the first 10 rows:

>> time_unix_usec_mavlink_system_time_t(1:10,:)

ans =

      737299.669028796        1.535486602487e+15
      737299.669032454        1.535486603002e+15
      737299.669053021        1.535486604884e+15
      737299.669073461        1.535486606434e+15
      737299.669089109        1.535486607963e+15
      737299.669107245        1.535486609503e+15
      737299.669126366        1.535486611002e+15
      737299.669141331        1.535486612543e+15
      737299.669164317        1.535486614084e+15
      737299.669184641        1.535486615583e+15

First column is matlab datenum, second is unix time in microseconds.

Using the first entry, on my linux box, which is set for GMT-5:

~>date --date='@1535486602.487'
Tue Aug 28 16:03:22 EDT 2018

And on MATLAB:

> datestr(737299.669028796)

ans =

'27-Aug-2018 16:03:24'

Thus, offset by one day. I’ll leave it to you to worry about the 2 second difference (plus probably some milliseconds). I don’t care right now for my purposes.

Does this suffice as my bug report?

Edit
If it matters, I’m running arducopter 3.5.7 on a rpi/navio2, and Mission Planner version 1.3.52 build 1.3.52.0

1 Like

ive made changed to add the missing day