TwoArmVisualServoTest.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::VisualServoGroup
19 * @author Markus Grotz ( markus dot grotz 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
26
27#include <RobotAPI/interface/components/ViewSelectionInterface.h>
28
32
33
34using namespace armarx;
35using namespace VisualServoGroup;
36
38
39// DO NOT EDIT NEXT LINE
40TwoArmVisualServoTest::SubClassRegistry
41 TwoArmVisualServoTest::Registry(TwoArmVisualServoTest::GetName(),
43
46 TwoArmVisualServoTestGeneratedBase<TwoArmVisualServoTest>(stateData)
47{
48}
49
51TwoArmVisualServoTest::getChannelRef(std::string objectName)
52{
53
54 VisualServoGroupStatechartContext* context = getContext<VisualServoGroupStatechartContext>();
55 ChannelRefBasePtr memoryChannel =
56 context->getObjectMemoryObserver()->requestObjectClassRepeated(
57 objectName, 250, armarx::DEFAULT_VIEWTARGET_PRIORITY);
58
59 if (memoryChannel)
60 {
61 memoryChannel->validate();
62 return ChannelRefPtr::dynamicCast(memoryChannel);
63 }
64 else
65 {
66 ARMARX_ERROR << "unable to get channel ref";
67 return nullptr;
68 }
69}
70
71void
73{
74
75 std::string leftObjectName = in.getLeftObjectName();
76 local.setLeftObjectMemoryChannel(getChannelRef(leftObjectName));
77
78 std::string rightObjectName = in.getRightObjectName();
79 if (leftObjectName != rightObjectName)
80 {
81 local.setRightObjectMemoryChannel(getChannelRef(rightObjectName));
82 }
83 else
84 {
85 local.setRightObjectMemoryChannel(local.getLeftObjectMemoryChannel());
86 }
87
88
89 std::string leftHandNameInMemory = in.getLeftHandNameInMemory();
90 local.setLeftHandMemoryChannel(getChannelRef(leftHandNameInMemory));
91
92 std::string rightHandNameInMemory = in.getRightHandNameInMemory();
93 local.setRightHandMemoryChannel(getChannelRef(rightHandNameInMemory));
94
95 VisualServoGroupStatechartContext* context = getContext<VisualServoGroupStatechartContext>();
96
97
98 // set first view directions manually for initial localization of hands and objects
99 FramedPositionPtr viewTarget;
100 std::string frameName =
101 context->getRobotStateComponent()->getSynchronizedRobot()->getRootNode()->getName();
102 std::string agentName = context->getRobotStateComponent()->getSynchronizedRobot()->getName();
103 Eigen::Vector3f targetPos;
104 targetPos(0) = 0;
105 targetPos(1) = 700;
106 targetPos(2) = 1100;
107 viewTarget = new FramedPosition(targetPos, frameName, agentName);
108 context->getViewSelection()->addManualViewTarget(viewTarget);
109 targetPos(0) = 300;
110 targetPos(1) = 500;
111 targetPos(2) = 1100;
112 viewTarget = new FramedPosition(targetPos, frameName, agentName);
113 context->getViewSelection()->addManualViewTarget(viewTarget);
114 targetPos(0) = 0;
115 targetPos(1) = 700;
116 targetPos(2) = 1100;
117 viewTarget = new FramedPosition(targetPos, frameName, agentName);
118 context->getViewSelection()->addManualViewTarget(viewTarget);
119 targetPos(0) = -300;
120 targetPos(1) = 500;
121 targetPos(2) = 1100;
122 viewTarget = new FramedPosition(targetPos, frameName, agentName);
123 context->getViewSelection()->addManualViewTarget(viewTarget);
124}
125
126// DO NOT EDIT NEXT FUNCTION
The FramedPosition class.
Definition FramedPose.h:158
TwoArmVisualServoTest(XMLStateConstructorParams stateData)
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Class for legacy to stay compatible with old statecharts.
Definition XMLState.h:147
#define ARMARX_ERROR
The logging level for unexpected behaviour, that must be fixed.
Definition Logging.h:196
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< ChannelRef > ChannelRefPtr
Definition ChannelRef.h:40
IceInternal::Handle< FramedPosition > FramedPositionPtr
Definition FramedPose.h:149
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition XMLState.h:64