3

I am trying to understand what effects does setting use_sim_time to true does specially when recording and playing a rosbag, but unfortunately the info is few and hard to understand.

I know already how to set it to true, so that is no problem.how to do it

I have done some experiments with a rosbag file I have and I noticed:

  • When I do rosplay play file.bag , the topic \clock is not published
  • When I do rosplay play file.bag --clock the topic \clock is published

I also have noticed that when I do rostopic echo \clock and I play the bag, many of the time published is the same! (what does this mean??)

And lastly I have noticed that use_sim_time has no effect on any of these results.

So what effect does setting this parameter to true have?

KansaiRobot
  • 7,564
  • 11
  • 71
  • 150

1 Answers1

2
  • In order for a ROS node to use simulation time according to the /clock topic, the /use_sim_time parameter must be set to true before the node is initialized. In other words, The ROS API used to get times ros::Time time = ros::Time::now() will retrieve time data from the /clock topic rather than using the system clock. If you turn use_sim_time off then any time values published to /clock will be ignored

  • If the /use_sim_time parameter is set, the ROS Time API will return time=0 until it has received a value from the /clock topic. Then, the time will only be updated on receipt of a message from the /clock topic and will stay constant between updates

More information follow: [1], [2]

GPrathap
  • 7,336
  • 7
  • 65
  • 83