ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
I don't think you need to call nh.subscribe("/camera/depth/points", 5, subCallback);
from inside the while loop. That just re-subscribes to the topic over and over again. I'm not sure what kind of noise that creates in ROS's backend, but I'm guessing it's unnecessary at best.
Also, why are you publishing in the while? Why not publish directly from inside your callback if the point cloud message fits your criteria?
To stop your main thread from exiting, I think all you need is ros::spin();