23 #ifndef _ARMARX_COMPONENT_ActiveVision_TabletopSegmentation_H
24 #define _ARMARX_COMPONENT_ActiveVision_TabletopSegmentation_H
27 #include <pcl/ModelCoefficients.h>
28 #include <pcl/common/angles.h>
29 #include <pcl/filters/extract_indices.h>
30 #include <pcl/filters/passthrough.h>
31 #include <pcl/point_types.h>
32 #include <pcl/segmentation/extract_clusters.h>
33 #include <pcl/segmentation/extract_polygonal_prism_data.h>
34 #include <pcl/segmentation/sac_segmentation.h>
35 #include <pcl/surface/convex_hull.h>
38 #include <ArmarXCore/interface/observers/ObserverInterface.h>
39 #include <ArmarXCore/interface/observers/RequestableService.h>
41 #include <ArmarXGui/interface/RemoteGuiInterface.h>
44 #include <RobotAPI/interface/visualization/DebugDrawerInterface.h>
47 #include <VisionX/interface/components/TabletopSegmentationInterface.h>
55 ServiceProvider(
const std::string& serviceName,
const std::function<
void(
int)>& callback);
66 std::string serviceName;
67 std::function<void(
int)> callback;
72 typedef pcl::PointXYZRGBA
PointT;
86 defineOptionalProperty<std::string>(
"DebugObserverName",
88 "Name of the topic the DebugObserver listens on");
89 defineOptionalProperty<std::string>(
90 "DebugDrawerTopicName",
"DebugDrawerUpdates",
"Name of the DebugDrawerTopic");
91 defineOptionalProperty<std::string>(
92 "RemoteGuiName",
"RemoteGuiProvider",
"Name of the remote gui provider");
93 defineOptionalProperty<bool>(
"AlwaysActive",
95 "If enabled the component runs always. Otherwise only "
96 "when requested via the requestable service interface.",
99 defineOptionalProperty<double>(
100 "DistanceThreshold", 20.0,
"The distance threshold for the plane.");
101 defineOptionalProperty<double>(
104 "The eps angle (in rad) for the plane perpendicular to the z-axis. If zero the "
105 "perpendicular constraint is removed.");
107 defineOptionalProperty<bool>(
"IncludeTabletopPlane",
109 "If enabled the points from the tabletop plane will be "
110 "added as a separate cluster.");
111 defineOptionalProperty<bool>(
"CalculatePlane",
true,
"Calculate plane");
113 defineOptionalProperty<double>(
114 "ClusterTolerance", 20.0,
"the tolerance used for euclidean cluster extraction.");
115 defineOptionalProperty<int>(
"MinClusterSize", 100,
"The minimum size of a cluster.");
116 defineOptionalProperty<int>(
"MaxClusterSize", 25000,
"The maximum size of a cluster.");
118 defineOptionalProperty<double>(
"HeightMin", 0.0,
"The minimum distance to the plane.");
119 defineOptionalProperty<double>(
120 "HeightMax", 500.0,
"The maximum distance to the plane.");
137 virtual public visionx::TabletopSegmentationInterface,
147 return "TabletopSegmentation";
183 visionx::TabletopSegmentationPlanePtr
getTablePlane(
const Ice::Current&)
override;
186 void extractEuclideanClusters(
const pcl::PointCloud<PointT>::ConstPtr& inputCloud,
187 const pcl::PointCloud<PointL>::Ptr& resultCloud);
196 RemoteGuiInterfacePrx remoteGui;
199 pcl::SACSegmentation<PointT> seg;
201 bool includeTabletopPlane;
202 pcl::EuclideanClusterExtraction<PointT> ec;
204 pcl::ExtractIndices<PointT> extract;
206 pcl::ExtractPolygonalPrismData<PointT> prism;
207 pcl::ConvexHull<PointT> hull;
212 std::mutex tablePlaneMutex;
213 visionx::TabletopSegmentationPlanePtr tablePlane;
216 std::mutex prop_mutex;
218 float prop_DistanceThreshold = 20.0;
219 float prop_EpsAngle = pcl::deg2rad(10.0);
221 float prop_ClusterTolerance = 20.0;
222 int prop_MinClusterSize = 100;
223 int prop_MaxClusterSize = 25000;
225 float prop_HeightMin = 0.0;
226 float prop_HeightMax = 500.0;
228 bool prop_IncludeTabletopPlane =
false;
229 bool prop_CalculatePlane =
true;