ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Try this for your callback:
void
cloud_cb (const sensor_msgs::PointCloud2ConstPtr& input)
{
// Convert the sensor_msgs/PointCloud2 data to pcl/PointCloud
pcl::PointCloud<pcl::PointXYZ>::Ptr
cloud(new pcl::PointCloud<pcl::PointXYZ> ()),
cloud_filtered(new pcl::PointCloud<pcl::PointXYZ> ());
pcl::fromROSMsg (*input, *cloud);
pcl::StatisticalOutlierRemoval<pcl::PointXYZ> sor;
sor.setInputCloud (cloud);
sor.setMeanK (50);
sor.setStddevMulThresh (1.0);
sor.filter (*cloud_filtered);
sensor_msgs::PointCloud2::Ptr
cloud_filtered2(new sensor_msgs::PointCloud2 ());
pcl::toROSMsg (*cloud_filtered, *cloud_filtered2);
// Publish the dataSize
pub.publish (cloud_filtered2);
}
Does that do what you want?