23 #ifndef _ARMARX_COMPONENT_ActiveVision_TabletopSegmentation_H
24 #define _ARMARX_COMPONENT_ActiveVision_TabletopSegmentation_H
31 #include <ArmarXCore/interface/observers/ObserverInterface.h>
32 #include <ArmarXCore/interface/observers/RequestableService.h>
33 #include <ArmarXGui/interface/RemoteGuiInterface.h>
35 #include <RobotAPI/interface/visualization/DebugDrawerInterface.h>
36 #include <VisionX/interface/components/TabletopSegmentationInterface.h>
40 #include <pcl/point_types.h>
42 #include <pcl/ModelCoefficients.h>
45 #include <pcl/common/angles.h>
47 #include <pcl/segmentation/sac_segmentation.h>
48 #include <pcl/segmentation/extract_clusters.h>
49 #include <pcl/filters/extract_indices.h>
50 #include <pcl/filters/passthrough.h>
52 #include <pcl/segmentation/extract_polygonal_prism_data.h>
53 #include <pcl/surface/convex_hull.h>
63 ServiceProvider(
const std::string& serviceName,
const std::function<
void(
int)>& callback);
69 std::string serviceName;
70 std::function<void(
int)> callback;
74 typedef pcl::PointXYZRGBA
PointT;
88 defineOptionalProperty<std::string>(
"DebugObserverName",
"DebugObserver",
"Name of the topic the DebugObserver listens on");
89 defineOptionalProperty<std::string>(
"DebugDrawerTopicName",
"DebugDrawerUpdates",
"Name of the DebugDrawerTopic");
90 defineOptionalProperty<std::string>(
"RemoteGuiName",
"RemoteGuiProvider",
"Name of the remote gui provider");
93 defineOptionalProperty<double>(
"DistanceThreshold", 20.0,
"The distance threshold for the plane.");
94 defineOptionalProperty<double>(
"EpsAngle", pcl::deg2rad(10.0),
"The eps angle (in rad) for the plane perpendicular to the z-axis. If zero the perpendicular constraint is removed.");
96 defineOptionalProperty<bool>(
"IncludeTabletopPlane",
false,
"If enabled the points from the tabletop plane will be added as a separate cluster.");
97 defineOptionalProperty<bool>(
"CalculatePlane",
true,
"Calculate plane");
99 defineOptionalProperty<double>(
"ClusterTolerance", 20.0,
"the tolerance used for euclidean cluster extraction.");
100 defineOptionalProperty<int>(
"MinClusterSize", 100,
"The minimum size of a cluster.");
101 defineOptionalProperty<int>(
"MaxClusterSize", 25000,
"The maximum size of a cluster.");
103 defineOptionalProperty<double>(
"HeightMin", 0.0,
"The minimum distance to the plane.");
104 defineOptionalProperty<double>(
"HeightMax", 500.0,
"The maximum distance to the plane.");
121 :
virtual public visionx::TabletopSegmentationInterface
130 return "TabletopSegmentation";
166 visionx::TabletopSegmentationPlanePtr
getTablePlane(
const Ice::Current&)
override;
169 void extractEuclideanClusters(
const pcl::PointCloud<PointT>::ConstPtr& inputCloud,
const pcl::PointCloud<PointL>::Ptr& resultCloud);
178 RemoteGuiInterfacePrx remoteGui;
181 pcl::SACSegmentation<PointT> seg;
183 bool includeTabletopPlane;
184 pcl::EuclideanClusterExtraction<PointT> ec;
186 pcl::ExtractIndices<PointT> extract;
188 pcl::ExtractPolygonalPrismData<PointT> prism;
189 pcl::ConvexHull<PointT> hull;
194 std::mutex tablePlaneMutex;
195 visionx::TabletopSegmentationPlanePtr tablePlane;
198 std::mutex prop_mutex;
200 float prop_DistanceThreshold = 20.0;
201 float prop_EpsAngle = pcl::deg2rad(10.0);
203 float prop_ClusterTolerance = 20.0;
204 int prop_MinClusterSize = 100;
205 int prop_MaxClusterSize = 25000;
207 float prop_HeightMin = 0.0;
208 float prop_HeightMax = 500.0;
210 bool prop_IncludeTabletopPlane =
false;
211 bool prop_CalculatePlane =
true;