PrimitiveVisualization.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::PrimitiveVisualization
17  * @author Markus Grotz ( markus dot grotz at kit dot edu )
18  * @date 2016
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 #pragma once
24 
25 
26 #include <mutex>
27 
29 
30 #include <RobotAPI/interface/visualization/DebugDrawerInterface.h>
33 
34 #include <VisionX/interface/components/PointCloudSegmenter.h>
35 
37 #include <MemoryX/interface/components/WorkingMemoryInterface.h>
39 
40 namespace armarx
41 {
42 
44  {
47  Obb,
49  };
50 
51  /**
52  * @class PrimitiveVisualizationPropertyDefinitions
53  * @brief
54  */
56  {
57  public:
60  {
61  defineOptionalProperty<std::string>(
62  "WorkingMemoryName", "WorkingMemory", "Name of WorkingMemory component");
63  defineOptionalProperty<PLANE_VISUALIZATION_METHOD>(
64  "PlaneVisualizationMethod",
65  Hull,
66  "Visualize planes as boxes, as rectangles or as convex hulls")
67  .map("Inlier", Inlier)
68  .map("Hull", Hull)
69  .map("OBB", Obb)
70  .map("Box", Obb)
71  .map("ConvexHull", Hull)
72  .map("Rectangle", Rectangle);
73  }
74  };
75 
76  /**
77  * @defgroup Component-PrimitiveVisualization PrimitiveVisualization
78  * @ingroup VisionX-Components
79  * A description of the component PrimitiveVisualization.
80  *
81  * @class PrimitiveVisualization
82  * @ingroup Component-PrimitiveVisualization
83  * @brief Brief description of class PrimitiveVisualization.
84  *
85  * Detailed description of class PrimitiveVisualization.
86  */
88  virtual public armarx::Component,
89  virtual public visionx::PointCloudSegmentationListener,
91  {
92  public:
93  /**
94  * @see armarx::ManagedIceObject::getDefaultName()
95  */
96  std::string
97  getDefaultName() const override
98  {
99  return "PrimitiveVisualization";
100  }
101 
102  void reportNewPointCloudSegmentation(const Ice::Current& c = Ice::emptyCurrent) override;
103 
104  protected:
105  /**
106  * @see armarx::ManagedIceObject::onInitComponent()
107  */
108  void onInitComponent() override;
109 
110  /**
111  * @see armarx::ManagedIceObject::onConnectComponent()
112  */
113  void onConnectComponent() override;
114 
115  /**
116  * @see armarx::ManagedIceObject::onDisconnectComponent()
117  */
118  void onDisconnectComponent() override;
119 
120  /**
121  * @see armarx::ManagedIceObject::onExitComponent()
122  */
123  void onExitComponent() override;
124 
125  /**
126  * @see PropertyUser::createPropertyDefinitions()
127  */
129 
130 
131  protected:
133 
134  memoryx::WorkingMemoryInterfacePrx workingMemory;
135  memoryx::EnvironmentalPrimitiveSegmentBasePrx environmentalPrimitiveSegment;
136 
137 
138  private:
139  void clearDebugLayer();
140 
141  std::mutex mutex;
142 
143  viz::Color getPrimitiveColor(const memoryx::EnvironmentalPrimitiveBasePtr& primitive);
144 
145  void visualizePrimitive(const memoryx::EnvironmentalPrimitiveBasePtr& primitive,
146  viz::Color color);
147  void visualizePlane(const memoryx::PlanePrimitiveBasePtr& plane, viz::Color color);
148  void visualizeSphere(const memoryx::SpherePrimitiveBasePtr& sphere, viz::Color color);
149  void visualizeCylinder(const memoryx::CylinderPrimitiveBasePtr& cylinder, viz::Color color);
150 
151  viz::Color primitiveColorFrame;
152 
153  viz::Layer layer = {};
154  };
155 } // namespace armarx
armarx::PrimitiveVisualization::getDefaultName
std::string getDefaultName() const override
Definition: PrimitiveVisualization.h:97
ArVizComponentPlugin.h
SegmentedMemory.h
armarx::PrimitiveVisualizationPropertyDefinitions::PrimitiveVisualizationPropertyDefinitions
PrimitiveVisualizationPropertyDefinitions(std::string prefix)
Definition: PrimitiveVisualization.h:58
armarx::PrimitiveVisualization::debugDrawer
DebugDrawerInterfacePrx debugDrawer
Definition: PrimitiveVisualization.h:132
armarx::Inlier
@ Inlier
Definition: PrimitiveVisualization.h:46
armarx::PrimitiveVisualizationPropertyDefinitions
Definition: PrimitiveVisualization.h:55
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:345
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
EnvironmentalPrimitiveSegment.h
armarx::PrimitiveVisualization::onConnectComponent
void onConnectComponent() override
Definition: PrimitiveVisualization.cpp:48
armarx::Rectangle
@ Rectangle
Definition: PrimitiveVisualization.h:48
armarx::PLANE_VISUALIZATION_METHOD
PLANE_VISUALIZATION_METHOD
Definition: PrimitiveVisualization.h:43
armarx::ArVizComponentPluginUser
Provides a ready-to-use ArViz client arviz as member variable.
Definition: ArVizComponentPlugin.h:35
armarx::PrimitiveVisualization::workingMemory
memoryx::WorkingMemoryInterfacePrx workingMemory
Definition: PrimitiveVisualization.h:134
armarx::PrimitiveVisualization::onInitComponent
void onInitComponent() override
Definition: PrimitiveVisualization.cpp:38
FramedPose.h
armarx::viz::Color
Definition: Color.h:12
armarx::Obb
@ Obb
Definition: PrimitiveVisualization.h:47
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:91
armarx::PrimitiveVisualization::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: PrimitiveVisualization.cpp:245
armarx::PrimitiveVisualization::reportNewPointCloudSegmentation
void reportNewPointCloudSegmentation(const Ice::Current &c=Ice::emptyCurrent) override
Definition: PrimitiveVisualization.cpp:66
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:69
armarx::PrimitiveVisualization
Brief description of class PrimitiveVisualization.
Definition: PrimitiveVisualization.h:87
IceUtil::Handle< class PropertyDefinitionContainer >
IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface >
armarx::PrimitiveVisualization::onDisconnectComponent
void onDisconnectComponent() override
Definition: PrimitiveVisualization.cpp:56
armarx::Hull
@ Hull
Definition: PrimitiveVisualization.h:45
armarx::viz::Layer
Definition: Layer.h:12
armarx::PrimitiveVisualization::environmentalPrimitiveSegment
memoryx::EnvironmentalPrimitiveSegmentBasePrx environmentalPrimitiveSegment
Definition: PrimitiveVisualization.h:135
armarx::PrimitiveVisualization::onExitComponent
void onExitComponent() override
Definition: PrimitiveVisualization.cpp:61
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27