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

answered 2012-06-10 14:29:09 -0500

joq gravatar image

For a node, you don't need an extra thread. Within your main() thread, in place of ros::spin(), invoke ros::spinOnce() in a loop. The rest of that loop can read UDP requests, or whatever you want.

while (!ros::shutdown()) {
    ros:spinOnce();
    // process UDP requests
}

Nodelets do need and extra thread for logic like this. I can explain how to do that too, if you are interested.

For a node, you don't need an extra thread. Within your main() thread, in place of ros::spin(), invoke ros::spinOnce() in a loop. The rest of that loop can read UDP requests, or whatever you want.

while (!ros::shutdown()) (ros::ok()) {
    ros:spinOnce();
    // process UDP requests
}

Nodelets do need and extra thread for logic like this. I can explain how to do that too, if you are interested.