NavigationPathIKRatingModule.cpp
Go to the documentation of this file.
1 
21 #include <ros/ros.h>
22 
23 namespace robot_model_services {
25  {
26  mRobotModel = robotModel;
28  }
30 
31  double NavigationPathIKRatingModule::getPanAngleRating(const geometry_msgs::Point &sourcePosition, const geometry_msgs::Point &targetPosition, double sourceRotationBase, double targetRotationBase)
32  {
33  targetRotationBase = fmod(targetRotationBase + M_PI, 2.0 * M_PI);
34  nav_msgs::Path navigationPath = this->mRobotModel->getNavigationPath(sourcePosition, targetPosition, sourceRotationBase, targetRotationBase);
35 
36  if (navigationPath.poses.size() > 2)
37  {
38  //Get length and angle change of the path
39  double length = 0;
40  double currentDotProduct;
41  double absolutAngleChange = 0;
42  std::vector<geometry_msgs::PoseStamped>::iterator poseIterator = navigationPath.poses.end();
43  geometry_msgs::Pose previousPose_2 = poseIterator->pose;
44  poseIterator--;
45  geometry_msgs::Pose previousPose_1 = poseIterator->pose;
46  poseIterator--;
47  do
48  {
49  length += sqrt(pow(previousPose_1.position.x-(*poseIterator).pose.position.x, 2.0)+pow(previousPose_1.position.y-(*poseIterator).pose.position.y, 2.0));
50  Eigen::Vector2d v1(previousPose_1.position.x - previousPose_2.position.x, previousPose_1.position.y - previousPose_2.position.y);
51  Eigen::Vector2d v2(-previousPose_2.position.x + (*poseIterator).pose.position.x, -previousPose_2.position.y + (*poseIterator).pose.position.y);
52  v1.normalize();
53  v2.normalize();
54  currentDotProduct = v1.dot(v2);
55  if (currentDotProduct < -1.0) currentDotProduct = -1.0;
56  if (currentDotProduct > 1.0) currentDotProduct = 1.0;
57  absolutAngleChange += fabs(acos(currentDotProduct));
58  previousPose_2 = previousPose_1;
59  previousPose_1 = poseIterator->pose;
60  poseIterator--;
61 
62  } while(poseIterator > navigationPath.poses.begin() && length < 1.0); //consider only the last 1 meter of the path
63  double rating = pow(0.6, absolutAngleChange);
64  mDebugHelperPtr->write(std::stringstream() << "Rating: " << rating
65  << " (absolutAngleChange: " << absolutAngleChange
66  << ", length: " << length << ")",
68  return rating;
69  }
70  else
71  {
72  return 0.0;
73  }
74  }
75 }
76 
IKRatingModule is a generalization for the rating of the inverse kinematic parameters.
static boost::shared_ptr< DebugHelper > getInstance()
Definition: DebugHelper.cpp:29
double getPanAngleRating(const geometry_msgs::Point &sourcePosition, const geometry_msgs::Point &targetPosition, double sourceRotationBase, double targetRotationBase)
this namespace contains all generally usable classes.
Definition: DebugHelper.hpp:27
NavigationPathIKRatingModule(RobotModelPtr robotModel)
constructor of the NavigationPathIKRatingModule object
TFSIMD_FORCE_INLINE tfScalar length(const Quaternion &q)
virtual ~NavigationPathIKRatingModule()
destructor of the NavigationPathIKRatingModule object.


asr_robot_model_services
Author(s): Aumann Florian, Borella Jocelyn, Heller Florian, Meißner Pascal, Schleicher Ralf, Stöckle Patrick, Stroh Daniel, Trautmann Jeremias, Walter Milena, Wittenbeck Valerij
autogenerated on Mon Jun 10 2019 12:49:59