GraspTableVisualServo.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::GraspTableVisualServoGroup
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 
25 #include "GraspTableVisualServo.h"
26 
28 
29 
30 using namespace armarx;
31 using namespace CoupledInteractionGroup;
32 
33 // DO NOT EDIT NEXT LINE
34 GraspTableVisualServo::SubClassRegistry
37 
40  GraspTableVisualServoGeneratedBase<GraspTableVisualServo>(stateData)
41 {
42 }
43 
44 void
46 {
47 
49  getContext<CoupledInteractionGroupStatechartContext>();
50  // set first view directions manually for initial localization of hands and objects
51  FramedPositionPtr viewTarget;
52  std::string frameName =
53  context->getRobotStateComponent()->getSynchronizedRobot()->getRootNode()->getName();
54  std::string agentName = context->getRobotStateComponent()->getSynchronizedRobot()->getName();
55  Eigen::Vector3f targetPos;
56  targetPos(0) = 0;
57  targetPos(1) = 700;
58  targetPos(2) = 1100;
59  viewTarget = new FramedPosition(targetPos, frameName, agentName);
60  context->getViewSelection()->addManualViewTarget(viewTarget);
61  targetPos(0) = 300;
62  targetPos(1) = 500;
63  targetPos(2) = 1100;
64  viewTarget = new FramedPosition(targetPos, frameName, agentName);
65  context->getViewSelection()->addManualViewTarget(viewTarget);
66  targetPos(0) = 0;
67  targetPos(1) = 700;
68  targetPos(2) = 1100;
69  viewTarget = new FramedPosition(targetPos, frameName, agentName);
70  context->getViewSelection()->addManualViewTarget(viewTarget);
71  targetPos(0) = -300;
72  targetPos(1) = 500;
73  targetPos(2) = 1100;
74  viewTarget = new FramedPosition(targetPos, frameName, agentName);
75  context->getViewSelection()->addManualViewTarget(viewTarget);
76 
77  local.setStartTimeRef(ChannelRefPtr::dynamicCast(
78  context->systemObserverPrx->startTimer("GraspTableVisualServoStartTime")));
79  Eigen::Matrix4f tablePose;
80  tablePose << 1, 0, 0, 0, 0, 1, 0, 700, 0, 0, 1, 950, 0, 0, 0, 1;
81  Eigen::Matrix4f rightTcpTargetPose;
82  Eigen::Matrix4f rightPreTcpTargetPose;
83  /*rightTcpTargetPose << 0.243387, -0.965925, 0.0880421, 365.426,
84  -0.342303, -0.000609159, 0.939589, 510.511,
85  -0.907519, -0.25882, -0.330787, 905.272,
86  0, 0, 0, 1;*/
87  /*rightTcpTargetPose << 0.0404131, -0.641525, -0.766036, 297.815,
88  -0.0199878, -0.767028, 0.641302, 400.0,
89  -0.998983, -0.0106055, -0.0438203, in.getTableHeight(),
90  0, 0, 0, 1;*/
91  /*rightTcpTargetPose << 0.53654, -0.178574, -0.824764, 280.355,
92  0.253516, -0.898098, 0.359374, 384.811,
93  -0.804894, -0.401909, -0.436594, in.getTableHeight(),
94  0, 0, 0, 1;*/
95  /*rightTcpTargetPose << 0.19216, -0.838976, -0.509109, 282.275,
96  0.0409204, -0.511477, 0.858322, 542.37,
97  -0.98051, -0.185769, -0.0639541, 988.324,
98  0, 0, 0, 1;*/
99  rightTcpTargetPose << 0.56283, -0.354918, -0.746496, 0.5 * in.getTableWidth(), 0.0284304,
100  -0.910899, 0.411648, 439.878, -0.826084, -0.210465, -0.522772, in.getTableHeight(), 0, 0, 0,
101  1;
102 
103  Eigen::Matrix4f leftTcpTargetPose;
104  Eigen::Matrix4f leftPreTcpTargetPose;
105  /*leftTcpTargetPose << -0.24339, -0.965924, -0.0880399, -365.426,
106  -0.34231, 0.000614762, 0.939587, 510.507,
107  -0.907516, 0.258823, -0.330795, 905.269,
108  0, 0, 0, 1;*/
109  /*leftTcpTargetPose << -0.0404158, -0.641524, 0.766038, -297.815,
110  -0.0199951, 0.76703, 0.6413, 400.0,
111  -0.998983, 0.0106016, -0.0438274, in.getTableHeight(),
112  0, 0, 0, 1;*/
113  /*leftTcpTargetPose << -0.19216, -0.838976, 0.509109, -282.275,
114  0.0409204, 0.511477, 0.858322, 542.37,
115  -0.98051, 0.185769, -0.0639541, 988.324,
116  0, 0, 0, 1;*/
117  /*leftTcpTargetPose << -0.53654, -0.178574, 0.824764, -280.355,
118  0.253516, 0.898098, 0.359374, 384.811,
119  -0.804894, 0.401909, -0.436594, in.getTableHeight(),
120  0, 0, 0, 1;*/
121  leftTcpTargetPose << -0.56283, -0.354918, 0.746496, -0.5 * in.getTableWidth(), -0.0284304,
122  0.910899, 0.411648, 439.878, -0.826084, 0.210465, -0.522772, in.getTableHeight(), 0, 0, 0,
123  1;
124 
125  leftPreTcpTargetPose = leftTcpTargetPose;
126  rightPreTcpTargetPose = rightTcpTargetPose;
127  leftPreTcpTargetPose(0, 3) -= 150.0;
128  rightPreTcpTargetPose(0, 3) += 150.0;
129  leftPreTcpTargetPose(1, 3) -= 50.0;
130  rightPreTcpTargetPose(1, 3) -= 50.0;
131  ARMARX_IMPORTANT << "in GraspTableState robot global pose:"
132  << context->getRobot()->getGlobalPose();
133  FramedPose tableFramedPoseBase =
134  FramedPose(tablePose, std::string("Armar3_Base"), std::string("Armar3"));
135  ;
136  FramedPose leftTcpTargetFramedPose =
137  FramedPose(leftTcpTargetPose, std::string("Armar3_Base"), std::string("Armar3"));
138  FramedPose leftPreTcpTargetFramedPose =
139  FramedPose(leftPreTcpTargetPose, std::string("Armar3_Base"), std::string("Armar3"));
140  ;
141  FramedPose rightTcpTargetFramedPose =
142  FramedPose(rightTcpTargetPose, std::string("Armar3_Base"), std::string("Armar3"));
143  ;
144  FramedPose rightPreTcpTargetFramedPose =
145  FramedPose(rightPreTcpTargetPose, std::string("Armar3_Base"), std::string("Armar3"));
146  ;
147  ARMARX_INFO << "leftTcpTargetGlobal "
148  << leftTcpTargetFramedPose.toGlobal(context->getRobot())->toEigen();
149  //TODO calculate these poses
150  local.setFramedTablePose(tableFramedPoseBase);
151  local.setLeftTcpPreTargetPose(leftPreTcpTargetFramedPose);
152  local.setLeftTcpTargetPose(leftTcpTargetFramedPose);
153  local.setRightTcpPreTargetPose(rightPreTcpTargetFramedPose);
154  local.setRightTcpTargetPose(rightTcpTargetFramedPose);
155 }
156 
157 void
159 {
160  // put your user code for the execution-phase here
161  // runs in seperate thread, thus can do complex operations
162  // should check constantly whether isRunningTaskStopped() returns true
163 }
164 
165 void
167 {
168  // put your user code for the breaking point here
169  // execution time should be short (<100ms)
170 }
171 
172 void
174 {
176  getContext<CoupledInteractionGroupStatechartContext>();
177  context->systemObserverPrx->removeTimer(local.getStartTimeRef());
178  // put your user code for the exit point here
179  // execution time should be short (<100ms)
180 }
181 
182 // DO NOT EDIT NEXT FUNCTION
183 std::string
185 {
186  return "GraspTableVisualServo";
187 }
188 
189 // DO NOT EDIT NEXT FUNCTION
192 {
193  return XMLStateFactoryBasePtr(new GraspTableVisualServo(stateData));
194 }
RemoteRobot.h
armarx::CoupledInteractionGroup::GraspTableVisualServo::onEnter
void onEnter() override
Definition: GraspTableVisualServo.cpp:45
ARMARX_IMPORTANT
#define ARMARX_IMPORTANT
Definition: Logging.h:190
armarx::FramedPose
The FramedPose class.
Definition: FramedPose.h:280
armarx::VariantType::FramedPose
const VariantTypeId FramedPose
Definition: FramedPose.h:36
armarx::CoupledInteractionGroup::GraspTableVisualServo::GetName
static std::string GetName()
Definition: GraspTableVisualServo.cpp:184
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:650
GraspTableVisualServo.h
armarx::CoupledInteractionGroup::GraspTableVisualServo
Definition: GraspTableVisualServo.h:37
armarx::CoupledInteractionGroup::CoupledInteractionGroupStatechartContext::getRobotStateComponent
RobotStateComponentInterfacePrx getRobotStateComponent()
Definition: CoupledInteractionGroupStatechartContext.h:139
armarx::StatechartContext::systemObserverPrx
SystemObserverInterfacePrx systemObserverPrx
Definition: StatechartContext.h:198
armarx::XMLStateConstructorParams
Definition: XMLState.h:49
armarx::CoupledInteractionGroup::GraspTableVisualServo::Registry
static SubClassRegistry Registry
Definition: GraspTableVisualServo.h:51
armarx::FramedPose::toGlobal
FramedPosePtr toGlobal(const SharedRobotInterfacePrx &referenceRobot) const
Definition: FramedPose.cpp:576
armarx::XMLStateFactoryBasePtr
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition: XMLState.h:64
IceInternal::Handle< FramedPosition >
armarx::CoupledInteractionGroup::CoupledInteractionGroupStatechartContext::getRobot
const VirtualRobot::RobotPtr getRobot()
Definition: CoupledInteractionGroupStatechartContext.h:133
armarx::XMLStateTemplate
Class for legacy to stay compatible with old statecharts.
Definition: XMLState.h:146
armarx::CoupledInteractionGroup::GraspTableVisualServo::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: GraspTableVisualServo.cpp:191
armarx::CoupledInteractionGroup::GraspTableVisualServo::onBreak
void onBreak() override
Definition: GraspTableVisualServo.cpp:166
armarx::CoupledInteractionGroup::GraspTableVisualServo::GraspTableVisualServo
GraspTableVisualServo(XMLStateConstructorParams stateData)
Definition: GraspTableVisualServo.cpp:38
armarx::CoupledInteractionGroup::GraspTableVisualServo::run
void run() override
Definition: GraspTableVisualServo.cpp:158
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:181
armarx::CoupledInteractionGroup::CoupledInteractionGroupStatechartContext
Definition: CoupledInteractionGroupStatechartContext.h:118
armarx::CoupledInteractionGroup::CoupledInteractionGroupStatechartContext::getViewSelection
ViewSelectionInterfacePrx getViewSelection()
Definition: CoupledInteractionGroupStatechartContext.h:215
armarx::VariantType::FramedPosition
const VariantTypeId FramedPosition
Definition: FramedPose.h:38
armarx::CoupledInteractionGroup::GraspTableVisualServo::onExit
void onExit() override
Definition: GraspTableVisualServo.cpp:173
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27