0
$\begingroup$

Rosanswers logo

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 , 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.


Originally posted by Tom Moore on ROS Answers with karma: 13689 on 2013-03-13

Post score: 3

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.

http://www.ros.org/wiki/rosbag/Cookbook#Rewrite_bag_with_header_timestamps

http://www.ros.org/doc/api/rosbag/html/c++/

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.

http://answers.ros.org/question/11570/ros-time-across-machines/


Originally posted by Chad Rockey with karma: 4541 on 2013-03-13

This answer was ACCEPTED on the original site

Post score: 4

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.