Ask Your Question

Revision history [back]

You have two main options; use rosbag, or generate the messages manually. Either way, if you want to treat that data as if the experiment was being run (as in, you wanted it treated as if you were back in time running the live), then you can set the "use_sim_time" parameter to true, which will make RVIZ (and anything else that uses ros::Time, which is just about everything except tf) act like the experiment was running live.

Option 1: rosbag. With rosbag, you can record data from a topic into a file, and then replay it, and ROS will worry about all the timing issues. There is plenty of information about rosbag, so I'll leave this here.

Option 2: Manually. Assuming you have recorded the data from an external source (outside of ROS), or the experiment is unrepeatable for whatever reason, you could use a node to both generate clock messages and publish your data. Jumping ahead, I am assuming you already have your data imported into a node of some sort (in a vector or something). Your best bet would be to set up a publisher for the /clock message (you can manually create a time message and just send your recorded time as this), then set up a publisher for your data and have it populate the fields as usual (you can use ros::Time::now() as usual for this, or set the stamp header manually, it shouldn't matter if your /clock messages are sent correctly). From here, you would just want to use ros::Time::sleep(dt), where dt is the difference in time between your recorded timestamps.