Skip to content

Commit 6e58fbe

Browse files
authored
Make sure fixed curvature lookahead distance doesn't overshoot distance to cusp (#5134)
Related issue: #5098
1 parent a291975 commit 6e58fbe

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

nav2_regulated_pure_pursuit_controller/src/regulated_pure_pursuit_controller.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ geometry_msgs::msg::TwistStamped RegulatedPurePursuitController::computeVelocity
187187

188188
// Find look ahead distance and point on path and publish
189189
double lookahead_dist = getLookAheadDistance(speed);
190+
double curv_lookahead_dist = params_->curvature_lookahead_dist;
190191

191192
// Check for reverse driving
192193
if (params_->allow_reversing) {
@@ -197,6 +198,9 @@ geometry_msgs::msg::TwistStamped RegulatedPurePursuitController::computeVelocity
197198
if (dist_to_cusp < lookahead_dist) {
198199
lookahead_dist = dist_to_cusp;
199200
}
201+
if (dist_to_cusp < curv_lookahead_dist) {
202+
curv_lookahead_dist = dist_to_cusp;
203+
}
200204
}
201205

202206
// Get the particular point on the path at the lookahead distance
@@ -211,7 +215,7 @@ geometry_msgs::msg::TwistStamped RegulatedPurePursuitController::computeVelocity
211215
double regulation_curvature = lookahead_curvature;
212216
if (params_->use_fixed_curvature_lookahead) {
213217
auto curvature_lookahead_pose = getLookAheadPoint(
214-
params_->curvature_lookahead_dist,
218+
curv_lookahead_dist,
215219
transformed_plan, params_->interpolate_curvature_after_goal);
216220
rotate_to_path_carrot_pose = curvature_lookahead_pose;
217221
regulation_curvature = calculateCurvature(curvature_lookahead_pose.pose.position);

0 commit comments

Comments
 (0)