1
$\begingroup$

Rosanswers logo

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.


Originally posted by Sentinal_Bias on ROS Answers with karma: 418 on 2014-01-28

Post score: 7

$\endgroup$

3 Answers 3

0
$\begingroup$

Rosanswers logo

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


Originally posted by Procópio with karma: 4402 on 2014-01-28

This answer was ACCEPTED on the original site

Post score: 20

$\endgroup$
0
$\begingroup$

Rosanswers logo

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.


Originally posted by dornhege with karma: 31395 on 2014-01-28

This answer was NOT ACCEPTED on the original site

Post score: 3

$\endgroup$
0
$\begingroup$

Rosanswers logo

Hello as Procópio with detailed steps :
first step:

roscore

second step:

rosparam set use_sim_time true

third step:

rosbag play name_of_the_bag.bag --clock 

if this command doesn't work well you can try:

rosbag play name_of_the_bag.bag 

Originally posted by ebrahim with karma: 21 on 2022-12-06

This answer was NOT ACCEPTED on the original site

Post score: 2

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.