Skip to content

Commit 600633a

Browse files
adding support for rotate in place cusps (#3934)
1 parent edfe5bf commit 600633a

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

nav2_regulated_pure_pursuit_controller/src/regulated_pure_pursuit_controller.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,12 +419,27 @@ double RegulatedPurePursuitController::findVelocitySignChange(
419419
/* Checking for the existance of cusp, in the path, using the dot product
420420
and determine it's distance from the robot. If there is no cusp in the path,
421421
then just determine the distance to the goal location. */
422-
if ( (oa_x * ab_x) + (oa_y * ab_y) < 0.0) {
422+
const double dot_prod = (oa_x * ab_x) + (oa_y * ab_y);
423+
if (dot_prod < 0.0) {
423424
// returning the distance if there is a cusp
424425
// The transformed path is in the robots frame, so robot is at the origin
425426
return hypot(
426427
transformed_plan.poses[pose_id].pose.position.x,
427428
transformed_plan.poses[pose_id].pose.position.y);
429+
} else if (
430+
(hypot(oa_x, oa_y) == 0.0 &&
431+
transformed_plan.poses[pose_id - 1].pose.orientation !=
432+
transformed_plan.poses[pose_id].pose.orientation)
433+
||
434+
(hypot(ab_x, ab_y) == 0.0 &&
435+
transformed_plan.poses[pose_id].pose.orientation !=
436+
transformed_plan.poses[pose_id + 1].pose.orientation))
437+
{
438+
// returning the distance since the points overlap
439+
// but are not simply duplicate points (e.g. in place rotation)
440+
return hypot(
441+
transformed_plan.poses[pose_id].pose.position.x,
442+
transformed_plan.poses[pose_id].pose.position.y);
428443
}
429444
}
430445

nav2_util/include/nav2_util/geometry_utils.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ inline Iter min_by(Iter begin, Iter end, Getter getCompareVal)
132132
Iter lowest_it = begin;
133133
for (Iter it = ++begin; it != end; ++it) {
134134
auto comp = getCompareVal(*it);
135-
if (comp < lowest) {
135+
if (comp <= lowest) {
136136
lowest = comp;
137137
lowest_it = it;
138138
}

0 commit comments

Comments
 (0)