0
$\begingroup$

Rosanswers logo

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
-----------
678
680
683
685

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?


Originally posted by alfa_80 on ROS Answers with karma: 1053 on 2012-01-07

Post score: 0


Original comments

Comment by alfa_80 on 2012-01-08:
It's simply an offline dataset which comprises some data+timestamps(in seconds) there.

Comment by ahendrix on 2012-01-08:
can you clarify what you mean by "a dataset read from a file"?

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.

EDIT:

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.


Originally posted by joq with karma: 25443 on 2012-01-08

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by alfa_80 on 2012-01-08:
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..

Comment by alfa_80 on 2012-01-08:
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.

Comment by alfa_80 on 2012-01-08:
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.

Comment by joq on 2012-01-08:
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?

Comment by alfa_80 on 2012-01-08:
I've edited my post, hopefully, it's a bit clear for you.

$\endgroup$

Your Answer

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