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 
27 
28 #include <RobotAPI/interface/visualization/DebugDrawerInterface.h>
30 
31 #include <MemoryX/interface/components/WorkingMemoryInterface.h>
34 
35 #include <VisionX/interface/components/PointCloudSegmenter.h>
37 
38 #include <mutex>
39 
40 namespace armarx
41 {
42 
44  {
46 
47  };
48 
49  /**
50  * @class PrimitiveVisualizationPropertyDefinitions
51  * @brief
52  */
55  {
56  public:
59  {
60  defineOptionalProperty<std::string>("WorkingMemoryName", "WorkingMemory", "Name of WorkingMemory component");
61  defineOptionalProperty<PLANE_VISUALIZATION_METHOD>("PlaneVisualizationMethod", Hull, "Visualize planes as boxes, as rectangles or as convex hulls")
62  .map("Inlier", Inlier)
63  .map("Hull", Hull)
64  .map("OBB", Obb)
65  .map("Box", Obb)
66  .map("ConvexHull", Hull)
67  .map("Rectangle", Rectangle);
68 
69  }
70  };
71 
72  /**
73  * @defgroup Component-PrimitiveVisualization PrimitiveVisualization
74  * @ingroup VisionX-Components
75  * A description of the component PrimitiveVisualization.
76  *
77  * @class PrimitiveVisualization
78  * @ingroup Component-PrimitiveVisualization
79  * @brief Brief description of class PrimitiveVisualization.
80  *
81  * Detailed description of class PrimitiveVisualization.
82  */
84  virtual public armarx::Component,
85  virtual public visionx::PointCloudSegmentationListener,
87  {
88  public:
89  /**
90  * @see armarx::ManagedIceObject::getDefaultName()
91  */
92  std::string getDefaultName() const override
93  {
94  return "PrimitiveVisualization";
95  }
96 
97 
98  void reportNewPointCloudSegmentation(const Ice::Current& c = Ice::emptyCurrent) override;
99  protected:
100  /**
101  * @see armarx::ManagedIceObject::onInitComponent()
102  */
103  void onInitComponent() override;
104 
105  /**
106  * @see armarx::ManagedIceObject::onConnectComponent()
107  */
108  void onConnectComponent() override;
109 
110  /**
111  * @see armarx::ManagedIceObject::onDisconnectComponent()
112  */
113  void onDisconnectComponent() override;
114 
115  /**
116  * @see armarx::ManagedIceObject::onExitComponent()
117  */
118  void onExitComponent() override;
119 
120  /**
121  * @see PropertyUser::createPropertyDefinitions()
122  */
124 
125 
126  protected:
127 
128 
130 
131  memoryx::WorkingMemoryInterfacePrx workingMemory;
132  memoryx::EnvironmentalPrimitiveSegmentBasePrx environmentalPrimitiveSegment;
133 
134 
135  private:
136 
137  void clearDebugLayer();
138 
139  std::mutex mutex;
140 
141  viz::Color getPrimitiveColor(const memoryx::EnvironmentalPrimitiveBasePtr& primitive);
142 
143  void visualizePrimitive(const memoryx::EnvironmentalPrimitiveBasePtr& primitive, viz::Color color);
144  void visualizePlane(const memoryx::PlanePrimitiveBasePtr& plane, viz::Color color);
145  void visualizeSphere(const memoryx::SpherePrimitiveBasePtr& sphere, viz::Color color);
146  void visualizeCylinder(const memoryx::CylinderPrimitiveBasePtr& cylinder, viz::Color color);
147 
148  viz::Color primitiveColorFrame;
149 
150  viz::Layer layer = {};
151 
152  };
153 }
154 
armarx::PrimitiveVisualization::getDefaultName
std::string getDefaultName() const override
Definition: PrimitiveVisualization.h:92
ArVizComponentPlugin.h
SegmentedMemory.h
armarx::PrimitiveVisualizationPropertyDefinitions::PrimitiveVisualizationPropertyDefinitions
PrimitiveVisualizationPropertyDefinitions(std::string prefix)
Definition: PrimitiveVisualization.h:57
armarx::PrimitiveVisualization::debugDrawer
DebugDrawerInterfacePrx debugDrawer
Definition: PrimitiveVisualization.h:129
armarx::Inlier
@ Inlier
Definition: PrimitiveVisualization.h:45
armarx::PrimitiveVisualizationPropertyDefinitions
Definition: PrimitiveVisualization.h:53
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
EnvironmentalPrimitiveSegment.h
armarx::PrimitiveVisualization::onConnectComponent
void onConnectComponent() override
Definition: PrimitiveVisualization.cpp:49
armarx::Rectangle
@ Rectangle
Definition: PrimitiveVisualization.h:45
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:36
armarx::PrimitiveVisualization::workingMemory
memoryx::WorkingMemoryInterfacePrx workingMemory
Definition: PrimitiveVisualization.h:131
armarx::PrimitiveVisualization::onInitComponent
void onInitComponent() override
Definition: PrimitiveVisualization.cpp:39
FramedPose.h
armarx::viz::Color
Definition: Color.h:13
armarx::Obb
@ Obb
Definition: PrimitiveVisualization.h:45
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:95
armarx::PrimitiveVisualization::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: PrimitiveVisualization.cpp:237
armarx::PrimitiveVisualization::reportNewPointCloudSegmentation
void reportNewPointCloudSegmentation(const Ice::Current &c=Ice::emptyCurrent) override
Definition: PrimitiveVisualization.cpp:69
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:70
armarx::PrimitiveVisualization
Brief description of class PrimitiveVisualization.
Definition: PrimitiveVisualization.h:83
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:132
armarx::PrimitiveVisualization::onExitComponent
void onExitComponent() override
Definition: PrimitiveVisualization.cpp:62
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28