CoupledInteractionGroupStatechartContext.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2014-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 RobotSkillTemplates::CoupledInteractionGroup
19  * @author [Author Name] ( [Author Email] )
20  * @date 2014
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
26 
27 //#include <RobotAPI/libraries/core/remoterobot/RemoteRobot.h>
28 //#include <RobotAPI/libraries/core/Pose.h>
29 
33 
34 #define DEFAULT_SETTINGS_AGENT_INSTANCES_SEGMENT_NAME "agentInstances"
35 
36 using namespace memoryx;
37 
38 
40 {
41  void CoupledInteractionGroupStatechartContext::onInitStatechartContext()
42  {
43  // Register dependencies
44  // usingProxy(getProperty<std::string>("KinematicUnitName").getValue());
45  // usingProxy(getProperty<std::string>("KinematicUnitObserverName").getValue());
46  // usingProxy(getProperty<std::string>("RobotStateComponentName").getValue());
47  // usingProxy(getProperty<std::string>("TCPControlUnitName").getValue());
48  usingProxy(getProperty<std::string>("KinematicUnitName").getValue());
49  usingProxy(getProperty<std::string>("KinematicUnitObserverName").getValue());
50  usingProxy(getProperty<std::string>("RobotStateComponentName").getValue());
51  usingProxy(getProperty<std::string>("TCPControlUnitName").getValue());
52  usingProxy(getProperty<std::string>("TCPControlUnitObserverName").getValue());
53  usingProxy(getProperty<std::string>("WorkingMemoryName").getValue());
54  usingProxy(getProperty<std::string>("ObjectMemoryObserverName").getValue());
55  usingProxy(getProperty<std::string>("PriorKnowledgeName").getValue());
56  usingProxy(getProperty<std::string>("ViewSelectionName").getValue());
57  usingProxy(getProperty<std::string>("ForceTorqueObserverName").getValue());
58  platformUnitObserverName = getProperty<std::string>("PlatformUnitObserverName").getValue();
59  platformUnitName = getProperty<std::string>("PlatformUnitName").getValue();
60  ARMARX_INFO << "Using platform unit:" << platformUnitName << ", platform observer:" << platformUnitObserverName;
61 
62  usingProxy(platformUnitName);
63  usingProxy(platformUnitObserverName);
64 
65  offeringTopic("DebugDrawerUpdates");
66  }
67 
68 
69  void CoupledInteractionGroupStatechartContext::onConnectStatechartContext()
70  {
71 
72  // retrieve proxies
73  // robotStateComponent = getProxy<RobotStateComponentInterfacePrx>(getProperty<std::string>("RobotStateComponentName").getValue());
74  // kinematicUnitPrx = getProxy<KinematicUnitInterfacePrx>(getProperty<std::string>("KinematicUnitName").getValue());
75  // kinematicUnitObserverPrx = getProxy<KinematicUnitObserverInterfacePrx>(getProperty<std::string>("KinematicUnitObserverName").getValue());
76  // tcpControlPrx = getProxy<TCPControlUnitInterfacePrx>(getProperty<std::string>("TCPControlUnitName").getValue());
77 
78  // // initialize remote robot
79  // remoteRobot.reset(new RemoteRobot(robotStateComponent->getSynchronizedRobot()));
80  // retrieve proxies
81  robotStateComponent = getProxy<RobotStateComponentInterfacePrx>(getProperty<std::string>("RobotStateComponentName").getValue());
82  kinematicUnitPrx = getProxy<KinematicUnitInterfacePrx>(getProperty<std::string>("KinematicUnitName").getValue());
83  kinematicUnitObserverPrx = getProxy<KinematicUnitObserverInterfacePrx>(getProperty<std::string>("KinematicUnitObserverName").getValue());
84  tcpControlPrx = getProxy<TCPControlUnitInterfacePrx>(getProperty<std::string>("TCPControlUnitName").getValue());
85  tcpControlUnitObserverPrx = getProxy<TCPControlUnitObserverInterfacePrx>(getProperty<std::string>("TCPControlUnitObserverName").getValue());
86  workingMemoryProxy = getProxy<memoryx::WorkingMemoryInterfacePrx>(getProperty<std::string>("WorkingMemoryName").getValue());
87  objectMemoryObserverProxy = getProxy<memoryx::ObjectMemoryObserverInterfacePrx>(getProperty<std::string>("ObjectMemoryObserverName").getValue());
88  priorKnowledgeProxy = getProxy<memoryx::PriorKnowledgeInterfacePrx>(getProperty<std::string>("PriorKnowledgeName").getValue());
89 
90  // retrieve proxies
91  platformUnitPrx = getProxy<PlatformUnitInterfacePrx>(platformUnitName);
92  platformUnitObserverPrx = getProxy<PlatformUnitObserverInterfacePrx>(platformUnitObserverName);
93  viewSelectionProxy = getProxy<ViewSelectionInterfacePrx>(getProperty<std::string>("ViewSelectionName").getValue());
94  ftUnitObserverPrx = getProxy<ForceTorqueUnitObserverInterfacePrx>(getProperty<std::string>("ForceTorqueObserverName").getValue());
95 
96  // initialize remote robot
97  remoteRobot.reset(new RemoteRobot(robotStateComponent->getSynchronizedRobot()));
98 
99  debugDrawerTopicProxy = getTopic<armarx::DebugDrawerInterfacePrx>("DebugDrawerUpdates");
100  /*if (this->getIceManager()->isObjectReachable("Simulator"))
101  {
102  simulatorPrx = getProxy<SimulatorInterfacePrx>("Simulator");
103  }
104  else
105  {
106  simulatorPrx = NULL;
107  }*/
108 
109 
110  AgentInstancesSegmentBasePrx agentInstancesProxy = AgentInstancesSegmentBasePrx::uncheckedCast(workingMemoryProxy->getSegment(DEFAULT_SETTINGS_AGENT_INSTANCES_SEGMENT_NAME));
111 
112  if (agentInstancesProxy)
113  {
114  agent = AgentInstancePtr::dynamicCast(agentInstancesProxy->getAgentInstanceByName("Armar3"));
115  }
116  else
117  {
118  agent = nullptr;
119  }
120  }
121 
122  Eigen::Matrix4f CoupledInteractionGroupStatechartContext::getRobotPose()
123  {
125 
126  if (!agent)
127  {
128  ARMARX_ERROR << deactivateSpam() << "no agent with name Armar3";
129  }
130  else
131  {
132 
133  FramedPositionPtr agentPosition = agent->getPosition();
134 
135  if (agentPosition)
136  {
137  robotPose.block(0, 3, 3, 1) = agentPosition->toEigen();
138  }
139 
140  FramedOrientationPtr agentOrientation = agent->getOrientation();
141 
142  if (agentOrientation)
143  {
144  robotPose.block(0, 0, 3, 3) = agentOrientation->toEigen();
145  }
146  }
147 
148  return robotPose;
149  }
150 
151  PropertyDefinitionsPtr CoupledInteractionGroupStatechartContext::createPropertyDefinitions()
152  {
154  getConfigIdentifier()));
155  }
156 }
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
CoupledInteractionGroupStatechartContext.h
Statechart.h
IceInternal::Handle< FramedPosition >
deactivateSpam
SpamFilterDataPtr deactivateSpam(SpamFilterDataPtr const &spamFilter, float deactivationDurationSec, const std::string &identifier, bool deactivate)
Definition: Logging.cpp:72
GfxTL::Identity
void Identity(MatrixXX< N, N, T > *a)
Definition: MatrixXX.h:523
DEFAULT_SETTINGS_AGENT_INSTANCES_SEGMENT_NAME
#define DEFAULT_SETTINGS_AGENT_INSTANCES_SEGMENT_NAME
Definition: CoupledInteractionGroupStatechartContext.cpp:34
armarx::CoupledInteractionGroup::CoupledInteractionGroupStatechartContextProperties
Definition: CoupledInteractionGroupStatechartContext.h:60
ARMARX_ERROR
#define ARMARX_ERROR
Definition: Logging.h:189
Component.h
armarx::RemoteRobot
Mimics the behaviour of the VirtualRobot::Robot class while redirecting everything to an Ice proxy.
Definition: RemoteRobot.h:139
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::CoupledInteractionGroup
Definition: CalculateApproachTablePose.h:31
armarx::PropertyDefinitionsPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
Definition: forward_declarations.h:34
ImportExportComponent.h