ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
ros::spin
processes messages from the callback queue. From Section 1 of the Callback and Spinning Overview:
Implementing a spin() of our own is quite simple:
#include <ros/callback_queue.h>
ros::NodeHandle n;
while (ros::ok())
{
ros::getGlobalCallbackQueue()->callAvailable(ros::WallDuration(0.1));
}
Briefly: the callback queue is associated with a NodeHandle
; the NodeHandle
is used to create your publishers and subscribers, which associates those pubs/subs with the callback queue; since you pass private_nh
as a parameter to you ObjDet
instance, I assume that's where your pubs/subs are created.
To your questions: no, the constructor/destructor will not be run each loop. It's not clear to me what you mean by "range in the loop". No, once spin
is called, nothing after it is run until ros::ok()
returns false (it's a non-returning call).