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

Synchronization of 2 kinds of timestamp

asked 2012-01-07 22:17:43 -0600

alfa_80 gravatar image

updated 2012-01-08 02:19:53 -0600

A node of mine publishes some messages in which their timestamps are according to a dataset read from a file (See Timestamp A below). In the node, there is another subscription of a topic from another node, which uses ROS timestamp (ros::Time::now())(See Timestamp B below).

Timestamp A

Timestamp B from ROS
Output 1 of ros::Time::now()
Output 2 of ros::Time::now()
Output 3 of ros::Time::now()

How do I alter/synchronize or map one to another those two kinds of timestamp, because if I want to use message_filters, for example, their timestamps should match. The synchronization, I mean, such that Timestamp of 678 in Timestamp A should match Output 1 of ros::Time::now() in Timestamp B, Timestamp of 680 in Timestamp A should match Output 2 of ros::Time::now() in Timestamp B and so on.

EDIT: My problem is in Timestamp A it's already at 678 seconds say, but in Timestamp B, it's another value comes in(whatever value ros::Time::now() at that moment). I need to process corresponding 2 values with regard to the comparable timestamp of them. How do I match those 2 timestamps?

edit retag flag offensive close merge delete


can you clarify what you mean by "a dataset read from a file"?
ahendrix gravatar image ahendrix  ( 2012-01-08 06:44:24 -0600 )edit
It's simply an offline dataset which comprises some data+timestamps(in seconds) there.
alfa_80 gravatar image alfa_80  ( 2012-01-08 19:47:43 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2012-01-08 02:05:51 -0600

joq gravatar image

updated 2012-01-09 03:04:01 -0600

I can't tell what you are trying to accomplish.

Note that ros::Time can be converted to and from double seconds. You could do some desired arithmetic using seconds, then convert back to ros::Time.


I now suspect you want to play back some previously acquired messages while running another node on the output. This would normally be accomplished by using rosbag record to save the messages in a bag file. In that case, this command would play them back with the original times:

rosbag play --clock my_saved_messages.bag

The --clock option configures the ros::Time interface to use simulated time.

Since you are not using rosbag, you may need to reimplement its simulated time logic. Or, perhaps you can convert your data file to ROS messages and save them using rosbag.

edit flag offensive delete link more


I've edited my post, hopefully, it's a bit clear for you.
alfa_80 gravatar image alfa_80  ( 2012-01-08 02:21:26 -0600 )edit
Not so clear. On what basis do you wish to match timestamps? Is it just a constant offset between now and time 678? Or, are you asking how to play back data using the original times when they were collected?
joq gravatar image joq  ( 2012-01-08 06:43:09 -0600 )edit
I have a third-party node in which I want to subscribe its topic and the messages published by that topic is using ros::Time::now(). In my own node I have a dataset by which the timestamp is in seconds.
alfa_80 gravatar image alfa_80  ( 2012-01-08 19:42:35 -0600 )edit
Cont'd: For computation in my node, I need to subscribe to that third-party node's topic and compute with my dataset that all in seconds. The problem now, is that, ros::Time::now() from third party node and mine in seconds.
alfa_80 gravatar image alfa_80  ( 2012-01-08 19:45:05 -0600 )edit
Cont'd: Even, I convert one of them using what you have suggested above, it won't be OK in this case i think. Thanks anyway, to think about this..
alfa_80 gravatar image alfa_80  ( 2012-01-08 19:46:28 -0600 )edit

Question Tools


Asked: 2012-01-07 22:17:43 -0600

Seen: 2,167 times

Last updated: Jan 09 '12