How to obtain time stamps for messages with no header

Hi all,

I have a simple question.

My problem is the following. I am listening to the move_base/cancel topic because I want to know the exact time at which a certain goal has been canceled.

The message I get from this topic is not of the stamped type. I guess that a simple solution would to call:

ros::Time stamp = ros::Time::now();


as first line of the callback.

However, I guess that the time this call is executed is not the same when the message has been sent.

For this reason, I was considering the idea of using a timer combined with a waitForMessage call.

Therefore, my question is: does this make sense? If yes, how do I obtain the time stamp?

Thanks.

edit retag close merge delete

As far as I'm aware, if a message doesn't have a header (or timestamp anywhere else) then it is not possible to determine when it was sent. Without a header the best you'll be able to do is what you've already got recording the time of receipt.

( 2019-07-11 09:54:14 -0500 )edit

Sort by » oldest newest most voted

Unless something has changed, there is no way to find out when a message was sent if it doesn't have a Header (note that even with a Header it would not tell you when the message was sent, as any value could be set in the stamp field).

The message I get from this topic is not of the stamped type. I guess that a simple solution would to call:

ros::Time stamp = ros::Time::now();


as first line of the callback.

That would get you the time your callback was called, not when the message was sent (nor when it was received).

However, I guess that the time this call is executed is not the same when the message has been sent.

Exactly.

For this reason, I was considering the idea of using a timer combined with a waitForMessage call.

I don't understand how this would get you the time the message was sent.

If the receipt time would be good enough, you could use a callback with a MessageEvent, instead of the 'raw' message.

One of the fields in the MessageEvent is the receipt_time, which is the time the message was received by your node and stored in the message queue. That's still not the time the message was sent, but would seem to be the closest you could get without adding Headers to messages that don't have them.

more