Matlab evaluation of ulog2csv and rosbag2csv

Hi
I would like to create some plots in matlab referencing to my flightlogs and my rosbags.
So to get .csv files is quite easy and loading them in my matlab workspace is a piece of cake.

But to compare these different data-sets is challenging. The rosdata and the ulogdata have different timestamps - so I thought maybe I can compare the arming-state in ROS/mavros/state and start when arming to look at the ulogs (which start to auto record on arming) but the ulog time was in my case around 20.6sec while the ros time (starting with arming up to disarming) was only 19.013sec - so yeah I know it is not as bad but it is still not the same and while the record frequency is so diverging I have no better idea how to improve (reduce the time offset)…

Does anyone of you validate their data via matlab for specific checks/plots - and can help? Flight Review is nice but to get some more data plots would be quite useful.
Or does there any mavros command exist to trigger the ulog-generation? That would help for any new measurements, if I can create some kind of launch-file to start rosbag and the ulog simultaneously.

Thanks and kind regards

@mhkabir or @TSC21 do you have any advice to sync timestamps between ulog and rosbags?

Hey,
I had some spare time and decided to look a bit more precisely into the datasets. I wrote some matlab Code to read multiple csv-files and searched in the different topics for arming states - because these determine the start of my ulog.
First I thought about the state (mavros/state or ulog_vehicle_status) but these were a bit unreliable as I mentioned lest week.
On the other hand the rc-inputs should determine the arm-commands too and are recorded at a much faster frequency - to use these improved the duration difference a lot and it is now more consistent (0.3-0.45sec). So I will go on with some test plots …

Still this is just a workaround - it would be amazing to use the same timestamps nativly for px4 and ros.
Is there maybe some some kind of possibility to see the ulog_timestamps in ros? Then it could be achieved with some c++ Code… or to to sync the px4 with the timestamps of incoming measurements (like vision_pose)?

Below are some of my evaluated datasets - if anyone is interested:

STATE DATA
duration_mavros duration_ulog duration_diff


    19.013             19.99           -0.97636  
    18.961            19.693           -0.73191  
        29               29.024          -0.024062  
    21.005            20.879            0.12615  
    32.002            33.057             -1.055  
    45.996             46.26           -0.26393  
    64.947            64.543            0.40343  
    92.004            92.278           -0.27423  
    38.994            39.767           -0.77242  
       122             123.3             -1.304  

RC DATA
duration_mavros_rc duration_ulog_rc duration_diff_rc


      20.002               19.603             0.39832     
      19.635               19.336             0.29873     
      29.986               29.568             0.41815     
      21.852                21.47             0.38213        
      32.957               32.622             0.33473     
       47.14                46.84             0.29968     
      65.325               64.943             0.38197     
      93.181               92.807             0.37429     
      39.935               39.475              0.4601     
      123.29               122.86             0.42981

Hey @JulianOes,
so it was a while back when I asked this Question and you referred to @mhkabir and @TSC21.

Overall I feel like I did not too bad with my attempt to sync the datasets. I tracked the mavros/rc/in arm_channel and used a static Offset correction of (mavros.time-0.25)~approx~ulog.time.
As you can see below it is working quite well - of course if I zoom it Looks not as good as in the overview right now.

(The image shows the x-position of my drone according to the logfile and rosbag during Position mode)

Recently I wanted to have a look at the Motor Outputs and Keep track of them via mavros - which seems to be working while I track the mavros/rc/out Topic - But I would like to know About the value differences between the logfiles and the rosdata (see my current Topic - link at the end of this post …). I know Maybe the datasets are not perfectly alligned on the time axis but even though the y-values of the Graphs = Motor Outputs are not the same.

So now to my Questions:

  1. Anything new about correctly syncing rosbag and ulog?

  2. What is the issue for the value differences? data_conversion? noise? And can they be improved?

  3. If the internal uOrb Topic is saved in the uLog and also transferred via mavlink to mavros/rc/out is there a known delay or do I need the evaluate this on my own by tracking a Signal - and which one would you recommend? An arm command via an offboard command and calc the difference between ros time stamp of the start command and the ros timestamp of Motor value changes?

Kind regards,
Mark