40 const KDL::Frame& goal_pose,
41 const KDL::Vector& center_point,
double eqradius)
43 double a = (start_pose.p - center_point).Norm();
44 double b = (goal_pose.p - center_point).Norm();
45 double c = (start_pose.p - goal_pose.p).Norm();
47 if (fabs(a - b) > MAX_RADIUS_DIFF)
53 double alpha = cosines(a, b, c);
55 KDL::RotationalInterpolation* rot_interpo =
new KDL::RotationalInterpolation_SingleAxis();
56 double old_kdl_epsilon = KDL::epsilon;
59 KDL::epsilon = MAX_COLINEAR_NORM;
60 auto circle = std::unique_ptr<KDL::Path>(
61 new KDL::Path_Circle(start_pose, center_point, goal_pose.p, goal_pose.M, alpha, rot_interpo, eqradius,
63 KDL::epsilon = old_kdl_epsilon;
66 catch (KDL::Error_MotionPlanning&)
68 KDL::epsilon = old_kdl_epsilon;
74 const KDL::Frame& goal_pose,
75 const KDL::Vector& interim_point,
double eqradius)
79 const KDL::Vector t = interim_point - start_pose.p;
80 const KDL::Vector u = goal_pose.p - start_pose.p;
81 const KDL::Vector v = goal_pose.p - interim_point;
83 const KDL::Vector w = t * u;
86 if (w.Norm() < MAX_COLINEAR_NORM)
88 throw KDL::Error_MotionPlanning_Circle_No_Plane();
90 const KDL::Vector center_point =
91 start_pose.p + (u * dot(t, t) * dot(u, v) - t * dot(u, u) * dot(t, v)) * 0.5 / pow(w.Norm(), 2);
95 const KDL::Vector t_center = center_point - start_pose.p;
96 const KDL::Vector v_center = goal_pose.p - center_point;
97 double a = t_center.Norm();
98 double b = v_center.Norm();
100 double alpha = cosines(a, b, c);
102 KDL::Vector kdl_aux_point(interim_point);
108 double interim_angle = cosines(t.Norm(), v.Norm(), u.Norm());
109 if (interim_angle < M_PI / 2)
111 alpha = 2 * M_PI - alpha;
115 if ((t_center * v_center).Norm() > MAX_COLINEAR_NORM)
117 kdl_aux_point = 2 * center_point - goal_pose.p;
121 KDL::RotationalInterpolation* rot_interpo =
new KDL::RotationalInterpolation_SingleAxis();
122 return std::unique_ptr<KDL::Path>(
123 std::make_unique<KDL::Path_Circle>(start_pose, center_point, kdl_aux_point, goal_pose.M, alpha, rot_interpo,
127 double PathCircleGenerator::cosines(
const double a,
const double b,
const double c)
129 return acos(std::max(std::min((pow(a, 2) + pow(b, 2) - pow(c, 2)) / (2.0 * a * b), 1.0), -1.0));
static std::unique_ptr< KDL::Path > circleFromCenter(const KDL::Frame &start_pose, const KDL::Frame &goal_pose, const KDL::Vector ¢er_point, double eqradius)
set the path circle from start, goal and center point
static std::unique_ptr< KDL::Path > circleFromInterim(const KDL::Frame &start_pose, const KDL::Frame &goal_pose, const KDL::Vector &interim_point, double eqradius)
set circle from start, goal and interim point