ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
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 Header
s to messages that don't have them.