Skip to content

Commit 9fc413a

Browse files
committed
restrict the rounding radius to not exceed KDL epsilon
1 parent 5072fbd commit 9fc413a

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

moveit_planners/pilz_industrial_motion_planner/src/path_free_generator.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}
119125
void PathFreeGenerator::checkConsecutiveColinearWaypoints(const KDL::Frame& p1, const KDL::Frame& p2,
120126
const KDL::Frame& p3)

0 commit comments

Comments
 (0)