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

Revision history [back]

Example code that should achieve what you want:

ros::Time start_time = ros::Time::now();
ros::Duration timeout(2.0); // Timeout of 2 seconds
while(ros::Time::now() - start_time < timeout) {
  // do your stuff
}

Example code that should achieve do what you want:

ros::Time start_time = ros::Time::now();
ros::Duration timeout(2.0); // Timeout of 2 seconds
while(ros::Time::now() - start_time < timeout) {
  // do your stuff
}