pose_helper.cpp
Go to the documentation of this file.
1 
19 
20 namespace world_model {
21 
23 
25  if (!instance_ptr_) {
27  resetInstance();
28  }
29  return instance_ptr_;
30 }
31 
33  if (instance_ptr_) {
34  // Params can be reseted here
35  }
36 }
37 
39 }
40 
41 
42 double PoseHelper::calcDistancePositionEucl(const geometry_msgs::Pose &pose1, const geometry_msgs::Pose &pose2) {
43  return sqrt(pow(pose1.position.x - pose2.position.x, 2)
44  + pow(pose1.position.y - pose2.position.y, 2)
45  + pow(pose1.position.z - pose2.position.z, 2));
46 }
47 
48 double PoseHelper::calcAngularDistanceInRad(const geometry_msgs::Pose &pose1, const geometry_msgs::Pose &pose2) {
49  Eigen::Quaterniond rotation1 = convertPoseQuatToQuat(pose1);
50  rotation1.normalize();
51  Eigen::Quaterniond rotation2 = convertPoseQuatToQuat(pose2);
52  rotation2.normalize();
53  return rotation1.angularDistance(rotation2);
54 }
55 
56 bool PoseHelper::checkPosesAreApproxEquale(const geometry_msgs::Pose &pose1, const geometry_msgs::Pose &pose2,
57  const double position_threshold, const double orientation_rad_threshold) {
58  return checkPositionsAreApproxEquale(pose1, pose2, position_threshold)
59  && checkOrientationsAreApproxEquale(pose1, pose2, orientation_rad_threshold);
60 }
61 
62 bool PoseHelper::checkPositionsAreApproxEquale(const geometry_msgs::Pose &pose1, const geometry_msgs::Pose &pose2, const double position_threshold) {
63  const double distance_position = calcDistancePositionEucl(pose1, pose2);
64  return position_threshold > distance_position;
65 }
66 
67 bool PoseHelper::checkOrientationsAreApproxEquale(const geometry_msgs::Pose &pose1, const geometry_msgs::Pose &pose2, const double orientation_rad_threshold) {
68  const double distance_orientation_rad = calcAngularDistanceInRad(pose1, pose2);
69  return orientation_rad_threshold > distance_orientation_rad;
70 }
71 
72 }
73 
74 
75 
static void resetInstance()
Definition: pose_helper.cpp:32
bool checkOrientationsAreApproxEquale(const geometry_msgs::Pose &pose1, const geometry_msgs::Pose &pose2, const double orientation_rad_threshold)
Definition: pose_helper.cpp:67
static boost::shared_ptr< PoseHelper > getInstance()
Definition: pose_helper.cpp:24
double calcDistancePositionEucl(const geometry_msgs::Pose &pose1, const geometry_msgs::Pose &pose2)
Definition: pose_helper.cpp:42
static boost::shared_ptr< PoseHelper > instance_ptr_
Definition: pose_helper.hpp:32
Eigen::Quaterniond convertPoseQuatToQuat(const geometry_msgs::Pose &pose)
Definition: pose_helper.hpp:34
bool checkPositionsAreApproxEquale(const geometry_msgs::Pose &pose1, const geometry_msgs::Pose &pose2, const double position_threshold)
Definition: pose_helper.cpp:62
bool checkPosesAreApproxEquale(const geometry_msgs::Pose &pose1, const geometry_msgs::Pose &pose2, const double position_threshold, const double orientation_rad_threshold)
Definition: pose_helper.cpp:56
boost::shared_ptr< PoseHelper > PoseHelperPtr
Definition: pose_helper.hpp:54
double calcAngularDistanceInRad(const geometry_msgs::Pose &pose1, const geometry_msgs::Pose &pose2)
Definition: pose_helper.cpp:48


asr_world_model
Author(s): Aumann Florian, Borella Jocelyn, Hutmacher Robin, Karrenbauer Oliver, Meißner Pascal, Schleicher Ralf, Stöckle Patrick, Trautmann Jeremias
autogenerated on Thu Jan 9 2020 07:20:01