0
$\begingroup$

Rosanswers logo

I want to get data out of event, as explained in 1.4 of : http://wiki.ros.org/roscpp_tutorials/Tutorials/Timers

But the problem is i don't know how to convert ros::time into double variable, am process further... i don't even know how to write what the obiect "event" contains using ROS_INFO, or something.


Originally posted by maneaflavian on ROS Answers with karma: 1 on 2015-03-27

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

It's not ros::time, it's ros::Time (capitalizing the 'T' is necessary).

You can use the toSec method of a Time instance to get the time as a double (see the Time Overview wiki).

The API for Time can be found here, while the API for its superclass TimeBase can be found here.

An example of using ROS_INFO for the last_real member of a received TimerEvent instance tEvent might look like so:

void callback1(const ros::TimerEvent& tEvent) {
  ROS_INFO("Event last_real time: %f", tEvent.last_real.toSec());
}

Originally posted by kramer with karma: 1470 on 2015-03-28

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.