Help understanding how fast the sensor_msgs::PointCloud2 from the openni_camera are received
Hello,
I've been working a little with ROS but I have some doubts. I'm trying to figure out how many messages do I receive per second from a topic to which I'm subscribed. I suppose it depends of the speed with which they're published by the node. I'm talking about the openni_camera node and the "camera/rgb/points" topic. Please tell me if I'm getting this alright:
Here's a typical main for a node:
int main (int argc, char** argv) {
// Initialize ROS
ros::init (argc, argv, "sergio_filter");
ros::NodeHandle nh;// Create a ROS subscriber for the input point cloud
ros::Subscriber sub = nh.subscribe ("camera/rgb/points", 10, cloud_cb);// Spin
ros::spin (); }
So, the cloud_cb is a callback function that is called each time a message from the subscribed topic is received, right? I did a simple study of the time that is takes to receive 1, 10 and 100 messages from the openni_camera and I got some unstable results =P. For example, to receive 10 sensor_msgs::PointCloud2 it takes between 0.444811 and 0.507768 seconds, so we could say that I receive ~20 msgs per sec. I guess this variation in time depends of the number of points that the Kinect is able to get in the pointcloud at a given time.
Isn't there any elegant ROS way or configuration to just "listen" to, let's say, 2 messages per second? Other than just using an:
void cloud_cb (const sensor_msgs::PointCloud2ConstPtr& input) {
if(i==10){ processing algorithm i=0; } else{ do nothing } i++; }
Given that my Point Cloud Library based algorithm isn't (for now) very fast, 20 pointclouds per second would be too much.
Let's say that my algorithm inside the cloud_cb callback function takes a whole second to complete. During this time my node is deaf to the other sensor_msgs::PointCloud2? Just one cloud_cb function can run at a time right? No parallel processing here. If I use a subscriber's buffer of 1, then when my cloud_cb function finishes, another instance will pop up with the NEXT message that arrives, right? While if I use a buffer of 50, it'll pop up with the next message in the queue.
Am I getting all this alright ?
Thank you for any help!
Best Regards,