BimanualGraspCandidateHelper.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T),
5  * Karlsruhe Institute of Technology (KIT), all rights reserved.
6  *
7  * ArmarX is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.
10  *
11  * ArmarX is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  *
19  * @author Simon Ottenhaus (simon dot ottenhaus at kit dot edu)
20  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21  * GNU General Public License
22  */
23 
24 #pragma once
25 
26 
27 #include <RobotAPI/interface/units/GraspCandidateProviderInterface.h>
29 
30 #include <VirtualRobot/Robot.h>
31 
32 #include <memory>
33 
34 
35 namespace armarx
36 {
37  typedef std::shared_ptr<class BimanualGraspCandidateHelper> BimanualGraspCandidateHelperPtr;
38 
40  {
41  public:
42  BimanualGraspCandidateHelper(const grasping::BimanualGraspCandidatePtr& candidate, VirtualRobot::RobotPtr robot);
47 
48  struct Side
49  {
51  Eigen::Matrix4f getPrePoseInRobotRoot(float approachDistance) const;
53  Eigen::Vector3f getGraspPositionInRobotRoot() const;
54 
57  Eigen::Vector3f getGraspPositionInGlobal() const;
58 
59  Eigen::Vector3f getApproachVector() const;
60 
61  private:
63  const BimanualGraspCandidateHelper* helper;
64  Eigen::Matrix4f graspPose;
65  Eigen::Vector3f approachVector;
66  Eigen::Vector3f inwardsVector;
67  };
68 
69  Side left() const
70  {
71  Side s;
72  s.helper = this;
73  s.graspPose = defrost(candidate->graspPoseLeft);
74  s.approachVector = defrost(candidate->approachVectorLeft);
75  s.inwardsVector = defrost(candidate->inwardsVectorLeft);
76  return s;
77  }
78  Side right() const
79  {
80  Side s;
81  s.helper = this;
82  s.graspPose = defrost(candidate->graspPoseRight);
83  s.approachVector = defrost(candidate->approachVectorRight);
84  s.inwardsVector = defrost(candidate->inwardsVectorRight);
85  return s;
86  }
87 
88  const grasping::BimanualGraspCandidatePtr getGraspCandidate() const
89  {
90  return candidate;
91  }
92 
93  Eigen::Vector3f defrost(const Vector3BasePtr& base) const
94  {
95  return Vector3Ptr::dynamicCast(base)->toEigen();
96  }
97  Eigen::Matrix4f defrost(const PoseBasePtr& base) const
98  {
99  return PosePtr::dynamicCast(base)->toEigen();
100  }
101 
102  private:
103  grasping::BimanualGraspCandidatePtr candidate;
105  };
106 }
armarx::BimanualGraspCandidateHelper::BimanualGraspCandidateHelper
BimanualGraspCandidateHelper(const grasping::BimanualGraspCandidatePtr &candidate, VirtualRobot::RobotPtr robot)
Definition: BimanualGraspCandidateHelper.cpp:32
armarx::BimanualGraspCandidateHelper::getGraspCandidate
const grasping::BimanualGraspCandidatePtr getGraspCandidate() const
Definition: BimanualGraspCandidateHelper.h:88
armarx::BimanualGraspCandidateHelper::Side::getGraspPositionInGlobal
Eigen::Vector3f getGraspPositionInGlobal() const
Definition: BimanualGraspCandidateHelper.cpp:70
armarx::BimanualGraspCandidateHelper::Side::getPrePoseInRobotRoot
Eigen::Matrix4f getPrePoseInRobotRoot(float approachDistance) const
Definition: BimanualGraspCandidateHelper.cpp:46
Pose.h
armarx::BimanualGraspCandidateHelper::left
Side left() const
Definition: BimanualGraspCandidateHelper.h:69
armarx::BimanualGraspCandidateHelper::Side::getGraspOrientationInGlobal
Eigen::Matrix3f getGraspOrientationInGlobal() const
Definition: BimanualGraspCandidateHelper.cpp:66
armarx::BimanualGraspCandidateHelper::Side::getApproachVector
Eigen::Vector3f getApproachVector() const
Definition: BimanualGraspCandidateHelper.cpp:75
armarx::BimanualGraspCandidateHelper::defrost
Eigen::Vector3f defrost(const Vector3BasePtr &base) const
Definition: BimanualGraspCandidateHelper.h:93
armarx::BimanualGraspCandidateHelper::Side::getGraspOrientationInRobotRoot
Eigen::Matrix3f getGraspOrientationInRobotRoot() const
Definition: BimanualGraspCandidateHelper.cpp:51
armarx::BimanualGraspCandidateHelper::Side::getGraspPoseInRobotRoot
Eigen::Matrix4f getGraspPoseInRobotRoot() const
Definition: BimanualGraspCandidateHelper.cpp:39
armarx::BimanualGraspCandidateHelper::Side
Definition: BimanualGraspCandidateHelper.h:48
armarx::BimanualGraspCandidateHelper::defrost
Eigen::Matrix4f defrost(const PoseBasePtr &base) const
Definition: BimanualGraspCandidateHelper.h:97
GfxTL::Matrix3f
MatrixXX< 3, 3, float > Matrix3f
Definition: MatrixXX.h:600
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
armarx::BimanualGraspCandidateHelper
Definition: BimanualGraspCandidateHelper.h:39
armarx::BimanualGraspCandidateHelper::operator=
BimanualGraspCandidateHelper & operator=(const BimanualGraspCandidateHelper &)=default
armarx::BimanualGraspCandidateHelper::Side::getGraspPositionInRobotRoot
Eigen::Vector3f getGraspPositionInRobotRoot() const
Definition: BimanualGraspCandidateHelper.cpp:56
armarx::BimanualGraspCandidateHelper::right
Side right() const
Definition: BimanualGraspCandidateHelper.h:78
armarx::BimanualGraspCandidateHelperPtr
std::shared_ptr< class BimanualGraspCandidateHelper > BimanualGraspCandidateHelperPtr
Definition: BimanualGraspCandidateHelper.h:37
armarx::BimanualGraspCandidateHelper::Side::getGraspPoseInGlobal
Eigen::Matrix4f getGraspPoseInGlobal() const
Definition: BimanualGraspCandidateHelper.cpp:61
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18