HKUST-Aerial-Robotics / ublox_driver

A driver for u-blox receiver (ZED-F9P) with ros support
GNU General Public License v3.0
96 stars 44 forks source link

Obtaining a timestamp for the resulting topics #12

Closed jcremona closed 6 months ago

jcremona commented 1 year ago

Thanks for sharing your impressive work! I am trying to make a rosbag from a .ubx file using ublox_driver (duration is ~90 minutes). After running ublox_driver and rosbag record -a, I obtain this rosbag: Screenshot from 2022-11-18 11-04-43

I would like to modify the rosbag to use it online. The easiest way would be to replace message timestamps with header timestamps. Unfortunately, only /ublox_driver/receiver_lla has a header with a timestamp. So, what would be the right way of getting a timestamp for the rest of the topics to rewrite the rosbag? gnss_comm has several functions to convert from GNSS time to time_t, but I am not sure about the msg fields I have to use to make this conversion.

shaozu commented 6 months ago

Hi, @jcremona, I am sure you have got the problem solved but hopefully my answer will help others. To convert GNSS time to ROS time, the function chain should be gpst2time => time2sec => ros::Time. If you need to compensate for leap seconds in order to work with other sensors, simply add gpst2utc between the first and second step.