FindAndGraspObjectContext.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 RobotSkillTemplates::FindAndGraspObject
17* @author Nikolaus Vahrenkamp
18* @date 2012 Nikolaus Vahrenkamp
19* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20* GNU General Public License
21*/
22
23
24#pragma once
25
27//#include <ArmarXSimulation/interface/simulator/SimulatorInterface.h>
28
31
32#include <RobotAPI/interface/units/KinematicUnitInterface.h>
35
36#include <VisionX/interface/components/Calibration.h>
37#include <VisionX/interface/components/HandLocalization.h>
38#include <VisionX/interface/core/ImageProcessorInterface.h>
39
40#include <MemoryX/interface/components/PriorKnowledgeInterface.h>
41#include <MemoryX/interface/observers/ObjectMemoryObserverInterface.h>
42
43namespace armarx
44{
45
46 // ****************************************************************
47 // Component and context
48 // ****************************************************************
49
51 {
54 {
55 defineOptionalProperty<std::string>("KinematicUnitName",
56 "Armar3KinematicUnit",
57 "Name of the kinematic unit that should be used");
59 "RobotStateComponentName",
60 "RobotStateComponent",
61 "Name of the robot state component that should be used");
63 "ObjectMemoryObserverName",
64 "ObjectMemoryObserver",
65 "Name of the ObjectMemoryObserver component that should be used");
67 "PriorKnowledgeName",
68 "PriorKnowledge",
69 "Name of the PriorKnowledge component that should be used");
70 //defineOptionalProperty<std::string>("SimulatorName", "Simulator", "Name of the simulator component that should be used");
71
73 "HeadIKUnitName", "", "Name of the head unit that should be used.");
75 "HeadIKKinematicChainName",
76 "",
77 "Name of the inematic chain that should be used for head IK.");
78 }
79 };
80
82 virtual public RobotStatechartContext
83 {
84 public:
85 // inherited from Component
86 virtual std::string
88 {
89 return "FindAndGraspObjectContext";
90 }
91
92 virtual void
94 {
95 ARMARX_LOG << eINFO << "Init FindAndGraspObjectContext" << flush;
96
98
99 usingProxy(getProperty<std::string>("KinematicUnitObserverName").getValue());
100 usingProxy(getProperty<std::string>("KinematicUnitName").getValue());
101 usingProxy(getProperty<std::string>("RobotStateComponentName").getValue());
102 usingProxy(getProperty<std::string>("ObjectMemoryObserverName").getValue());
103 usingProxy(getProperty<std::string>("PriorKnowledgeName").getValue());
104
105 //For Visualization of (debug) coordinate systems
106 std::string simPrxName = getProperty<std::string>("SimulatorName").getValue();
107
108 if (!simPrxName.empty())
109 {
110 usingProxy(simPrxName);
111 }
112
113 // headIKUnit
114 headIKUnitName = getProperty<std::string>("HeadIKUnitName").getValue();
115 ARMARX_LOG << eINFO << "headIKUnitName:" << headIKUnitName << flush;
117 getProperty<std::string>("HeadIKKinematicChainName").getValue();
118
119 if (!headIKUnitName.empty())
120 {
122 }
123 }
124
125 virtual void
127 {
129 ARMARX_LOG << eINFO << "Starting FindAndGraspObjectContext" << flush;
130 // retrieve proxies
131
133 getProperty<std::string>("ObjectMemoryObserverName").getValue());
135 getProperty<std::string>("PriorKnowledgeName").getValue());
136 std::string rbStateName =
137 getProperty<std::string>("RobotStateComponentName").getValue();
139 std::string kinUnitName = getProperty<std::string>("KinematicUnitName").getValue();
141
142 // initialize remote robot
143 remoteRobot.reset(new RemoteRobot(robotStateComponent->getSynchronizedRobot()));
144
145 //For Visualization of (debug) coordinate systems
146 /*std::string simPrxName = getProperty<std::string>("SimulatorName").getValue();
147 if (!simPrxName.empty())
148 {
149 simulatorProxy = getProxy<SimulatorInterfacePrx>(simPrxName);
150 }
151 //ARMARX_LOG << eINFO << "Fetched proxies " << kinUnitName << ":" << kinematicUnitPrx << ", " << rbStateName << ": " << robotStateComponent << flush;
152 */
153 if (!headIKUnitName.empty())
154 {
156 ARMARX_LOG << eINFO << "Fetched headIK proxy " << headIKUnitName << ":"
157 << headIKUnitPrx << ", head IK kin chain:" << headIKKinematicChainName
158 << flush;
159 }
160
162 ARMARX_LOG << eINFO << "Created local robot" << flush;
163 }
164
171
172 //From GraspingWithVisualFeedbackContext:
173 //TCPControlUnitInterfacePrx tcpControlUnitProxy; //Maybe not necessary?
174
175 //visionx::ImageFileSequenceProviderInterfacePrx imageSequenceProviderProxy;
176 memoryx::ObjectMemoryObserverInterfacePrx objectMemoryObserver;
177 memoryx::PriorKnowledgeInterfacePrx priorMemoryProxy;
178 VirtualRobot::GraspPtr graspDefinition;
179 //visionx::HandLocalizationInterfacePrx handLocalizationProxy;
180 //std::string kinematicChainName, graspedObjectName;
181
182 //From VisualServoContext:
184 KinematicUnitInterfacePrx kinematicUnitPrx;
186
187 //For Visualization of (debug) coordinate systems
188 //SimulatorInterfacePrx simulatorProxy;
189
190 HeadIKUnitInterfacePrx headIKUnitPrx;
192 std::string headIKUnitName;
193
194 // a temporary robot which has to be manually synchronized. Can be used for IK computations.
196 };
197
198} // namespace armarx
#define ARMARXCOMPONENT_IMPORT_EXPORT
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition Component.cpp:90
Property< PropertyType > getProperty(const std::string &name)
virtual PropertyDefinitionsPtr createPropertyDefinitions()
memoryx::PriorKnowledgeInterfacePrx priorMemoryProxy
memoryx::ObjectMemoryObserverInterfacePrx objectMemoryObserver
RobotStateComponentInterfacePrx robotStateComponent
virtual void onInitStatechartContext()
onInitStatechartonInitStatechartContext can be implemented by subclasses
virtual void onConnectStatechartContext()
onConnectStatechartContext can be implemented by subclasses
bool usingProxy(const std::string &name, const std::string &endpoints="")
Registers a proxy for retrieval after initialization and adds it to the dependency list.
Ice::ObjectPrx getProxy(long timeoutMs=0, bool waitForScheduler=true) const
Returns the proxy of this object (optionally it waits for the proxy)
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)
Mimics the behaviour of the VirtualRobot::Robot class while redirecting everything to an Ice proxy.
static VirtualRobot::RobotPtr createLocalClone(RobotStateComponentInterfacePrx robotStatePrx, const std::string &filename=std::string(), const Ice::StringSeq packages=Ice::StringSeq(), VirtualRobot::RobotIO::RobotDescription loadMode=VirtualRobot::RobotIO::eFull)
void onInitStatechartContext() override
onInitStatechartonInitStatechartContext can be implemented by subclasses
void onConnectStatechartContext() override
onConnectStatechartContext can be implemented by subclasses
#define ARMARX_LOG
Definition Logging.h:165
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
const LogSender::manipulator flush
Definition LogSender.h:251
::IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface > RobotStateComponentInterfacePrx