Does ros::Timer::hasPending method actually work?
I used it expecting that it will return true after starting the timer, until the callback get's called (in a one-shot timer). But I turned out to be wrong; the following program will return always false:
#include "ros/ros.h"
void callback(const ros::TimerEvent &event)
{
ROS_INFO("CB!");
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "timer_test");
ros::NodeHandle nh;
ros::Timer timer = nh.createTimer(ros::Duration(1.0), callback, true);
ROS_INFO("%d", timer.hasPending());
ros::spinOnce();
ROS_INFO("%d", timer.hasPending());
ros::Duration(0.5).sleep();
ros::spinOnce();
ROS_INFO("%d", timer.hasPending());
ros::Duration(0.5).sleep();
ros::spinOnce();
ROS_INFO("%d", timer.hasPending());
ros::Duration(0.5).sleep();
ros::spinOnce();
ROS_INFO("%d", timer.hasPending());
ros::spinOnce();
}
Am I misunderstanding what the method actually does? Thanks