SegmentRansacShapeExtractor.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @package VisionX::ArmarXObjects::SegmentRansacShapeExtractor
17  * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu )
18  * @date 2019
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 #pragma once
24 
25 #include <pcl/point_types.h>
26 
27 #include <SemanticObjectRelations/ShapeExtraction/ShapeExtraction.h>
28 
31 
32 
33 #include <ArmarXCore/interface/observers/ObserverInterface.h>
35 
36 #include <VisionX/interface/libraries/SemanticObjectRelations/ShapesTopic.h>
37 #include <VisionX/interface/components/SegmentRansacShapeExtractor.h>
39 
40 
41 namespace visionx
42 {
43 
44  /**
45  * @class SegmentRansacShapeExtractorPropertyDefinitions
46  * @brief Property definitions of `SegmentRansacShapeExtractor`.
47  */
50  {
51  public:
53  };
54 
55 
56  /**
57  * @defgroup Component-SegmentRansacShapeExtractor SegmentRansacShapeExtractor
58  * @ingroup VisionX-Components
59  * A description of the component SegmentRansacShapeExtractor.
60  *
61  * @class SegmentRansacShapeExtractor
62  * @ingroup Component-SegmentRansacShapeExtractor
63  * @brief Brief description of class SegmentRansacShapeExtractor.
64  *
65  * Detailed description of class SegmentRansacShapeExtractor.
66  */
68  virtual public visionx::PointCloudProcessor,
69  virtual public visionx::SegmentRansacShapeExtractorInterface
70  {
71  /// The used point type.
72  using PointT = pcl::PointXYZRGBL;
73 
74  public:
75 
76  /// @see armarx::ManagedIceObject::getDefaultName()
77  std::string getDefaultName() const override;
78 
79 
80  // SegmentRansacShapeExtractorInterface interface
81  armarx::semantic::data::ShapeList extractShapes(const Ice::Current& = Ice::emptyCurrent) override;
82  armarx::semantic::data::ShapeList getExtractedShapes(const Ice::Current& = Ice::emptyCurrent) override;
83 
84 
85  protected:
86 
87  /// @see visionx::PointCloudProcessor::onInitPointCloudProcessor()
88  void onInitPointCloudProcessor() override;
89 
90  /// @see visionx::PointCloudProcessor::onConnectPointCloudProcessor()
91  void onConnectPointCloudProcessor() override;
92 
93  /// @see visionx::PointCloudProcessor::onDisconnectPointCloudProcessor()
94  void onDisconnectPointCloudProcessor() override;
95 
96  /// @see visionx::PointCloudProcessor::onExitPointCloudProcessor()
97  void onExitPointCloudProcessor() override;
98 
99 
100  /// @see visionx::PointCloudProcessor::process()
101  void process() override;
102 
103 
104  /// @see PropertyUser::createPropertyDefinitions()
106 
107 
108  private:
109 
110 
111  // INPUT
112 
113  std::mutex inputPointCloudMutex;
114 
115  /// The latest received point cloud.
116  pcl::PointCloud<pcl::PointXYZRGBL>::Ptr inputPointCloud;
117 
118 
119  // PROCESSING
120 
121  /// Locked while process is running.
122  std::mutex extractionMutex;
123 
124  /// The shape extraction.
125  semrel::ShapeExtraction shapeExtraction;
126 
127  armarx::SimpleRunningTask<>::pointer_type shapeExtractionTask;
128 
129 
130  // RESULT
131 
132  struct ExtractedShapes
133  {
134 
135  /// Protects `extractedShapes` and `extractedShapesIce`.
136  std::mutex mutex;
137 
138  /// The result of the latest processed point cloud.
139  semrel::ShapeList shapes;
140 
141  /// Serialized version of `shapes`. Is kept up to date.
142  armarx::semantic::data::ShapeList shapesIce;
143  };
144 
145  ExtractedShapes extractedShapes;
146 
147 
148  // ICE
149 
150  armarx::DebugObserverInterfacePrx debugObserver;
151  armarx::DebugDrawerTopic debugDrawer;
152 
153  std::string shapesName;
154  armarx::semantic::ShapesTopicPrx shapesTopic;
155 
156  };
157 }
visionx::SegmentRansacShapeExtractor::onConnectPointCloudProcessor
void onConnectPointCloudProcessor() override
Definition: SegmentRansacShapeExtractor.cpp:152
armarx::DebugDrawerTopic
The DebugDrawerTopic wraps a DebugDrawerInterfacePrx and provides a more useful interface than the Ic...
Definition: DebugDrawerTopic.h:152
visionx::SegmentRansacShapeExtractor::getExtractedShapes
armarx::semantic::data::ShapeList getExtractedShapes(const Ice::Current &=Ice::emptyCurrent) override
Definition: SegmentRansacShapeExtractor.cpp:265
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
visionx::SegmentRansacShapeExtractor::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: SegmentRansacShapeExtractor.cpp:278
visionx::SegmentRansacShapeExtractor::onInitPointCloudProcessor
void onInitPointCloudProcessor() override
Definition: SegmentRansacShapeExtractor.cpp:114
visionx::SegmentRansacShapeExtractor::onDisconnectPointCloudProcessor
void onDisconnectPointCloudProcessor() override
Definition: SegmentRansacShapeExtractor.cpp:164
visionx::SegmentRansacShapeExtractorPropertyDefinitions
Property definitions of SegmentRansacShapeExtractor.
Definition: SegmentRansacShapeExtractor.h:48
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
visionx::SegmentRansacShapeExtractor
Brief description of class SegmentRansacShapeExtractor.
Definition: SegmentRansacShapeExtractor.h:67
visionx::SegmentRansacShapeExtractor::onExitPointCloudProcessor
void onExitPointCloudProcessor() override
Definition: SegmentRansacShapeExtractor.cpp:168
visionx::SegmentRansacShapeExtractor::extractShapes
armarx::semantic::data::ShapeList extractShapes(const Ice::Current &=Ice::emptyCurrent) override
Definition: SegmentRansacShapeExtractor.cpp:228
DebugDrawerTopic.h
visionx::PointCloudProcessor
The PointCloudProcessor class provides an interface for access to PointCloudProviders via Ice and sha...
Definition: PointCloudProcessor.h:186
visionx::PointCloudProcessorPropertyDefinitions
Properties of PointCloudProcessor.
Definition: PointCloudProcessor.h:173
PointCloudProcessor.h
TaskUtil.h
Component.h
visionx::SegmentRansacShapeExtractor::process
void process() override
Definition: SegmentRansacShapeExtractor.cpp:173
IceUtil::Handle< class PropertyDefinitionContainer >
IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface >
visionx::SegmentRansacShapeExtractor::getDefaultName
std::string getDefaultName() const override
Definition: SegmentRansacShapeExtractor.cpp:272
visionx::SegmentRansacShapeExtractorPropertyDefinitions::SegmentRansacShapeExtractorPropertyDefinitions
SegmentRansacShapeExtractorPropertyDefinitions(std::string prefix)
Definition: SegmentRansacShapeExtractor.cpp:39
shapes
MiscLib::Vector< std::pair< MiscLib::RefCountPtr< PrimitiveShape >, size_t > > shapes
Definition: ReadMe.txt:92