EntityDrawerComponent.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package MemoryX::ArmarXObjects::EntityDrawerComponent
19 * @author Nikolaus Vahrenkamp ( vahrenkamp at kit dot edu )
20 * @date 2015
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24
25#pragma once
26
27
28// Coin3D & SoQt
29
30#include <Inventor/nodes/SoNode.h>
31#include <Inventor/nodes/SoSeparator.h>
32#include <Inventor/sensors/SoTimerSensor.h>
33
34// ArmarX
36
38
40#include <MemoryX/interface/components/PriorKnowledgeInterface.h>
41#include <MemoryX/interface/gui/EntityDrawerInterface.h>
42#include <MemoryX/interface/memorytypes/MemoryEntities.h>
44
45namespace memoryx
46{
47
48 /*!
49 * \class EntityDrawerPropertyDefinitions
50 * \brief
51 */
53 {
54 public:
57 {
58 defineOptionalProperty<std::string>("CommonStorageName",
59 "CommonStorage",
60 "Name of the the CommonStorage memory component");
61 defineOptionalProperty<std::string>("PriorKnowledgeName",
62 "PriorKnowledge",
63 "Name of the the PriorKnowledge memory component");
64 }
65 };
66
67 /*!
68 \class EntityDrawerComponent
69 \ingroup MemoryX-Components
70 * \brief The EntityDrawerComponent class implements a component that listens to layered / debug drawer commands and creates internal representations of the visualization
71 * which can be conveniently used by gui components to visualize the content.
72 * Basically it is a armarx::DebugDrawerComponent with additional memroy features. In addition to all debug drawer fucntions it is capable of showing memory entities, e.g. objects.
73 *
74 * \see armarx::DebugDrawerComponent
75 *
76 * The following plugins listen to the EntityDrawer topic:
77 * \see memoryx::WorkingMemoryGuiPlugin
78 */
80 virtual public memoryx::EntityDrawerInterface,
81 virtual public armarx::DebugDrawerComponent
82 {
83 public:
84 /*!
85 * \brief EntityDrawerComponent Constructs a debug drawer
86 */
88
89 // inherited from Component
90 std::string
91 getDefaultName() const override
92 {
93 return "EntityDrawer";
94 }
95
96 static std::string GetDefaultName();
97
98 void onInitComponent() override;
99 void onConnectComponent() override;
100 void onDisconnectComponent() override;
101 void onExitComponent() override;
102
103
104 void setObjectVisu(const std::string& layerName,
105 const std::string& objectName,
106 const memoryx::ObjectClassBasePtr& objectClassBase,
107 const armarx::PoseBasePtr& globalPose,
108 const Ice::Current& c = Ice::emptyCurrent) override;
109 void setObjectVisuByName(const std::string& layerName,
110 const std::string& customObjectName,
111 const std::string& objectClassName,
112 const armarx::PoseBasePtr& globalPose,
113 const Ice::Current& c = Ice::emptyCurrent) override;
114 void updateObjectPose(const std::string& layerName,
115 const std::string& objectName,
116 const armarx::PoseBasePtr& globalPose,
117 const Ice::Current& c = Ice::emptyCurrent) override;
118 /*!
119 * \brief updateObjectColor Colorizes the object visualization
120 * \param layerName The layer
121 * \param objectName The object identifier
122 * \param c The draw color, if all is set to 0, the colorization is disabled (i.e. the original vizualization shows up)
123 */
124 void updateObjectColor(const std::string& layerName,
125 const std::string& objectName,
126 const armarx::DrawColor& color,
127 const Ice::Current& c = Ice::emptyCurrent) override;
128
129 void updateObjectTransparency(const std::string& layerName,
130 const std::string& objectName,
131 float alpha,
132 const Ice::Current& c = Ice::emptyCurrent) override;
133 void removeObjectVisu(const std::string& layerName,
134 const std::string& objectName,
135 const Ice::Current& c = Ice::emptyCurrent) override;
136
137 /*!
138 * \see PropertyUser::createPropertyDefinitions()
139 */
146
147 ~EntityDrawerComponent() override;
148
149 protected:
150 struct EntityData : public DrawData
151 {
153 {
154 updateColor = false;
155 updatePose = false;
156 }
157
159
161 VirtualRobot::VisualizationFactory::Color color;
162
164 Eigen::Matrix4f globalPose;
165 };
166
168 {
169 std::map<std::string, EntityData> entities;
170 };
171
173
174 void onUpdateVisualization() override;
175 void removeCustomVisu(const std::string& layerName, const std::string& name) override;
176
177 void drawEntity(const EntityData& d);
178
179 void removeEntity(const std::string& layerName, const std::string& name);
180
181 VirtualRobot::SceneObjectPtr requestEntity(const EntityData& d);
182
183 std::map<std::string, VirtualRobot::SceneObjectPtr> activeObjects;
184 std::map<std::string, VirtualRobot::ManipulationObjectPtr> objectCache;
185
186 memoryx::PriorKnowledgeInterfacePrx priorKnowledgePrx;
187 memoryx::PersistentObjectClassSegmentBasePrx objectClassSegment;
188
190
191
192 void onRemoveAccumulatedData(const std::string& layerName) override;
193 };
194
196
197} // namespace memoryx
constexpr T c
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition Component.cpp:90
The DebugDrawerComponent class.
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::map< std::string, VirtualRobot::SceneObjectPtr > activeObjects
memoryx::PersistentObjectClassSegmentBasePrx objectClassSegment
void onInitComponent() override
Pure virtual hook for the subclass.
void updateObjectColor(const std::string &layerName, const std::string &objectName, const armarx::DrawColor &color, const Ice::Current &c=Ice::emptyCurrent) override
updateObjectColor Colorizes the object visualization
void updateObjectPose(const std::string &layerName, const std::string &objectName, const armarx::PoseBasePtr &globalPose, const Ice::Current &c=Ice::emptyCurrent) override
VirtualRobot::SceneObjectPtr requestEntity(const EntityData &d)
void setObjectVisuByName(const std::string &layerName, const std::string &customObjectName, const std::string &objectClassName, const armarx::PoseBasePtr &globalPose, const Ice::Current &c=Ice::emptyCurrent) override
void setObjectVisu(const std::string &layerName, const std::string &objectName, const memoryx::ObjectClassBasePtr &objectClassBase, const armarx::PoseBasePtr &globalPose, const Ice::Current &c=Ice::emptyCurrent) override
void onDisconnectComponent() override
Hook for subclass.
void removeObjectVisu(const std::string &layerName, const std::string &objectName, const Ice::Current &c=Ice::emptyCurrent) override
memoryx::PriorKnowledgeInterfacePrx priorKnowledgePrx
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void removeEntity(const std::string &layerName, const std::string &name)
void removeCustomVisu(const std::string &layerName, const std::string &name) override
std::map< std::string, VirtualRobot::ManipulationObjectPtr > objectCache
void onConnectComponent() override
Pure virtual hook for the subclass.
EntityDrawerComponent()
EntityDrawerComponent Constructs a debug drawer.
void onRemoveAccumulatedData(const std::string &layerName) override
void onExitComponent() override
Hook for subclass.
void drawEntity(const EntityData &d)
std::string getDefaultName() const override
Retrieve default name of component.
void updateObjectTransparency(const std::string &layerName, const std::string &objectName, float alpha, const Ice::Current &c=Ice::emptyCurrent) override
void onUpdateVisualization() override
onUpdateVisualization derived methods can overwrite this method to update custom visualizations.
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
VirtualRobot headers.
IceInternal::Handle< ObjectClass > ObjectClassPtr
Definition ObjectClass.h:35
IceInternal::Handle< EntityDrawerComponent > EntityDrawerComponentPtr
std::shared_ptr< GridFileManager > GridFileManagerPtr
VirtualRobot::VisualizationFactory::Color color