19 #include <pcl/segmentation/extract_clusters.h> 32 ROS_WARN(
"FODDetector: invalid tolerance value: %f", tolerance);
47 pcl::search::KdTree<pcl::PointXYZRGB>::Ptr tree(
new pcl::search::KdTree<pcl::PointXYZRGB>);
48 tree->setInputCloud(
cloud_);
50 pcl::EuclideanClusterExtraction<pcl::PointXYZRGB> ec;
54 ec.setSearchMethod(tree);
67 for (std::vector<int>::const_iterator pit = it->indices.begin(); pit != it->indices.end(); ++pit)
68 cloud_cluster->points.push_back(
cloud_->points[*pit]);
69 cloud_cluster->width = cloud_cluster->points.size();
70 cloud_cluster->height = 1;
71 cloud_cluster->is_dense =
true;
72 ROS_INFO(
"cluster_size: %zd", cloud_cluster->points.size());
74 fod_cloud_array.push_back(cloud_cluster);
82 std::vector<PointCloudRGB::Ptr> fod_cloud_array;
85 sensor_msgs::PointCloud2 cluster_msg;
86 for (
const auto &cloud : fod_cloud_array)
89 fod_msg_array.push_back(cluster_msg);
93 ROS_INFO(
"msg_size: %zd", fod_msg_array.size());
int fodIndicesToPointCloud(std::vector< PointCloudRGB::Ptr > &cloud_array)
Save each cluster (possible FOD) in a pcl::PointCloudRGB. Give back an array of all generated clouds...
double cluster_tolerance_
Tolerance to set as cluster tolerance.
void getFODIndices(std::vector< pcl::PointIndices > &fod_indices)
Get the FOD indices computed in clusterPossibleFODs()
static void cloudToROSMsg(PointCloudRGB::Ptr cloud, sensor_msgs::PointCloud2 &cloud_msg, const std::string &frameid="world")
Convert XYZRGB cloud to PointCloud2.
PointCloudRGB::Ptr cloud_
Input cloud.
void setClusterTolerance(double tolerance)
Set the Cluster Tolerance object.
pcl::PointCloud< pcl::PointXYZRGB > PointCloudRGB
std::vector< pcl::PointIndices > cluster_indices_
Cluster indices to be identified as FODs.
void clusterPossibleFODs()
Extract cluster indices from input cloud with resolution set. Each cluster is a possible FOD...
int fodIndicesToROSMsg(std::vector< sensor_msgs::PointCloud2 > &cluster_msg_array)
Save each cluster (possible FOD) in a PointCloud2 msg. Give back an array of all generated msgs...
FODDetector(PointCloudRGB::Ptr cloud, double cluster_tolerance, double min_fod_points)
Construct a new FODDetector object with given tolerance and minimal fod points.
void setMinFODpoints(double min_fod_points)
Set the Min FOD points object.
double min_cluster_size_
Min number of points to identify a cluster.