How to decide the thread count for AsyncSpinner?
I am using AsyncSpinner on ROS Indigo to receive the data from multiple point cloud sensors simultaneously. Below is the same code:
int main(int argc, char** argv)
{
ros::init(argc, argv, "listener");
ros::NodeHandle n;
ros::Subscriber sub1 = n.subscribe<sensor_msgs::PointCloud2>("point_cloud1", 1, callback1);
ros::Subscriber sub2 = n.subscribe<sensor_msgs::PointCloud2>("point_cloud2", 1, callback2);
ros::Subscriber sub3 = n.subscribe<sensor_msgs::PointCloud2>("point_cloud3", 1, callback3);
int point_cloud_subs_count = 3;
ros::AsyncSpinner spinner(point_cloud_subs_count);
spinner.start();
while (ros::ok()) {
// todo
pub.publish(some_data);
rate.sleep();
}
return 0;
}
In the above code, I have three point cloud subscribers. Hence in order to receive the data from them, I have defined 3 threads. My guess is that each thread is allocated for each subscriber. However, I am not sure.
Following are my questions:
- How to decide the thread count for AsyncSpinner?
- Does using
ros::spinOnce()
have the same effect?