CalculateApproachTablePose.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::CalculateApproachTablePoseGroup
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 
27 
28 
29 using namespace armarx;
30 using namespace CoupledInteractionGroup;
31 
32 // DO NOT EDIT NEXT LINE
34 
35 
36 
38  XMLStateTemplate < CalculateApproachTablePose > (stateData), CalculateApproachTablePoseGeneratedBase<CalculateApproachTablePose>(stateData)
39 {
40 }
41 
42 float CalculateApproachTablePose::getYawAngle(const Eigen::Matrix4f& pose) const
43 {
44  Eigen::Vector3f rpy;
45  VirtualRobot::MathTools::eigen4f2rpy(pose, rpy);
46  return rpy[2];
47 }
48 
49 
51 {
52  CoupledInteractionGroupStatechartContext* context = getContext<CoupledInteractionGroupStatechartContext>();
53  float approachDistance = in.getApproachDistance();
54  float finalDistance = in.getFinalDistance();
55  FramedPosePtr tablePose = in.getTablePose();
56  ARMARX_LOG << "Incoming Table Pose " << *tablePose;
57  Eigen::Matrix4f approachoffset = Eigen::Matrix4f::Identity();
58  approachoffset(0, 3) = approachDistance;
59  Eigen::Matrix4f approachPoseGlobal = tablePose->toGlobal(context->getRobot())->toEigen() * approachoffset;
60 
62  finaloffset(0, 3) = finalDistance;
63  Eigen::Matrix4f finalPoseGlobal = tablePose->toGlobal(context->getRobot())->toEigen() * finaloffset;
64 
65  Eigen::Vector3f finalplatformPosVec(finalPoseGlobal(0, 3),
66  finalPoseGlobal(1, 3),
67  getYawAngle(finalPoseGlobal) + M_PI_2);
68 
69  Eigen::Vector3f approachplatformPosVec(approachPoseGlobal(0, 3),
70  approachPoseGlobal(1, 3),
71  getYawAngle(approachPoseGlobal) + M_PI_2);
72 
73  std::vector< Vector3Ptr > approachPoses;
74  approachPoses.push_back(new Vector3(approachplatformPosVec));
75  approachPoses.push_back(new Vector3(finalplatformPosVec));
76  out.setApproachTablePose(approachPoses);
77  emitEvApproachPoseCalculated();
78 
79 
80 
81 
82  // FramedDirectionPtr tablePose = in.getTablePose();
83  // //Convert from Robot Base Frame to global Base frame
84 
85 
86 
87 
88 
89 
90 
91  // Eigen::Matrix4f approachLocal = Eigen::Matrix4f::Identity();
92  // approachLocal(0,3) = tablePose->x;
93  // approachLocal(1,3) = tablePose->y - approachDistance;
94  // Eigen::Matrix4f finalLocal = Eigen::Matrix4f::Identity();
95  // finalLocal(0,3) = tablePose->x;
96  // finalLocal(1,3) = tablePose->y - finalDistance;
97 
98  // Eigen::Matrix4f globalApproachPose = context->getRobot()->getRootNode()->toGlobalCoordinateSystem(approachLocal);
99  // Eigen::Matrix4f globalFinalPose = context->getRobot()->getRootNode()->toGlobalCoordinateSystem(finalLocal);
100 
101  // PosePtr poseApproach(new Pose(globalApproachPose));
102  // PosePtr poseFinal(new Pose(globalFinalPose));
103  // context->getDebugDrawerTopicProxy()->setPoseDebugLayerVisu("Approach Table", poseApproach);
104  // context->getDebugDrawerTopicProxy()->setPoseDebugLayerVisu("Final Table", poseFinal);
105 
106  // /*
107  // Eigen::Matrix4f tableBaseTransform = Eigen::Matrix4f::Identity();
108  // tableBaseTransform(0,3) = tablePose->x;
109  // tableBaseTransform(1,3) = tablePose->y;
110  // tableBaseTransform(0,0) = cos(tablePose->z);
111  // tableBaseTransform(0,1) = -sin(tablePose->z);
112  // tableBaseTransform(1,1) = cos(tablePose->z);
113  // tableBaseTransform(1,0) = -sin(tablePose->z);
114  // Eigen::Matrix4f approachPoseTableTransform = Eigen::Matrix4f::Identity();
115  // approachPoseTableTransform(1,3) = -approachDistance;
116  // Eigen::Matrix4f finalPoseTableTransform = Eigen::Matrix4f::Identity();
117  // finalPoseTableTransform(1,3) = -finalDistance;
118  // Eigen::Matrix4f globalApproachPose = context->getRobot()->getRootNode()->getGlobalPose()*tableBaseTransform*approachPoseTableTransform;
119  // Eigen::Matrix4f globalFinalPose = context->getRobot()->getRootNode()->getGlobalPose()*tableBaseTransform*finalPoseTableTransform;*/
120 
121  // ARMARX_INFO << "Approach and Final Distance " << approachDistance << " " << finalDistance;
122  // armarx::ChannelRefPtr poseRef = context->getChannelRef(context->getPlatformUnitObserverName(), "platformPose");
123  // //currentBaseVec(0) = poseRef->getDataField("positionX")->getFloat();
124  // //currentBaseVec(1) = poseRef->getDataField("positionY")->getFloat();
125  // //currentBaseVec(2) = poseRef->getDataField("rotation")->getFloat();
126  // ARMARX_INFO << "Approach Pose " << globalApproachPose;
127  // ARMARX_INFO << "Approach Pose " << globalFinalPose;
128  // Vector3Ptr approachPose1 = new Vector3();
129 
130 
131 
132 
133  // approachPose1->x = poseRef->getDataField("positionX")->getFloat()+0.75*(globalApproachPose(0,3)-poseRef->getDataField("positionX")->getFloat());
134 
135  // approachPose1->y = poseRef->getDataField("positionY")->getFloat()+0.75*(globalApproachPose(1,3)-poseRef->getDataField("positionY")->getFloat());
136  // approachPose1->z = poseRef->getDataField("rotation")->getFloat()+0.5*(tablePose->z);
137  // approachPose1->x = globalFinalPose(0,3)+2.0*(approachPose1->x-globalFinalPose(0,3));
138  // approachPose1->y = globalFinalPose(1,3)+2.0*(approachPose1->y-globalFinalPose(1,3));
139  // Vector3Ptr approachPose2 = new Vector3();
140  // approachPose2->x = globalApproachPose(0,3);
141  // approachPose2->y = globalApproachPose(1,3);
142  // approachPose2->z = poseRef->getDataField("rotation")->getFloat()+tablePose->z;
143 
144  // Vector3Ptr finalPose = new Vector3();
145  // finalPose->x = globalFinalPose(0,3);
146  // finalPose->y = globalFinalPose(1,3);
147  // finalPose->z = poseRef->getDataField("rotation")->getFloat()+tablePose->z;
148  // std::vector< Vector3Ptr > approachPoses;
149  // approachPoses.push_back(approachPose1);
150  // approachPoses.push_back(approachPose2);
151  // approachPoses.push_back(finalPose);
152  // out.setApproachTablePose(approachPoses);
153  // emitEvApproachPoseCalculated();
154 }
155 
157 {
158  // put your user code for the execution-phase here
159  // runs in seperate thread, thus can do complex operations
160  // should check constantly whether isRunningTaskStopped() returns true
161 
162 }
163 
165 {
166  // put your user code for the breaking point here
167  // execution time should be short (<100ms)
168 }
169 
171 {
172 
173  // put your user code for the exit point here
174  // execution time should be short (<100ms)
175 
176 }
177 
178 // DO NOT EDIT NEXT FUNCTION
180 {
181  return "CalculateApproachTablePose";
182 }
183 
184 // DO NOT EDIT NEXT FUNCTION
186 {
187  return XMLStateFactoryBasePtr(new CalculateApproachTablePose(stateData));
188 }
189 
RemoteRobot.h
armarx::CoupledInteractionGroup::CalculateApproachTablePose::Registry
static SubClassRegistry Registry
Definition: CalculateApproachTablePose.h:48
armarx::CoupledInteractionGroup::CalculateApproachTablePose::GetName
static std::string GetName()
Definition: CalculateApproachTablePose.cpp:179
armarx::XMLStateConstructorParams
Definition: XMLState.h:50
CalculateApproachTablePose.h
IceInternal::Handle< FramedPose >
armarx::CoupledInteractionGroup::CoupledInteractionGroupStatechartContext::getRobot
const VirtualRobot::RobotPtr getRobot()
Definition: CoupledInteractionGroupStatechartContext.h:101
GfxTL::Identity
void Identity(MatrixXX< N, N, T > *a)
Definition: MatrixXX.h:523
armarx::CoupledInteractionGroup::CalculateApproachTablePose::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: CalculateApproachTablePose.cpp:185
armarx::XMLStateTemplate
Class for legacy to stay compatible with old statecharts.
Definition: XMLState.h:137
ARMARX_LOG
#define ARMARX_LOG
Definition: Logging.h:163
armarx::XMLStateFactoryBasePtr
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition: XMLState.h:65
armarx::CoupledInteractionGroup::CalculateApproachTablePose::onBreak
void onBreak() override
Definition: CalculateApproachTablePose.cpp:164
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
armarx::CoupledInteractionGroup::CalculateApproachTablePose::run
void run() override
Definition: CalculateApproachTablePose.cpp:156
memoryx::KBM::Vector3
Eigen::Vector3d Vector3
Definition: kbm.h:41
armarx::CoupledInteractionGroup::CoupledInteractionGroupStatechartContext
Definition: CoupledInteractionGroupStatechartContext.h:88
armarx::CoupledInteractionGroup::CalculateApproachTablePose::onExit
void onExit() override
Definition: CalculateApproachTablePose.cpp:170
armarx::CoupledInteractionGroup::CalculateApproachTablePose::CalculateApproachTablePose
CalculateApproachTablePose(XMLStateConstructorParams stateData)
Definition: CalculateApproachTablePose.cpp:37
armarx::CoupledInteractionGroup::CalculateApproachTablePose::onEnter
void onEnter() override
Definition: CalculateApproachTablePose.cpp:50
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::CoupledInteractionGroup::CalculateApproachTablePose
Definition: CalculateApproachTablePose.h:33