ROS Resources: Documentation | Support | Discussion Forum | Service Status | Q&A
Ask Your Question

When should I need --clock parameter on rosbag play?

asked 2012-01-10 18:03:20 -0500

sam gravatar image

I can't find any doc about parameter of rosbag play.

In rosbag video told that parameter.

How to use --clock parameter?

Thank you~

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2012-01-11 02:50:03 -0500

joq gravatar image

updated 2012-03-31 05:30:14 -0500

If you run "rosbag play --clock ..." before your other nodes, it will set use_sim_time for you. If you prefer to launch the other nodes first, be sure to set it yourself, as @michikarg recommends.

In addition, the --clock option causes rosbag play to publish simulated time synchronized to the messages in the bag file to the /clock topic. That way, your other nodes run as if they were executing when those messages were originally published.

CORRECTION: My mistake, rosbag play does not set use_sim_time for you. Setting it yourself is a good idea. That typically needs to be done before the other nodes start up.

edit flag offensive delete link more


Does 'they were executing when those messages were originally published' means it use the original timestamp when I recording? But when I rosbag play, receiver always get the latest timestamp and always different. What happened?
sam gravatar imagesam ( 2012-01-13 00:20:05 -0500 )edit
Probably, you either forgot to set `use_sim_time` first, or you did not specify `--clock` on the playback.
joq gravatar imagejoq ( 2012-01-13 01:15:29 -0500 )edit

Basically, without --clock, nothing gets published on /clock. And if use_sim_time is true, it needs stuff on /clock

2ROS0 gravatar image2ROS0 ( 2019-01-03 16:05:32 -0500 )edit

answered 2012-01-10 19:02:09 -0500

michikarg gravatar image

I think what you are searching for is the /time topic that has to be published when running in simulation or playing rosbags. In your case this should be done automatically by rosbag but you have to tell your master that you use simulation time. You can do so by:

rosparam set use_sim_time true

Hope that helps.

edit flag offensive delete link more


After I use 'rosparam set use_sim_time true', I can't figure out the difference of adding --clock parameter. When should I use --clock? Thank you~
sam gravatar imagesam ( 2012-01-11 00:26:38 -0500 )edit

When you want rosbag to publish the original times of the messages.

joq gravatar imagejoq ( 2012-03-31 05:31:35 -0500 )edit

When is the case of using 'rosparam set use_sim_time true'? I can't find /time topic when I run 'rosparam set use_sim_time true & rosbag play ...'.

sam gravatar imagesam ( 2012-03-31 21:19:34 -0500 )edit

The /time topic has been replaced by the /clock topic.

joq gravatar imagejoq ( 2012-04-01 02:55:49 -0500 )edit

Thank you. Now I know --clock is for publish /clock topic, but I still unknown that when is the case of using 'rosparam set use_sim_time true'? I have tested it and I found it is different with --clock, but I can figure out what's its usage.

sam gravatar imagesam ( 2012-04-01 03:13:55 -0500 )edit

Your Answer

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

Add Answer

Question Tools



Asked: 2012-01-10 18:03:20 -0500

Seen: 20,759 times

Last updated: Mar 31 '12