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 
45 namespace 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  void onInitComponent() override;
97  void onConnectComponent() override;
98  void onDisconnectComponent() override;
99  void onExitComponent() override;
100 
101 
102  void setObjectVisu(const std::string& layerName,
103  const std::string& objectName,
104  const memoryx::ObjectClassBasePtr& objectClassBase,
105  const armarx::PoseBasePtr& globalPose,
106  const Ice::Current& c = Ice::emptyCurrent) override;
107  void setObjectVisuByName(const std::string& layerName,
108  const std::string& customObjectName,
109  const std::string& objectClassName,
110  const armarx::PoseBasePtr& globalPose,
111  const Ice::Current& c = Ice::emptyCurrent) override;
112  void updateObjectPose(const std::string& layerName,
113  const std::string& objectName,
114  const armarx::PoseBasePtr& globalPose,
115  const Ice::Current& c = Ice::emptyCurrent) override;
116  /*!
117  * \brief updateObjectColor Colorizes the object visualization
118  * \param layerName The layer
119  * \param objectName The object identifier
120  * \param c The draw color, if all is set to 0, the colorization is disabled (i.e. the original vizualization shows up)
121  */
122  void updateObjectColor(const std::string& layerName,
123  const std::string& objectName,
124  const armarx::DrawColor& color,
125  const Ice::Current& c = Ice::emptyCurrent) override;
126 
127  void updateObjectTransparency(const std::string& layerName,
128  const std::string& objectName,
129  float alpha,
130  const Ice::Current& c = Ice::emptyCurrent) override;
131  void removeObjectVisu(const std::string& layerName,
132  const std::string& objectName,
133  const Ice::Current& c = Ice::emptyCurrent) override;
134 
135  /*!
136  * \see PropertyUser::createPropertyDefinitions()
137  */
140  {
143  }
144 
145  ~EntityDrawerComponent() override;
146 
147  protected:
148  struct EntityData : public DrawData
149  {
151  {
152  updateColor = false;
153  updatePose = false;
154  }
155 
157 
160 
163  };
164 
166  {
167  std::map<std::string, EntityData> entities;
168  };
169 
171 
172  void onUpdateVisualization() override;
173  void removeCustomVisu(const std::string& layerName, const std::string& name) override;
174 
175  void drawEntity(const EntityData& d);
176 
177  void removeEntity(const std::string& layerName, const std::string& name);
178 
180 
181  std::map<std::string, VirtualRobot::SceneObjectPtr> activeObjects;
182  std::map<std::string, VirtualRobot::ManipulationObjectPtr> objectCache;
183 
184  memoryx::PriorKnowledgeInterfacePrx priorKnowledgePrx;
185  memoryx::PersistentObjectClassSegmentBasePrx objectClassSegment;
186 
188 
189 
190  void onRemoveAccumulatedData(const std::string& layerName) override;
191  };
192 
194 
195 } // namespace memoryx
DebugDrawerComponent.h
memoryx::EntityDrawerComponent::setObjectVisu
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
Definition: EntityDrawerComponent.cpp:323
memoryx::EntityDrawerComponent::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: EntityDrawerComponent.cpp:197
armarx::DebugDrawerComponent
The DebugDrawerComponent class.
Definition: DebugDrawerComponent.h:113
memoryx::EntityDrawerComponent::accumulatedCustomUpdateData
EntityUpdateData accumulatedCustomUpdateData
Definition: EntityDrawerComponent.h:170
memoryx::EntityDrawerComponent::setObjectVisuByName
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
Definition: EntityDrawerComponent.cpp:343
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:650
memoryx::EntityDrawerComponent::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: EntityDrawerComponent.cpp:185
memoryx::EntityDrawerComponent::EntityUpdateData
Definition: EntityDrawerComponent.h:165
memoryx::EntityDrawerComponent::updateObjectTransparency
void updateObjectTransparency(const std::string &layerName, const std::string &objectName, float alpha, const Ice::Current &c=Ice::emptyCurrent) override
Definition: EntityDrawerComponent.cpp:275
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:345
armarx::DebugDrawerPropertyDefinitions::DebugDrawerPropertyDefinitions
DebugDrawerPropertyDefinitions(std::string prefix)
Definition: DebugDrawerComponent.h:61
memoryx::EntityDrawerComponent::~EntityDrawerComponent
~EntityDrawerComponent() override
Definition: EntityDrawerComponent.cpp:47
GridFileManager.h
memoryx::EntityDrawerComponent::objectClassSegment
memoryx::PersistentObjectClassSegmentBasePrx objectClassSegment
Definition: EntityDrawerComponent.h:185
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
memoryx::EntityDrawerComponent::removeEntity
void removeEntity(const std::string &layerName, const std::string &name)
Definition: EntityDrawerComponent.cpp:155
memoryx::EntityDrawerComponent::onUpdateVisualization
void onUpdateVisualization() override
onUpdateVisualization derived methods can overwrite this method to update custom visualizations.
Definition: EntityDrawerComponent.cpp:52
memoryx::EntityDrawerComponent::EntityUpdateData::entities
std::map< std::string, EntityData > entities
Definition: EntityDrawerComponent.h:167
ObjectClass.h
memoryx::EntityDrawerComponent::onDisconnectComponent
void onDisconnectComponent() override
Hook for subclass.
Definition: EntityDrawerComponent.cpp:221
memoryx::EntityDrawerComponent::updateObjectPose
void updateObjectPose(const std::string &layerName, const std::string &objectName, const armarx::PoseBasePtr &globalPose, const Ice::Current &c=Ice::emptyCurrent) override
Definition: EntityDrawerComponent.cpp:303
IceInternal::Handle< ObjectClass >
memoryx::EntityDrawerComponent::fileManager
GridFileManagerPtr fileManager
Definition: EntityDrawerComponent.h:187
Color
uint32_t Color
RGBA color.
Definition: color.h:8
memoryx::EntityDrawerComponent::objectCache
std::map< std::string, VirtualRobot::ManipulationObjectPtr > objectCache
Definition: EntityDrawerComponent.h:182
memoryx::EntityDrawerComponent::EntityData::globalPose
Eigen::Matrix4f globalPose
Definition: EntityDrawerComponent.h:162
memoryx::EntityDrawerPropertyDefinitions
Definition: EntityDrawerComponent.h:52
memoryx::EntityDrawerComponent::priorKnowledgePrx
memoryx::PriorKnowledgeInterfacePrx priorKnowledgePrx
Definition: EntityDrawerComponent.h:184
memoryx::EntityDrawerComponent::updateObjectColor
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
Definition: EntityDrawerComponent.cpp:246
memoryx::EntityDrawerComponent::requestEntity
VirtualRobot::SceneObjectPtr requestEntity(const EntityData &d)
Definition: EntityDrawerComponent.cpp:370
memoryx::EntityDrawerPropertyDefinitions::EntityDrawerPropertyDefinitions
EntityDrawerPropertyDefinitions(std::string prefix)
Definition: EntityDrawerComponent.h:55
memoryx::EntityDrawerComponent::EntityData::updatePose
bool updatePose
Definition: EntityDrawerComponent.h:161
memoryx::EntityDrawerComponent::drawEntity
void drawEntity(const EntityData &d)
Definition: EntityDrawerComponent.cpp:75
memoryx::EntityDrawerComponent::EntityData::color
VirtualRobot::VisualizationFactory::Color color
Definition: EntityDrawerComponent.h:159
memoryx::EntityDrawerComponent::activeObjects
std::map< std::string, VirtualRobot::SceneObjectPtr > activeObjects
Definition: EntityDrawerComponent.h:181
memoryx::EntityDrawerComponent
The EntityDrawerComponent class implements a component that listens to layered / debug drawer command...
Definition: EntityDrawerComponent.h:79
Component.h
memoryx::EntityDrawerComponent::EntityData
Definition: EntityDrawerComponent.h:148
armarx::Component::getConfigIdentifier
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition: Component.cpp:79
memoryx::EntityDrawerComponent::removeObjectVisu
void removeObjectVisu(const std::string &layerName, const std::string &objectName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: EntityDrawerComponent.cpp:233
memoryx::EntityDrawerComponent::EntityData::EntityData
EntityData()
Definition: EntityDrawerComponent.h:150
memoryx::EntityDrawerComponent::onRemoveAccumulatedData
void onRemoveAccumulatedData(const std::string &layerName) override
Definition: EntityDrawerComponent.cpp:452
memoryx::GridFileManagerPtr
std::shared_ptr< GridFileManager > GridFileManagerPtr
Definition: AbstractEntityWrapper.h:33
IceUtil::Handle< class PropertyDefinitionContainer >
memoryx::EntityDrawerComponent::EntityData::updateColor
bool updateColor
Definition: EntityDrawerComponent.h:158
scene3D::SceneObjectPtr
boost::intrusive_ptr< SceneObject > SceneObjectPtr
Definition: PointerDefinitions.h:40
memoryx::EntityDrawerComponent::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: EntityDrawerComponent.h:91
memoryx::EntityDrawerComponent::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: EntityDrawerComponent.h:139
memoryx::EntityDrawerComponent::removeCustomVisu
void removeCustomVisu(const std::string &layerName, const std::string &name) override
Definition: EntityDrawerComponent.cpp:69
armarx::PropertyDefinitionsPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
Definition: forward_declarations.h:35
memoryx::EntityDrawerComponent::EntityDrawerComponent
EntityDrawerComponent()
EntityDrawerComponent Constructs a debug drawer.
Definition: EntityDrawerComponent.cpp:43
memoryx::EntityDrawerComponent::EntityData::objectClass
memoryx::ObjectClassPtr objectClass
Definition: EntityDrawerComponent.h:156
memoryx::EntityDrawerComponent::onExitComponent
void onExitComponent() override
Hook for subclass.
Definition: EntityDrawerComponent.cpp:227
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::DebugDrawerComponent::DrawData
Definition: DebugDrawerComponent.h:565
armarx::DebugDrawerPropertyDefinitions
Definition: DebugDrawerComponent.h:58