Ask Your Question
14

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

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

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

3 Answers

Sort by ยป oldest newest most voted
17

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

joq gravatar image

updated 2021-09-22 08:32:45 -0600

lucasw gravatar image

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

Comments

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 image sam  ( 2012-01-13 00:20:05 -0600 )edit
Probably, you either forgot to set `use_sim_time` first, or you did not specify `--clock` on the playback.
joq gravatar image joq  ( 2012-01-13 01:15:29 -0600 )edit
2

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

2ROS0 gravatar image 2ROS0  ( 2019-01-03 16:05:32 -0600 )edit
5

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

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

Comments

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 image sam  ( 2012-01-11 00:26:38 -0600 )edit

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

joq gravatar image joq  ( 2012-03-31 05:31:35 -0600 )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 image sam  ( 2012-03-31 21:19:34 -0600 )edit

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

joq gravatar image joq  ( 2012-04-01 02:55:49 -0600 )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 image sam  ( 2012-04-01 03:13:55 -0600 )edit
2

answered 2021-06-27 04:10:28 -0600

gbohus gravatar image

updated 2021-06-27 04:12:00 -0600

I found this works for me.

Start ROS, but not your nodes.

Start using simulated time:

rosparam set use_sim_time true

Start your nodes.

Start playback:

rosbag play --clock <bag_file>
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

3 followers

Stats

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

Seen: 37,099 times

Last updated: Sep 22 '21