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
36using namespace memoryx;
37
39{
40 void
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
61 << ", platform observer:" << platformUnitObserverName;
62
63 usingProxy(platformUnitName);
64 usingProxy(platformUnitObserverName);
65
66 offeringTopic("DebugDrawerUpdates");
67 }
68
69 void
71 {
72
73 // retrieve proxies
74 // robotStateComponent = getProxy<RobotStateComponentInterfacePrx>(getProperty<std::string>("RobotStateComponentName").getValue());
75 // kinematicUnitPrx = getProxy<KinematicUnitInterfacePrx>(getProperty<std::string>("KinematicUnitName").getValue());
76 // kinematicUnitObserverPrx = getProxy<KinematicUnitObserverInterfacePrx>(getProperty<std::string>("KinematicUnitObserverName").getValue());
77 // tcpControlPrx = getProxy<TCPControlUnitInterfacePrx>(getProperty<std::string>("TCPControlUnitName").getValue());
78
79 // // initialize remote robot
80 // remoteRobot.reset(new RemoteRobot(robotStateComponent->getSynchronizedRobot()));
81 // retrieve proxies
83 getProperty<std::string>("RobotStateComponentName").getValue());
84 kinematicUnitPrx = getProxy<KinematicUnitInterfacePrx>(
85 getProperty<std::string>("KinematicUnitName").getValue());
86 kinematicUnitObserverPrx = getProxy<KinematicUnitObserverInterfacePrx>(
87 getProperty<std::string>("KinematicUnitObserverName").getValue());
89 getProperty<std::string>("TCPControlUnitName").getValue());
90 tcpControlUnitObserverPrx = getProxy<TCPControlUnitObserverInterfacePrx>(
91 getProperty<std::string>("TCPControlUnitObserverName").getValue());
93 getProperty<std::string>("WorkingMemoryName").getValue());
95 getProperty<std::string>("ObjectMemoryObserverName").getValue());
97 getProperty<std::string>("PriorKnowledgeName").getValue());
98
99 // retrieve proxies
100 platformUnitPrx = getProxy<PlatformUnitInterfacePrx>(platformUnitName);
101 platformUnitObserverPrx =
102 getProxy<PlatformUnitObserverInterfacePrx>(platformUnitObserverName);
103 viewSelectionProxy = getProxy<ViewSelectionInterfacePrx>(
104 getProperty<std::string>("ViewSelectionName").getValue());
106 getProperty<std::string>("ForceTorqueObserverName").getValue());
107
108 // initialize remote robot
109 remoteRobot.reset(new RemoteRobot(robotStateComponent->getSynchronizedRobot()));
110
111 debugDrawerTopicProxy = getTopic<armarx::DebugDrawerInterfacePrx>("DebugDrawerUpdates");
112 /*if (this->getIceManager()->isObjectReachable("Simulator"))
113 {
114 simulatorPrx = getProxy<SimulatorInterfacePrx>("Simulator");
115 }
116 else
117 {
118 simulatorPrx = NULL;
119 }*/
120
121
122 AgentInstancesSegmentBasePrx agentInstancesProxy =
123 AgentInstancesSegmentBasePrx::uncheckedCast(
124 workingMemoryProxy->getSegment(DEFAULT_SETTINGS_AGENT_INSTANCES_SEGMENT_NAME));
125
126 if (agentInstancesProxy)
127 {
128 agent = AgentInstancePtr::dynamicCast(
129 agentInstancesProxy->getAgentInstanceByName("Armar3"));
130 }
131 else
132 {
133 agent = nullptr;
134 }
135 }
136
137 Eigen::Matrix4f
139 {
140 Eigen::Matrix4f robotPose = Eigen::Matrix4f::Identity();
141
142 if (!agent)
143 {
144 ARMARX_ERROR << deactivateSpam() << "no agent with name Armar3";
145 }
146 else
147 {
148
149 FramedPositionPtr agentPosition = agent->getPosition();
150
151 if (agentPosition)
152 {
153 robotPose.block<3,1>(0, 3) = agentPosition->toEigen();
154 }
155
156 FramedOrientationPtr agentOrientation = agent->getOrientation();
157
158 if (agentOrientation)
159 {
160 robotPose.block<3, 3>(0, 0) = agentOrientation->toEigen();
161 }
162 }
163
164 return robotPose;
165 }
166
168 CoupledInteractionGroupStatechartContext::createPropertyDefinitions()
169 {
172 }
173} // namespace armarx::CoupledInteractionGroup
#define DEFAULT_SETTINGS_AGENT_INSTANCES_SEGMENT_NAME
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition Component.cpp:90
Property< PropertyType > getProperty(const std::string &name)
void onInitStatechartContext() override
onInitStatechartonInitStatechartContext can be implemented by subclasses
void onConnectStatechartContext() override
onConnectStatechartContext can be implemented by subclasses
SpamFilterDataPtr deactivateSpam(float deactivationDurationSec=10.0f, const std::string &identifier="", bool deactivate=true) const
disables the logging for the current line for the given amount of seconds.
Definition Logging.cpp:99
void offeringTopic(const std::string &name)
Registers a topic for retrival after initialization.
TopicProxyType getTopic(const std::string &name)
Returns a proxy of the specified topic.
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)
Mimics the behaviour of the VirtualRobot::Robot class while redirecting everything to an Ice proxy.
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:181
#define ARMARX_ERROR
The logging level for unexpected behaviour, that must be fixed.
Definition Logging.h:196
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
IceInternal::Handle< FramedPosition > FramedPositionPtr
Definition FramedPose.h:149
IceInternal::Handle< FramedOrientation > FramedOrientationPtr
Definition FramedPose.h:207
VirtualRobot headers.