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

How can i manipulate "ros::TimerEvent& event" from a callback time function?

asked 2015-03-27 10:34:16 -0500

maneaflavian gravatar image

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

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.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-03-28 08:09:50 -0500

kramer gravatar image

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());
}
edit flag offensive delete link more

Question Tools

Stats

Asked: 2015-03-27 10:34:16 -0500

Seen: 328 times

Last updated: Mar 28 '15