Ask Your Question
0

How to obtain time stamps for messages with no header

asked 2019-07-11 08:53:25 -0500

schizzz8 gravatar image

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 flag offensive close merge delete

Comments

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.

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

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-07-11 10:01:58 -0500

gvdhoorn gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-07-11 08:53:25 -0500

Seen: 58 times

Last updated: Jul 11