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

Revision history [back]

click to hide/show revision 1
initial version

Hello Rizqa,

you have the choise, it depends on what you actually want to do.

One way is, that you meassure the time between two messages in that node which creates and sends the message. The other way is that you get messages from other nodes. I think this is what you actually want.

So like davinci already said you need a subscriber. You initializes that subscriber with a self defined callback function and of course the message/topic name. This callback function gets called if a message from another node arrives. But don't forget that you have to call ros::spin() or ros::spinOnce()!!. Then you can directly get the current time in this callback function with ros::Time::now(). This can be done if the message doesn't have a header with a timestamp. If you get messages with a header and a timestamp you can read this timestamp from the message.

So I also recomment to have a look at the tutorial http://www.ros.org/wiki/ROS/Tutorials/WritingPublisherSubscriber%28c%2B%2B%29.

Beste regards, zumili