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 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 */
144
145 ~EntityDrawerComponent() override;
146
147 protected:
148 struct EntityData : public DrawData
149 {
151 {
152 updateColor = false;
153 updatePose = false;
154 }
155
157
159 VirtualRobot::VisualizationFactory::Color color;
160
162 Eigen::Matrix4f globalPose;
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
179 VirtualRobot::SceneObjectPtr requestEntity(const EntityData& d);
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
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