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 #include <Inventor/nodes/SoNode.h>
30 #include <Inventor/nodes/SoSeparator.h>
31 #include <Inventor/sensors/SoTimerSensor.h>
32 
33 #include <VirtualRobot/VirtualRobotCommon.h>
34 
35 // ArmarX
38 #include <MemoryX/interface/gui/EntityDrawerInterface.h>
39 #include <MemoryX/interface/components/PriorKnowledgeInterface.h>
40 #include <MemoryX/interface/memorytypes/MemoryEntities.h>
43 
44 
45 namespace memoryx
46 {
47 
48  /*!
49  * \class EntityDrawerPropertyDefinitions
50  * \brief
51  */
54  {
55  public:
58  {
59  defineOptionalProperty<std::string>("CommonStorageName", "CommonStorage", "Name of the the CommonStorage memory component");
60  defineOptionalProperty<std::string>("PriorKnowledgeName", "PriorKnowledge", "Name of the the PriorKnowledge memory component");
61  }
62  };
63 
64  /*!
65  \class EntityDrawerComponent
66  \ingroup MemoryX-Components
67  * \brief The EntityDrawerComponent class implements a component that listens to layered / debug drawer commands and creates internal representations of the visualization
68  * which can be conveniently used by gui components to visualize the content.
69  * 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.
70  *
71  * \see armarx::DebugDrawerComponent
72  *
73  * The following plugins listen to the EntityDrawer topic:
74  * \see memoryx::WorkingMemoryGuiPlugin
75  */
77  virtual public memoryx::EntityDrawerInterface,
78  virtual public armarx::DebugDrawerComponent
79  {
80  public:
81 
82  /*!
83  * \brief EntityDrawerComponent Constructs a debug drawer
84  */
86 
87 
88  // inherited from Component
89  std::string getDefaultName() const override
90  {
91  return "EntityDrawer";
92  }
93  void onInitComponent() override;
94  void onConnectComponent() override;
95  void onDisconnectComponent() override;
96  void onExitComponent() override;
97 
98 
99  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;
100  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;
101  void updateObjectPose(const std::string& layerName, const std::string& objectName, const armarx::PoseBasePtr& globalPose, const Ice::Current& c = Ice::emptyCurrent) override;
102  /*!
103  * \brief updateObjectColor Colorizes the object visualization
104  * \param layerName The layer
105  * \param objectName The object identifier
106  * \param c The draw color, if all is set to 0, the colorization is disabled (i.e. the original vizualization shows up)
107  */
108  void updateObjectColor(const std::string& layerName, const std::string& objectName, const armarx::DrawColor& color, const Ice::Current& c = Ice::emptyCurrent) override;
109 
110  void updateObjectTransparency(const std::string& layerName, const std::string& objectName, float alpha, const Ice::Current& c = Ice::emptyCurrent) override;
111  void removeObjectVisu(const std::string& layerName, const std::string& objectName, const Ice::Current& c = Ice::emptyCurrent) override;
112 
113  /*!
114  * \see PropertyUser::createPropertyDefinitions()
115  */
117  {
120  }
121 
122 
123  ~EntityDrawerComponent() override;
124  protected:
125 
126  struct EntityData : public DrawData
127  {
129  {
130  updateColor = false;
131  updatePose = false;
132  }
134 
137 
140  };
141 
143  {
144  std::map<std::string, EntityData> entities;
145  };
146 
148 
149  void onUpdateVisualization() override;
150  void removeCustomVisu(const std::string& layerName, const std::string& name) override;
151 
152  void drawEntity(const EntityData& d);
153 
154  void removeEntity(const std::string& layerName, const std::string& name);
155 
157 
158  std::map < std::string, VirtualRobot::SceneObjectPtr > activeObjects;
159  std::map< std::string, VirtualRobot::ManipulationObjectPtr > objectCache;
160 
161  memoryx::PriorKnowledgeInterfacePrx priorKnowledgePrx;
162  memoryx::PersistentObjectClassSegmentBasePrx objectClassSegment;
163 
165 
166 
167  void onRemoveAccumulatedData(const std::string& layerName) override;
168  };
169 
171 
172 }
173 
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:302
memoryx::EntityDrawerComponent::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: EntityDrawerComponent.cpp:196
armarx::DebugDrawerComponent
The DebugDrawerComponent class.
Definition: DebugDrawerComponent.h:108
memoryx::EntityDrawerComponent::accumulatedCustomUpdateData
EntityUpdateData accumulatedCustomUpdateData
Definition: EntityDrawerComponent.h:147
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:317
memoryx::EntityDrawerComponent::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: EntityDrawerComponent.cpp:185
memoryx::EntityDrawerComponent::EntityUpdateData
Definition: EntityDrawerComponent.h:142
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:262
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
armarx::DebugDrawerPropertyDefinitions::DebugDrawerPropertyDefinitions
DebugDrawerPropertyDefinitions(std::string prefix)
Definition: DebugDrawerComponent.h:62
memoryx::EntityDrawerComponent::~EntityDrawerComponent
~EntityDrawerComponent() override
Definition: EntityDrawerComponent.cpp:52
GridFileManager.h
memoryx::EntityDrawerComponent::objectClassSegment
memoryx::PersistentObjectClassSegmentBasePrx objectClassSegment
Definition: EntityDrawerComponent.h:162
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
memoryx::EntityDrawerComponent::removeEntity
void removeEntity(const std::string &layerName, const std::string &name)
Definition: EntityDrawerComponent.cpp:156
memoryx::EntityDrawerComponent::onUpdateVisualization
void onUpdateVisualization() override
onUpdateVisualization derived methods can overwrite this method to update custom visualizations.
Definition: EntityDrawerComponent.cpp:57
memoryx::EntityDrawerComponent::EntityUpdateData::entities
std::map< std::string, EntityData > entities
Definition: EntityDrawerComponent.h:144
ObjectClass.h
memoryx::EntityDrawerComponent::onDisconnectComponent
void onDisconnectComponent() override
Hook for subclass.
Definition: EntityDrawerComponent.cpp:218
memoryx::EntityDrawerComponent::activeObjects
std::map< std::string, VirtualRobot::SceneObjectPtr > activeObjects
Definition: EntityDrawerComponent.h:158
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:286
IceInternal::Handle< ObjectClass >
memoryx::EntityDrawerComponent::fileManager
GridFileManagerPtr fileManager
Definition: EntityDrawerComponent.h:164
Color
uint32_t Color
RGBA color.
Definition: color.h:8
memoryx::EntityDrawerComponent::EntityData::globalPose
Eigen::Matrix4f globalPose
Definition: EntityDrawerComponent.h:139
memoryx::EntityDrawerPropertyDefinitions
Definition: EntityDrawerComponent.h:52
memoryx::EntityDrawerComponent::priorKnowledgePrx
memoryx::PriorKnowledgeInterfacePrx priorKnowledgePrx
Definition: EntityDrawerComponent.h:161
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:238
memoryx::EntityDrawerComponent::requestEntity
VirtualRobot::SceneObjectPtr requestEntity(const EntityData &d)
Definition: EntityDrawerComponent.cpp:338
memoryx::EntityDrawerPropertyDefinitions::EntityDrawerPropertyDefinitions
EntityDrawerPropertyDefinitions(std::string prefix)
Definition: EntityDrawerComponent.h:56
memoryx::EntityDrawerComponent::EntityData::updatePose
bool updatePose
Definition: EntityDrawerComponent.h:138
memoryx::EntityDrawerComponent::drawEntity
void drawEntity(const EntityData &d)
Definition: EntityDrawerComponent.cpp:78
memoryx::EntityDrawerComponent::objectCache
std::map< std::string, VirtualRobot::ManipulationObjectPtr > objectCache
Definition: EntityDrawerComponent.h:159
memoryx::EntityDrawerComponent::EntityData::color
VirtualRobot::VisualizationFactory::Color color
Definition: EntityDrawerComponent.h:136
memoryx::EntityDrawerComponent
The EntityDrawerComponent class implements a component that listens to layered / debug drawer command...
Definition: EntityDrawerComponent.h:76
Component.h
memoryx::EntityDrawerComponent::EntityData
Definition: EntityDrawerComponent.h:126
armarx::Component::getConfigIdentifier
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition: Component.cpp:74
memoryx::EntityDrawerComponent::removeObjectVisu
void removeObjectVisu(const std::string &layerName, const std::string &objectName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: EntityDrawerComponent.cpp:228
memoryx::EntityDrawerComponent::EntityData::EntityData
EntityData()
Definition: EntityDrawerComponent.h:128
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
memoryx::EntityDrawerComponent::onRemoveAccumulatedData
void onRemoveAccumulatedData(const std::string &layerName) override
Definition: EntityDrawerComponent.cpp:417
memoryx::GridFileManagerPtr
std::shared_ptr< GridFileManager > GridFileManagerPtr
Definition: AbstractEntityWrapper.h:32
IceUtil::Handle< class PropertyDefinitionContainer >
memoryx::EntityDrawerComponent::EntityData::updateColor
bool updateColor
Definition: EntityDrawerComponent.h:135
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:89
memoryx::EntityDrawerComponent::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: EntityDrawerComponent.h:116
memoryx::EntityDrawerComponent::removeCustomVisu
void removeCustomVisu(const std::string &layerName, const std::string &name) override
Definition: EntityDrawerComponent.cpp:72
armarx::PropertyDefinitionsPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
Definition: forward_declarations.h:34
memoryx::EntityDrawerComponent::EntityDrawerComponent
EntityDrawerComponent()
EntityDrawerComponent Constructs a debug drawer.
Definition: EntityDrawerComponent.cpp:46
memoryx::EntityDrawerComponent::EntityData::objectClass
memoryx::ObjectClassPtr objectClass
Definition: EntityDrawerComponent.h:133
memoryx::EntityDrawerComponent::onExitComponent
void onExitComponent() override
Hook for subclass.
Definition: EntityDrawerComponent.cpp:223
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::DebugDrawerComponent::DrawData
Definition: DebugDrawerComponent.h:337
armarx::DebugDrawerPropertyDefinitions
Definition: DebugDrawerComponent.h:58