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

Revision history [back]

From the Callbacks and Subscribers wiki,

#include <ros/callback_queue.h>
ros::NodeHandle n;
while (ros::ok())
{
  ros::getGlobalCallbackQueue()->callAvailable(ros::WallDuration(0.1));
}

Is the equivalent implementation of ros::spin(). That page should also have some different ways of implementing multhread spinning, although none of them are event driven that I can tell.

From the Callbacks and Subscribers wiki,

#include <ros/callback_queue.h>
ros::NodeHandle n;
while (ros::ok())
{
  ros::getGlobalCallbackQueue()->callAvailable(ros::WallDuration(0.1));
}

Is the equivalent implementation of ros::spin(). That page should also have some different ways of implementing multhread spinning, although none of them are event driven that I can tell. .

Edit: From @gvdhoorn's comments below, callAvaliable waits on a condition variable for the given duration, making spin majority event driven.