SceneModifier.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 General Public License version 2 as
6* published by the Free Software Foundation.
7*
8* ArmarX is distributed in the hope that it will be useful, but
9* WITHOUT ANY WARRANTY; without even the implied warranty of
10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11* GNU General Public License for more details.
12*
13* You should have received a copy of the GNU General Public License
14* along with this program. If not, see <http://www.gnu.org/licenses/>.
15*
16* @package ArmarXSimulation::SceneModifier
17* @author Nikolaus Vahrenkamp
18* @date 2015
19* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20* GNU General Public License
21*/
22
23#pragma once
24
25#include <Eigen/Core>
26
29#include <ArmarXCore/interface/observers/ConditionHandlerInterface.h>
30
31#include <ArmarXSimulation/interface/simulator/SimulatorInterface.h>
32
33#include <MemoryX/interface/components/PriorKnowledgeInterface.h>
34#include <MemoryX/interface/components/WorkingMemoryInterface.h>
35#include <MemoryX/interface/observers/ObjectMemoryObserverInterface.h>
36
37namespace armarx
38{
39
41 {
42 public:
44 {
46 "SceneModificationType",
47 "Possible modes are 'addObject', 'removeObject', and 'moveObject'. No object "
48 "manipulation with 'none'.");
50 "Name of object class in PriorKnowledge");
51 defineRequiredProperty<std::string>("ObjectInstanceName",
52 "Name of object instance in working memory");
53 defineOptionalProperty<float>("PositionX", 0.0f, "Position of object (x)");
54 defineOptionalProperty<float>("PositionY", 0.0f, "Position of object (y)");
55 defineOptionalProperty<float>("PositionZ", 0.0f, "Position of object (z)");
56 defineOptionalProperty<float>("OrientationRoll", 0.0f, "Orientation of object (roll)");
58 "OrientationPitch", 0.0f, "Orientation of object (pitch)");
59 defineOptionalProperty<float>("OrientationYaw", 0.0f, "Orientation of object (yaw)");
60 defineOptionalProperty<bool>("StaticObject",
61 false,
62 "Specify if the object is static (fixed in the world) or "
63 "dynamic (can move in the world)");
65 "WorkingMemoryName",
66 "WorkingMemory",
67 "Name of the WorkingMemory component that should be used");
69 "PriorKnowledgeName",
70 "PriorKnowledge",
71 "Name of the PriorKnowledge component that should be used");
73 "SimulatorName",
74 "Simulator",
75 "Name of the Simulator component that should be used");
76
77 // define optional properties:
78 for (int i = 0; i < 10; i++)
79 {
80 std::stringstream ss1;
81 ss1 << "SceneModificationType_" << i;
83 ss1.str(),
84 "none",
85 "Optional additional object. Possible modes are 'addObject', 'removeObject', "
86 "and 'moveObject'. No object manipulation with 'none'.");
87
88 std::stringstream ss2;
89 ss2 << "ObjectClassName_" << i;
91 ss2.str(),
92 "",
93 "Optional additional object. Name of object class in PriorKnowledge");
94
95 std::stringstream ss3;
96 ss3 << "ObjectInstanceName_" << i;
98 ss3.str(),
99 "",
100 "Optional additional object. Name of object instance in working memory");
101
102 std::stringstream ss4;
103 ss4 << "PositionX_" << i;
105 ss4.str(), 0.0f, "Optional additional object. Position of object (x)");
106
107 std::stringstream ss5;
108 ss5 << "PositionY_" << i;
110 ss5.str(), 0.0f, "Optional additional object. Position of object (y)");
111
112 std::stringstream ss6;
113 ss6 << "PositionZ_" << i;
115 ss6.str(), 0.0f, "Optional additional object. Position of object (z)");
116
117 std::stringstream ss7;
118 ss7 << "OrientationRoll_" << i;
120 ss7.str(), 0.0f, "Optional additional object. Orientation of object (roll)");
121
122 std::stringstream ss8;
123 ss8 << "OrientationPitch_" << i;
125 ss8.str(), 0.0f, "Optional additional object. Orientation of object (pitch)");
126
127 std::stringstream ss9;
128 ss9 << "OrientationYaw_" << i;
130 ss9.str(), 0.0f, "Optional additional object. Orientation of object (yaw)");
131
132 std::stringstream ss10;
133 ss10 << "StaticObject_" << i;
135 ss10.str(),
136 false,
137 "Optional additional object. Specify if the object is static (fixed in the "
138 "world) or dynamic (can move in the world)");
139 }
140
142 "LocalizeObject",
143 false,
144 "Start localization of object. This will make the object visible in the WM gui.");
146 "LocalizeObject_seconds", 10, "How long should the object be localized");
147
148 defineOptionalProperty<std::string>("AttachObjectToRobot.ObjectName",
149 "",
150 "Attach object to robot: object instance name");
152 "AttachObjectToRobot.RobotName", "", "Attach object to robot: name of robot");
154 "AttachObjectToRobot.RobotNodeName",
155 "",
156 "Attach object to robot: name of RobotNode (i.e. tcp)");
157 }
158 };
159
160 /**
161 * @defgroup Component-SceneModifier SceneModifier
162 * @ingroup ArmarXSimulation-Components
163
164 * @brief The SceneModifier class is capable of modifying a simulated scene.
165 * Possible modifications are adding, moving or removing objects or attaching them to a robot node.
166 *
167 * This application allows to adjust a default scene in order to add or move objects for a custom scenario setup.
168 *
169 * @see @ref ArmarXSimulation-HowTos-Customize-Scene
170 *
171 * @class SceneModifier
172 * @ingroup Component-SceneModifier
173 *
174 */
176 {
177 public:
178 /**
179 * @see PropertyUser::createPropertyDefinitions()
180 */
187
188 // inherited from Component
189 std::string
190 getDefaultName() const override
191 {
192 return "SceneModifier";
193 }
194
195 void onInitComponent() override;
196 void onExitComponent() override;
197 void onConnectComponent() override;
198
199 void onDisconnectComponent() override;
200
201 protected:
202 Eigen::Matrix4f getGlobalPose(const std::string& suffix);
203
204 void addObject(const std::string& suffix);
205 void removeObject(const std::string& suffix);
206 void moveObject(const std::string& suffix);
207
208 memoryx::WorkingMemoryInterfacePrx workingMemoryProxy;
209 memoryx::PriorKnowledgeInterfacePrx priorKnowledgeProxy;
210 SimulatorInterfacePrx simulatorPrx;
211 memoryx::ObjectMemoryObserverInterfacePrx memoryObserver;
212 armarx::ConditionHandlerInterfacePrx conditionHandler;
213 armarx::ChannelRefBasePtr classChannel1;
214 void localizeSingleObject(const std::string& objClass, int sleepS);
215 void attachObject(const std::string& objName,
216 const std::string& robotName,
217 const std::string& robotNodeName);
218 bool checkForConfigs(const std::string& suffix);
219 bool getStatic(const std::string& suffix);
220 };
221} // namespace armarx
#define ARMARXCOMPONENT_IMPORT_EXPORT
Default component property definition container.
Definition Component.h:70
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition Component.cpp:46
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition Component.h:94
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition Component.cpp:90
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)
PropertyDefinition< PropertyType > & defineRequiredProperty(const std::string &name, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
SceneModifierPropertyDefinitions(std::string prefix)
bool checkForConfigs(const std::string &suffix)
armarx::ConditionHandlerInterfacePrx conditionHandler
memoryx::WorkingMemoryInterfacePrx workingMemoryProxy
memoryx::ObjectMemoryObserverInterfacePrx memoryObserver
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
SimulatorInterfacePrx simulatorPrx
armarx::ChannelRefBasePtr classChannel1
void localizeSingleObject(const std::string &objClass, int sleepS)
void attachObject(const std::string &objName, const std::string &robotName, const std::string &robotNodeName)
bool getStatic(const std::string &suffix)
std::string getDefaultName() const override
Retrieve default name of component.
memoryx::PriorKnowledgeInterfacePrx priorKnowledgeProxy
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.