ros.spinOnce() during delay
Say I have a ros rate of 10 Hz. Does ros.spinOnce()
occur during ros::Duration(2).sleep()
?
Example:
void main(void){
ros::nh;
ros::rate r(10);
while(ros::ok())
{
do something;
ros::Duration(2).sleep();
ros::spinOnce();
}
}
ros::rate r(10);
as it is used, is doing nothing. If you want the loop to run at 10Hz you should callr.sleep()
at the end of your while loop.Currently the loop would run at a rate of 1/(2 + call backs processing time).