AffordancePipelineVisualization.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 Lesser General Public License as
6 * published by the Free Software Foundation; either version 2 of
7 * the License, or (at your option) any later version.
8 *
9 * ArmarX is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * @package VisionX
18 * @author Peter Kaiser (peter dot kaiser at kit dot edu)
19 * @date 2015
20 * @copyright http://www.gnu.org/licenses/gpl.txt
21 * GNU General Public License
22 */
23
24#pragma once
25
26#include <mutex>
27
28#include <Eigen/Eigen>
29
30#include <IceUtil/IceUtil.h>
31
34
35#include <RobotAPI/interface/visualization/DebugDrawerInterface.h>
37
38#include <VisionX/interface/components/AffordancePipelineVisualization.h>
39#include <VisionX/interface/components/PointCloudSegmenter.h>
41
42#include <AffordanceKit/primitives/Box.h>
43#include <AffordanceKit/primitives/Cylinder.h>
44#include <AffordanceKit/primitives/Plane.h>
45#include <AffordanceKit/primitives/Sphere.h>
47#include <MemoryX/interface/components/WorkingMemoryInterface.h>
50
51namespace armarx
52{
53 /**
54 * @class AffordanceExtractionPropertyDefinitions
55 * @brief
56 */
59 {
60 public:
63 {
65 "WorkingMemoryName", "WorkingMemory", "Name of WorkingMemory component");
67 "DebugDrawerTopicName", "DebugDrawerUpdates", "The name of the debug drawer topic");
68 defineOptionalProperty<std::string>("DebugDrawerSelectionsTopicName",
69 "DebugDrawerSelections",
70 "The name of the debug drawer topic");
72 "VisualizationUpdateTopicName",
73 "AffordanceVisualizationTopic",
74 "Topic under which visualization updates are reported");
75 defineOptionalProperty<bool>("EnableDebugDrawerSelections",
76 true,
77 "Allow users to select primitives via debug drawer");
78
80 "EnablePrimitiveVisualization", true, "Initially enable primitive visualization");
82 "EnableAffordanceVisualization", true, "Initially enable affordance visualization");
84 "EnableDebugVisualization", false, "Initially enable debug visualization");
85
87 "VisualizeAffordanceBeliefFunction",
88 "",
89 "The affordance belief function that should initially be visualized");
91 "MinExpectedProbability",
92 0,
93 "Visualize only samplings with expected probability greater than X");
94
96 "NoAffordanceExtractionConfigured",
97 false,
98 "In this case visualization will start as soon as primitives are computed");
99
101 "FileName", "", "Load affordances from a file name and exit.");
102 }
103 };
104
105 /**
106 * @class AffordanceExtraction
107 * @ingroup RobotSkillTemplates-Components
108 * @brief A brief description
109 *
110 * Detailed Description
111 */
113 virtual public Component,
114 virtual public AffordancePipelineVisualizationInterface
115 {
116 public:
118
119 /**
120 * @see armarx::ManagedIceObject::getDefaultName()
121 */
122 std::string
123 getDefaultName() const override
124 {
125 return "AffordancePipelineVisualization";
126 }
127
128 void reportNewPointCloudSegmentation(const Ice::Current& c = Ice::emptyCurrent) override;
129 void reportNewAffordances(const Ice::Current& c = Ice::emptyCurrent) override;
130
131 void selectPrimitive(const std::string& id,
132 const Ice::Current& c = Ice::emptyCurrent) override;
133 void deselectPrimitive(const std::string& id,
134 const Ice::Current& c = Ice::emptyCurrent) override;
135 void deselectAllPrimitives(const Ice::Current& c = Ice::emptyCurrent) override;
136
137 void enableVisualization(bool enablePrimitives,
138 bool enableAffordances,
139 bool enableDebugInformation,
140 const Ice::Current& c = Ice::emptyCurrent) override;
141 void configureAffordanceVisualization(AffordanceVisualizationStyle style,
142 const std::vector<std::string>& primitives,
143 const std::vector<std::string>& affordances,
144 float minExpectedProbability,
145 const Ice::Current& c = Ice::emptyCurrent) override;
146 void triggerVisualization(const Ice::Current& c = Ice::emptyCurrent) override;
147
148 void exportVisualizationAsIV(const std::string& filename,
149 const Ice::Current& c = Ice::emptyCurrent) override;
150 void exportVisualizationAsJSON(const std::string& filename,
151 const Ice::Current& c = Ice::emptyCurrent) override;
152
153 void clearVisualization(const Ice::Current& c = Ice::emptyCurrent) override;
154
155 // DebugDrawerListener interface
156 void reportSelectionChanged(const DebugDrawerSelectionList& selectedObjects,
157 const ::Ice::Current& = Ice::emptyCurrent) override;
158
159 protected:
160 /**
161 * @see armarx::ManagedIceObject::onInitComponent()
162 */
163 void onInitComponent() override;
164
165 /**
166 * @see armarx::ManagedIceObject::onConnectComponent()
167 */
168 void onConnectComponent() override;
169
170 /**
171 * @see armarx::ManagedIceObject::onDisconnectComponent()
172 */
173 void onDisconnectComponent() override;
174
175 /**
176 * @see armarx::ManagedIceObject::onExitComponent()
177 */
178 void onExitComponent() override;
179
180 /**
181 * @see PropertyUser::createPropertyDefinitions()
182 */
184
185 void visualizeScene(const AffordanceKit::ScenePtr& scene,
186 bool updatePrimitives = true,
187 bool updateAffordances = true,
188 bool updateDebugInfo = true);
189 void visualizePrimitives(const AffordanceKit::PrimitiveSetPtr& primitives);
190 void visualizePrimitive(const AffordanceKit::PrimitivePtr& primitive);
191 void visualizeAffordances(const AffordanceKit::ScenePtr& scene);
192 void visualizeAffordance(const AffordanceKit::AffordancePtr& affordance,
193 const AffordanceKit::PrimitivePtr& primitve,
194 unsigned int index);
195 void visualizeAffordanceLabels(const AffordanceKit::PrimitivePtr& primitive,
196 const std::vector<std::string>& labels);
197 void visualizeDebugInformation(const AffordanceKit::ScenePtr& scene);
198
199 void visualizePlane(const AffordanceKit::PlanePtr& plane);
200 void visualizeSphere(const AffordanceKit::SpherePtr& sphere);
201 void visualizeCylinder(const AffordanceKit::CylinderPtr& cylinder);
202 void visualizeBox(const AffordanceKit::BoxPtr& box);
203
204 protected:
205 void visualize(bool updatePrimitives = true,
206 bool updateAffordances = true,
207 bool updateDebugInfo = true);
208
209 protected:
211 AffordancePipelineVisualizationListenerPrx affordanceVisualizationTopicPrx;
212 memoryx::WorkingMemoryInterfacePrx workingMemoryPrx;
213 memoryx::AffordanceSegmentBasePrx affordanceSegment;
214 memoryx::EnvironmentalPrimitiveSegmentBasePrx environmentalPrimitiveSegment;
215
216 std::set<std::string> selections;
217
218 std::map<int, std::list<std::string>> labelMap;
219
220 DrawColor primitiveColor;
223
225
229
230 AffordanceVisualizationStyle visualizationStyle;
231 std::vector<std::string> visualizationPrimitiveSet;
232 std::vector<std::string> visualizationAffordanceSet;
234
235 std::mutex sceneMutex;
237 };
238} // namespace armarx
uint8_t index
constexpr T c
void visualize(bool updatePrimitives=true, bool updateAffordances=true, bool updateDebugInfo=true)
void visualizeBox(const AffordanceKit::BoxPtr &box)
void visualizePrimitive(const AffordanceKit::PrimitivePtr &primitive)
void visualizePrimitives(const AffordanceKit::PrimitiveSetPtr &primitives)
void deselectAllPrimitives(const Ice::Current &c=Ice::emptyCurrent) override
void visualizePlane(const AffordanceKit::PlanePtr &plane)
void triggerVisualization(const Ice::Current &c=Ice::emptyCurrent) override
void enableVisualization(bool enablePrimitives, bool enableAffordances, bool enableDebugInformation, const Ice::Current &c=Ice::emptyCurrent) override
void visualizeAffordance(const AffordanceKit::AffordancePtr &affordance, const AffordanceKit::PrimitivePtr &primitve, unsigned int index)
void reportNewPointCloudSegmentation(const Ice::Current &c=Ice::emptyCurrent) override
void visualizeScene(const AffordanceKit::ScenePtr &scene, bool updatePrimitives=true, bool updateAffordances=true, bool updateDebugInfo=true)
void configureAffordanceVisualization(AffordanceVisualizationStyle style, const std::vector< std::string > &primitives, const std::vector< std::string > &affordances, float minExpectedProbability, const Ice::Current &c=Ice::emptyCurrent) override
void visualizeCylinder(const AffordanceKit::CylinderPtr &cylinder)
void exportVisualizationAsIV(const std::string &filename, const Ice::Current &c=Ice::emptyCurrent) override
void clearVisualization(const Ice::Current &c=Ice::emptyCurrent) override
PropertyDefinitionsPtr createPropertyDefinitions() override
void visualizeDebugInformation(const AffordanceKit::ScenePtr &scene)
void deselectPrimitive(const std::string &id, const Ice::Current &c=Ice::emptyCurrent) override
void visualizeAffordances(const AffordanceKit::ScenePtr &scene)
void visualizeSphere(const AffordanceKit::SpherePtr &sphere)
void exportVisualizationAsJSON(const std::string &filename, const Ice::Current &c=Ice::emptyCurrent) override
void reportSelectionChanged(const DebugDrawerSelectionList &selectedObjects, const ::Ice::Current &=Ice::emptyCurrent) override
memoryx::EnvironmentalPrimitiveSegmentBasePrx environmentalPrimitiveSegment
std::map< int, std::list< std::string > > labelMap
void selectPrimitive(const std::string &id, const Ice::Current &c=Ice::emptyCurrent) override
AffordancePipelineVisualizationListenerPrx affordanceVisualizationTopicPrx
void visualizeAffordanceLabels(const AffordanceKit::PrimitivePtr &primitive, const std::vector< std::string > &labels)
void reportNewAffordances(const Ice::Current &c=Ice::emptyCurrent) override
Default component property definition container.
Definition Component.h:70
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition Component.cpp:46
Component()
Protected default constructor. Used for virtual inheritance. Use createManagedIceObject() instead.
Definition Component.cpp:66
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
std::shared_ptr< SceneArmarX > SceneArmarXPtr
Definition SceneArmarX.h:52
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface > DebugDrawerInterfacePrx