ros2 use_sim_time and bagfile playback

asked 2021-11-03 17:18:33 -0500

mschuckmann gravatar image

I'm trying to understand how to use use_sim_time and --clock with ros2 bag play all of the documentation seems to be around ros1 (as they refer to the rosparam and rosbag commands which don't exist in ros2. Plus the fact that use_sim_time seems to be a global parameter in ros1 but no so in ros2).

I'm also finding the existing documentation to be a bit confusing and incomplete as I'm not really sure what is supposed to happen when I use --clock or use_sim_time.

Ultimately I'm trying to understand how to use recorded bag file data with older time stamps with the rest of my ros2 system. So say I have a bag with a topic that has the sequence of timestamps below:

sec: 9049 nanosec: 837516000 sec: 9049 nanosec: 837516000 sec: 9049 nanosec: 837516000 sec: 9049 nanosec: 849105000 ... And I replay that bagfile using the command `ros2 bag play --loop --clock 10.0 some_bag_file What does that give me? Or put another way how can I observe a change in behavior that demonstrates that a simulated clock is being used?

Note: I've tried echoing the /clock topic expecting the clock time to match my bag file timestamps but that doesn't seem to be the case. I can also observe that the timestamps for my data from the bag file don't change so I'm really stumped on how this works (and I don't seem to be only one).

edit retag flag offensive close merge delete