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

Revision history [back]

click to hide/show revision 1
initial version

You are looking for Timers, see the wiki

void callback(const ros::TimerEvent&)
{
  ROS_INFO("Callback triggered");
}

int main(int argc, char **argv)
{
  ros::init(argc, argv, "name");
  ros::NodeHandle n;
  ros::Timer timer = n.createTimer(ros::Duration(1.0), callback);
}

Here the callback will be triggered every second. You can put your condition or function inside the callback to have it called every second.