@@ -101,20 +101,26 @@ double PathFreeGenerator::computeBlendRadius(const std::vector<KDL::Frame>& wayp
101101 }
102102
103103 // The maximum feasible radius for this junction
104- double local_max_radius =
105- std::tan ((M_PI - segment_angle (waypoints_[i - 1 ], waypoints_[i], waypoints_[i + 1 ])) / 2.0 ) *
106- std::min (dist1 / 2.0 , dist2 / 2.0 );
104+ double theta = segment_angle (waypoints_[i - 1 ], waypoints_[i], waypoints_[i + 1 ]);
105+ double local_max_radius = std::tan ((M_PI - theta) / 2.0 ) * std::min (dist1 / 2.0 , dist2 / 2.0 );
107106
108107 // track the tightest constraint
109108 // due to KDL::Path_RoundedComposite don't support changing radius
110109 if (local_max_radius < max_allowed_radius)
111110 max_allowed_radius = local_max_radius;
111+ // to ensure Path_RoundedComposite not throw
112+ // Error_MotionPlanning_Circle_ToSmall or
113+ // Error_MotionPlanning_Circle_No_Plane
114+ if (max_allowed_radius * std::sin (M_PI - std::acos (theta)) * std::clamp (smoothness, MIN_SMOOTHNESS, MAX_SMOOTHNESS) <
115+ KDL::epsilon)
116+ {
117+ max_allowed_radius = KDL::epsilon;
118+ break ;
119+ }
112120 }
121+ max_allowed_radius *= std::clamp (smoothness, MIN_SMOOTHNESS, MAX_SMOOTHNESS);
113122
114- // Apply the smoothness scaling factor
115- double max_radius = max_allowed_radius * std::clamp (smoothness, MIN_SMOOTHNESS, MAX_SMOOTHNESS);
116-
117- return max_radius;
123+ return max_allowed_radius;
118124}
119125void PathFreeGenerator::checkConsecutiveColinearWaypoints (const KDL::Frame& p1, const KDL::Frame& p2,
120126 const KDL::Frame& p3)
0 commit comments