#include // PCL specific includes #include #include #include #include ros::Publisher pub; void cloud_cb (const pcl::PCLPointCloud2ConstPtr& cloud) { pcl::PCLPointCloud2 cloud_filtered; // Perform the actual filtering pcl::VoxelGrid sor; sor.setInputCloud (cloud); sor.setLeafSize (0.1, 0.1, 0.1); sor.filter (cloud_filtered); // Publish the data pub.publish (cloud_filtered); } int main (int argc, char** argv) { // Initialize ROS ros::init (argc, argv, "my_pcl_tutorial"); ros::NodeHandle nh; // Create a ROS subscriber for the input point cloud ros::Subscriber sub = nh.subscribe ("input", 1, cloud_cb); // Create a ROS publisher for the output point cloud pub = nh.advertise ("output", 1); // Spin ros::spin (); }