Ask Your Question
2

sync ros bag timestamps with ros system

asked 2014-01-28 00:20:49 -0500

Sentinal_Bias gravatar image

Currently I am publishing frames from a ROS bag file, using recorded timestamps. When I try a publish a pointcloud using from a current node. Frames do not exist to publish the topic, this is because the frames are being broadcast from a bagfile and hence have old time stamps.

One solution was the re-write the timestamps in the bag files and then play them. However by the time you parse and re-write the bag files and play them the time stamps will be too old again.

I am wondering if there was a way to force the ROS system time to equal the earliest time in the bagfile, once the bag file play command is given?

My current idea, to publish a time stamp message from the ROS bag file. Then all nodes will subscribe to this, therefore when something is published from my nodes, it can refer to the bagfile time stamp. This method would fall apart when you are rely on third party nodes to publish certain things eg pcd2pointcloud node.

Another method, would be to figure out the offset in time between the current time and the bagfile time, therefore you could publish a pointcloud to the correct time. This method would mean you cannot play the bagfile at half speed.

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
11

answered 2014-01-28 00:40:05 -0500

Procópio gravatar image

updated 2014-01-28 19:36:20 -0500

Yes, there is a a way to force the ROS system time to use the time stored in your bagfile. To do this you must:

  1. set the use_sim_time parameter to true:

    rosparam set use_sim_time true

  2. play your bag file with the argument --clock:

    rosbag play xxxx.bag --clock

I hope this solve your issue. For further info you can check this page

more info: here and in the wiki

edit flag offensive delete link more
2

answered 2014-01-28 00:41:57 -0500

dornhege gravatar image

You should approach the problem from the other direction. Use the --clock option when playing a bag file. Depending on the nodes you start you might also want to set use_sim_time to true on the param server.

This will publish ROS time on the /clock topic and then ROS time will be the time from the bag file. System time doesn't exist any more unless explicitly requested by using a ros::WallTime.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-01-28 00:20:49 -0500

Seen: 9,643 times

Last updated: Jan 28 '14