Pose.cpp
Go to the documentation of this file.
1 
18 #include "Pose.hpp"
19 #include "JsonStream.hpp"
21 
22 namespace ISM {
23  std::ostream& operator<<(std::ostream &strm, const ISM::Pose &p) {
24  return strm<<"pose: ["<<p.point<<";"<<p.quat<<"]";
25  }
26 
27  std::ostream& operator<<(std::ostream &strm, const ISM::PosePtr &p) {
28  return strm<<(*p);
29  }
30 
31  bool operator==(const PosePtr& pose1, const PosePtr& pose2)
32  {
33  return *pose1 == *pose2;
34  }
35 
36  bool operator==(const Pose& pose1, const Pose& pose2)
37  {
38  return pose1.point == pose2.point && pose1.quat == pose2.quat;
39  }
40 
41  void Pose::serialize(std::ostream& strm) const {
42  strm<<"{"<<std::endl<<"\"point\": "<<json(this->point)<<", "<<std::endl
43  <<"\"quaternion\": "<<json(this->quat)<<", "<<std::endl
45  <<std::endl<<"}";
46  }
47 
48  void Pose::convertPoseIntoFrame(const boost::shared_ptr<Pose>& pFrame, boost::shared_ptr<Pose>& pResult)
49  {
50  // Initialize the result pointer.
51  pResult.reset(new Pose());
52 
53  // Calculate the relative position by subtracting the position of the child from the parent position.
54  // Rotate the resulting relative position into the parent frame.
55  pResult->point.reset(new ISM::Point(pFrame->quat->getEigen().toRotationMatrix().inverse() * (point->getEigen() - pFrame->point->getEigen())));
56 
57  // The relative orientation is defined as the difference between the orientation of parent and child.
58  pResult->quat.reset(new ISM::Quaternion(quat->getEigen() * pFrame->quat->getEigen().inverse()));
59  }
60 }
static PointPtr vectorToPoint(const Eigen::Vector3d &v)
static Eigen::Vector3d getAxisFromQuat(const QuaternionPtr &quat, const Eigen::Vector3d &viewport=Eigen::Vector3d::UnitX())
Pose()
Definition: Pose.hpp:38
virtual void serialize(std::ostream &strm) const
Definition: Pose.cpp:41
PointPtr point
Definition: Pose.hpp:35
std::ostream & operator<<(std::ostream &strm, const ISM::ObjectRelation &r)
bool operator==(const PointPtr &p1, const PointPtr &p2)
Definition: Point.cpp:39
boost::shared_ptr< Pose > PosePtr
Definition: Pose.hpp:79
void convertPoseIntoFrame(const boost::shared_ptr< Pose > &pFrame, boost::shared_ptr< Pose > &pResult)
Definition: Pose.cpp:48
this namespace contains all generally usable classes.
QuaternionPtr quat
Definition: Pose.hpp:36


asr_lib_ism
Author(s): Hanselmann Fabian, Heller Florian, Heizmann Heinrich, Kübler Marcel, Mehlhaus Jonas, Meißner Pascal, Qattan Mohamad, Reckling Reno, Stroh Daniel
autogenerated on Wed Jan 8 2020 04:02:40