AngleApproximationIKRatingModule.cpp
Go to the documentation of this file.
1 
21 #include <ros/ros.h>
22 
23 namespace robot_model_services {
26 
27  double AngleApproximationIKRatingModule::getPanAngleRating(const geometry_msgs::Point &sourcePosition, const geometry_msgs::Point &targetPosition, double sourceRotationBase, double targetRotationBase)
28  {
29  double angleBetweenPoints = 0.0;
30  if (fabs(targetPosition.y - sourcePosition.y) > 0.000001f && fabs(targetPosition.x - sourcePosition.x) > 0.000001f) //Prevent undefined behavior when distance if close to zero
31  {
32  //ROS_INFO_STREAM("Rating for (" << sourcePosition.x << ", " << sourcePosition.y << ") to (" << targetPosition.x << ", " << targetPosition.y << ")");
33  angleBetweenPoints = std::atan2(targetPosition.y - sourcePosition.y, targetPosition.x - sourcePosition.x);
34  }
35  //Make sure, input is between 0 and 2 PI
36  if (sourceRotationBase <= 0) {sourceRotationBase += 2.0*M_PI;}
37  if (targetRotationBase <= 0) {targetRotationBase += 2.0*M_PI;}
38  double sourceRotDiff = fmod(sourceRotationBase - angleBetweenPoints, 2.0*M_PI);
39  double targetRotDiff = fmod(targetRotationBase - angleBetweenPoints, 2.0*M_PI);
40  //Make sure, rotation difference is between 0 and 2 PI
41  if (sourceRotDiff <= 0) {sourceRotDiff += 2.0*M_PI;}
42  if (targetRotDiff <= 0) {targetRotDiff += 2.0*M_PI;}
43 
44  //Calculate costs, take costs for turning left oder right, depending on which ones better
45  double rotationCosts = std::min(fabs(targetRotDiff), (2.0f*M_PI-fabs(targetRotDiff))) + std::min(fabs(sourceRotDiff), (2.0f*M_PI-fabs(sourceRotDiff)));
46 
47  double rating = pow(0.6, rotationCosts);
48  return rating;
49  }
50 }
51 
52 
IKRatingModule is a generalization for the rating of the inverse kinematic parameters.
f
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
AngleApproximationIKRatingModule()
constructor of the AngleApproximationIKRatingModule object
virtual ~AngleApproximationIKRatingModule()
destructor of the AngleApproximationIKRatingModule 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