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

Get message metadata within rosjava

asked 2014-05-21 09:22:10 -0500

Using rosjava, how would one get the timestamp and other metadata for a message?

Answering in the form of an adaptation of the Listener class in the rosjava tutorial would be particularly useful.


edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2014-05-27 07:04:09 -0500

After talking with a colleague, I have a rough understanding of this issue now. My understanding is below, though I haven't verified it via further internet research.

Headers are a field type that can be added to a message definition. A pre-defined message cannot simply have a header added to it at runtime (as I thought it could). Because of this, the Message class in rosjava does not have the ability to get the header from the message. Rather, a specific message class that inherits from Message could have a getHeader() method written in for it.

Please feel free to correct any misconceptions here.

edit flag offensive delete link more

answered 2014-05-21 11:42:35 -0500

damonkohler gravatar image

ROS messages don't have metadata. Timestamps are encoded in the Header sub-message of "stamped" messages. So, message.getHeader().getStamp().

edit flag offensive delete link more


Good to hear from you, Damon. Thanks for your timely response. There is apparently no getHeader() method in org.ros.internal.message.Message, either in my local copy or at Any suggestions?

bradknox gravatar image bradknox  ( 2014-05-21 12:42:21 -0500 )edit

Question Tools

1 follower


Asked: 2014-05-21 09:22:10 -0500

Seen: 381 times

Last updated: May 27 '14