Pose.cpp
Go to the documentation of this file.
1 
18 #include "Pose.h"
19 
20 namespace ResourcesForPsm {
21 
23  {
24  mPosition.reset(new Eigen::Vector3d(0, 0, 0));
25  mOrientation.reset(new Eigen::Quaternion<double>(1, 0, 0, 0));
26  }
27 
28  Pose::Pose(const asr_msgs::AsrObject pObject)
29  {
30 
31  if(!pObject.sampledPoses.size()){
32  std::cerr << "Got a AsrObject without poses." << std::endl;
33  std::exit(1);
34  }
35 
36  // Copy the position.
37  mPosition.reset(new Eigen::Vector3d(pObject.sampledPoses.front().pose.position.x,
38  pObject.sampledPoses.front().pose.position.y,
39  pObject.sampledPoses.front().pose.position.z));
40 
41  // Copy the orientation.
42  mOrientation.reset(new Eigen::Quaternion<double>(pObject.sampledPoses.front().pose.orientation.w,
43  pObject.sampledPoses.front().pose.orientation.x,
44  pObject.sampledPoses.front().pose.orientation.y,
45  pObject.sampledPoses.front().pose.orientation.z));
46 
47  }
48 
49  Pose::Pose(const geometry_msgs::Pose pPose)
50  {
51  // Copy the position.
52  mPosition.reset(new Eigen::Vector3d(pPose.position.x,
53  pPose.position.y,
54  pPose.position.z));
55 
56  // Copy the orientation.
57  mOrientation.reset(new Eigen::Quaternion<double>(pPose.orientation.w,
58  pPose.orientation.x,
59  pPose.orientation.y,
60  pPose.orientation.z));
61  }
62 
63  Pose::Pose(const boost::shared_ptr<SceneModel::Object> pObject)
64  {
65  mPosition = pObject->mPosition;
66  mOrientation = pObject->mOrientation;
67  }
68 
70  {
71  }
72 
73  void Pose::convertPoseIntoFrame(const boost::shared_ptr<Pose>& pFrame, boost::shared_ptr<Pose>& pResult)
74  {
75  // Initialize the result pointer.
76  pResult.reset(new Pose());
77 
78  // Calculate the relative position by subtracting the position of the child from the parent position.
79  // Rotate the resulting relative position into the parent frame.
80 // pResult->mPosition.reset(new Eigen::Vector3d(pFrame->mOrientation->toRotationMatrix().inverse() * (*pFrame->mPosition - *mPosition)));
81  pResult->mPosition.reset(new Eigen::Vector3d(pFrame->mOrientation->toRotationMatrix().inverse() * (*mPosition - *pFrame->mPosition)));
82 
83  // The relative orientation is defined as the difference between the orientation of parent and child.
84  pResult->mOrientation.reset(new Eigen::Quaternion<double>(*mOrientation * pFrame->mOrientation->inverse()));
85  }
86 
87  Eigen::Vector3d Pose::getPosition()
88  {
89  return *mPosition;
90  }
91 
92  Eigen::Quaternion<double> Pose::getOrientation()
93  {
94  return *mOrientation;
95  }
96 
97 }
Eigen::Quaternion< double > getOrientation()
Definition: Pose.cpp:92
boost::shared_ptr< Eigen::Vector3d > mPosition
Definition: Pose.h:101
Eigen::Vector3d getPosition()
Definition: Pose.cpp:87
void convertPoseIntoFrame(const boost::shared_ptr< Pose > &pFrame, boost::shared_ptr< Pose > &pResult)
Definition: Pose.cpp:73
boost::shared_ptr< Eigen::Quaternion< double > > mOrientation
Definition: Pose.h:106


asr_resources_for_psm
Author(s): Gehrung Joachim, Meißner Pascal
autogenerated on Fri Nov 8 2019 03:42:23