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