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