ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

rosbag --clock time for files recorded on a different machine

asked 2013-03-13 09:50:35 -0500

Tom Moore gravatar image

I ran rosbag record on a laptop to produce a bag file. However, all of the nodes producing the topics were on my robot's computer (i.e., on the same network, but not on the same machine). I am now trying to play back the data using rosbag play --clock <filename>, but the time being produced by /clock is about two minutes off from the time embedded in one of my sensor messages (/imu/data). I'm assuming that the time on the laptop was different than the time on the robot's computer, and that is what's accounting for this issue. Where does ROS get its initial time when playing back a bag file? Is there any way to change it? Ideally, I'd like it to be in line with the first message that was received from any sensor.

The reason it's a problem for me is that I am using robot_pose_ekf (with use_sim_time set), which is waiting for a transformation from /imu to /base_footprint. However, the time difference between ros::Time::now() and the IMU message's timestamp is ~130 seconds, and robot_pose_ekf is only using a transform time difference of 0.5 seconds.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-03-13 12:15:45 -0500

Chad Rockey gravatar image

rosbag records ros::Time::now() of when the message is received on the "rosbag record" computer. This helps the playback system emulate the latency of the logged messages.

Your imu publisher likely fills in the msg.header.stamp with ros::Time::now() of the robot the imu is attached to.

To change the timestamps, have a look at the rosbag APIs, you can read in the bagfile and write a new one with whatever timestamps you want.

Finally, to prevent this from happening in the future, take a look at a solution like chrony. It's great for ROS because ROS requires two way communication; and that's all it takes for chrony to synchronize your timestamps.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2013-03-13 09:50:35 -0500

Seen: 7,891 times

Last updated: Mar 13 '13