CheckLiftHeight.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::CheckLiftHeightGroup
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 "CheckLiftHeight.h"
27 
28 
29 using namespace armarx;
30 using namespace CoupledInteractionGroup;
31 
32 // DO NOT EDIT NEXT LINE
34 
35 
36 
38  XMLStateTemplate < CheckLiftHeight > (stateData), CheckLiftHeightGeneratedBase < CheckLiftHeight > (stateData)
39 {
40 }
41 
43 {
44  CoupledInteractionGroupStatechartContext* context = getContext<CoupledInteractionGroupStatechartContext>();
45  float liftOffset = in.getLiftOffset();
46  Eigen::Matrix4f leftTcpPoseBase = context->getRobot()->getRobotNode(in.getLeftHandName())->getPoseInRootFrame();
47  Eigen::Matrix4f rightTcpPoseBase = context->getRobot()->getRobotNode(in.getRightHandName())->getPoseInRootFrame();
48  FramedPosePtr initialLeftTcpPoseBase = in.getInitialLeftTcpPose();
49  FramedPosePtr initialRightTcpPoseBase = in.getInitialRightTcpPose();
50  //leftTcpPoseBase->toEigen();
51  Eigen::Matrix4f initLeftTcpPoseBase = initialLeftTcpPoseBase->toEigen();
52  Eigen::Matrix4f initRightTcpPoseBase = initialRightTcpPoseBase->toEigen();
53  Eigen::Vector3f leftOrientationVel;
54  leftOrientationVel(0) = 0.0;
55  leftOrientationVel(1) = 0.0;
56  leftOrientationVel(2) = 0.0;
57  Eigen::Vector3f rightOrientationVel;
58  rightOrientationVel(0) = 0.0;
59  rightOrientationVel(1) = 0.0;
60  rightOrientationVel(2) = 0.0;
61  Eigen::Vector3f leftPositionVel;
62  leftPositionVel(0) = 0.0;
63  leftPositionVel(1) = 0.0;
64  leftPositionVel(2) = liftOffset + initLeftTcpPoseBase(2, 3) - leftTcpPoseBase(2, 3);
65  ARMARX_INFO << "in check lift height init and current" << initLeftTcpPoseBase(2, 3) << " " << leftTcpPoseBase(2, 3);
66  Eigen::Vector3f rightPositionVel;
67  rightPositionVel(0) = 0.0;
68  rightPositionVel(1) = 0.0;
69  rightPositionVel(2) = liftOffset + initRightTcpPoseBase(2, 3) - rightTcpPoseBase(2, 3);
70 
71  if (fabs(rightPositionVel(2)) < 30.0 || fabs(leftPositionVel(2)) < 30.0)
72  {
73  leftPositionVel(2) = 0;
74  rightPositionVel(2) = 0;
75  out.setCurrentLeftOrientationVel(FramedDirection(leftOrientationVel, "Armar3_Base", "Armar3"));
76  out.setCurrentRightOrientationVel(FramedDirection(rightOrientationVel, "Armar3_Base", "Armar3"));
77  out.setCurrentLeftPositionVel(FramedDirection(leftPositionVel, "Armar3_Base", "Armar3"));
78  out.setCurrentRightPositionVel(FramedDirection(rightPositionVel, "Armar3_Base", "Armar3"));
79  emitEvLiftHeightReached();
80  }
81  else
82  {
83  out.setCurrentLeftOrientationVel(FramedDirection(leftOrientationVel, "Armar3_Base", "Armar3"));
84  out.setCurrentRightOrientationVel(FramedDirection(rightOrientationVel, "Armar3_Base", "Armar3"));
85  out.setCurrentLeftPositionVel(FramedDirection(leftPositionVel, "Armar3_Base", "Armar3"));
86  out.setCurrentRightPositionVel(FramedDirection(rightPositionVel, "Armar3_Base", "Armar3"));
87  emitEvLiftHeightNotReached();
88  }
89 }
90 
92 {
93  // put your user code for the execution-phase here
94  // runs in seperate thread, thus can do complex operations
95  // should check constantly whether isRunningTaskStopped() returns true
96 
97 }
98 
100 {
101  // put your user code for the breaking point here
102  // execution time should be short (<100ms)
103 }
104 
106 {
107 
108  // put your user code for the exit point here
109  // execution time should be short (<100ms)
110 
111 }
112 
113 // DO NOT EDIT NEXT FUNCTION
115 {
116  return "CheckLiftHeight";
117 }
118 
119 // DO NOT EDIT NEXT FUNCTION
121 {
122  return XMLStateFactoryBasePtr(new CheckLiftHeight(stateData));
123 }
124 
RemoteRobot.h
armarx::CoupledInteractionGroup::CheckLiftHeight
Definition: CheckLiftHeight.h:34
armarx::XMLStateConstructorParams
Definition: XMLState.h:50
armarx::CoupledInteractionGroup::CheckLiftHeight::onEnter
void onEnter() override
Definition: CheckLiftHeight.cpp:42
armarx::CoupledInteractionGroup::CheckLiftHeight::onBreak
void onBreak() override
Definition: CheckLiftHeight.cpp:99
armarx::CoupledInteractionGroup::CheckLiftHeight::Registry
static SubClassRegistry Registry
Definition: CheckLiftHeight.h:49
armarx::CoupledInteractionGroup::CheckLiftHeight::run
void run() override
Definition: CheckLiftHeight.cpp:91
IceInternal::Handle< FramedPose >
armarx::CoupledInteractionGroup::CheckLiftHeight::GetName
static std::string GetName()
Definition: CheckLiftHeight.cpp:114
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::CheckLiftHeight::CheckLiftHeight
CheckLiftHeight(XMLStateConstructorParams stateData)
Definition: CheckLiftHeight.cpp:37
armarx::CoupledInteractionGroup::CheckLiftHeight::onExit
void onExit() override
Definition: CheckLiftHeight.cpp:105
armarx::CoupledInteractionGroup::CheckLiftHeight::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: CheckLiftHeight.cpp:120
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::VariantType::FramedDirection
const VariantTypeId FramedDirection
Definition: FramedPose.h:38
armarx::CoupledInteractionGroup::CoupledInteractionGroupStatechartContext
Definition: CoupledInteractionGroupStatechartContext.h:88
CheckLiftHeight.h
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28