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
30using namespace armarx;
31using namespace CoupledInteractionGroup;
32
33// DO NOT EDIT NEXT LINE
34CheckLiftHeight::SubClassRegistry CheckLiftHeight::Registry(CheckLiftHeight::GetName(),
36
39 CheckLiftHeightGeneratedBase<CheckLiftHeight>(stateData)
40{
41}
42
43void
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
101void
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
109void
111{
112 // put your user code for the breaking point here
113 // execution time should be short (<100ms)
114}
115
116void
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
125std::string
127{
128 return "CheckLiftHeight";
129}
130
131// DO NOT EDIT NEXT FUNCTION
CheckLiftHeight(XMLStateConstructorParams stateData)
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
FramedDirection is a 3 dimensional direction vector with a reference frame.
Definition FramedPose.h:87
Class for legacy to stay compatible with old statecharts.
Definition XMLState.h:147
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:181
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition XMLState.h:64
IceInternal::Handle< FramedPose > FramedPosePtr
Definition FramedPose.h:272