Skip to content

Commit 6bc74e5

Browse files
[RPP] Prevent collision check premature termination (#5598)
* prevent collision check premature termination Signed-off-by: EricoMeger <ericomeger9@gmail.com> * improve comment wording Co-authored-by: Steve Macenski <stevenmacenski@gmail.com> Signed-off-by: Érico Meger <86668447+EricoMeger@users.noreply.github.com> * fix linting error Signed-off-by: EricoMeger <ericomeger9@gmail.com> --------- Signed-off-by: EricoMeger <ericomeger9@gmail.com> Signed-off-by: Érico Meger <86668447+EricoMeger@users.noreply.github.com> Co-authored-by: Steve Macenski <stevenmacenski@gmail.com>
1 parent 4d28c13 commit 6bc74e5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

‎nav2_regulated_pure_pursuit_controller/src/collision_checker.cpp‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,14 @@ bool CollisionChecker::isCollisionImminent(
9191

9292
// only forward simulate within time requested
9393
double max_allowed_time_to_collision_check = params_->max_allowed_time_to_collision_up_to_carrot;
94+
double simulation_distance_limit = carrot_dist;
9495
if (params_->min_distance_to_obstacle > 0.0) {
9596
max_allowed_time_to_collision_check = std::max(
9697
params_->max_allowed_time_to_collision_up_to_carrot,
9798
params_->min_distance_to_obstacle / std::max(std::abs(linear_vel),
9899
params_->min_approach_linear_velocity)
99100
);
101+
simulation_distance_limit = std::max(carrot_dist, params_->min_distance_to_obstacle);
100102
}
101103
int i = 1;
102104
while (i * projection_time < max_allowed_time_to_collision_check) {
@@ -110,8 +112,11 @@ bool CollisionChecker::isCollisionImminent(
110112
theta += projection_time * angular_vel;
111113
curr_pose.orientation = nav2_util::geometry_utils::orientationAroundZAxis(theta);
112114

113-
// check if past carrot pose, where no longer a thoughtfully valid command
114-
if (hypot(curr_pose.position.x - robot_xy.x, curr_pose.position.y - robot_xy.y) > carrot_dist) {
115+
// Stop simulating if we've gone past the simulation distance limit
116+
// (max: carrot or min distance)
117+
if (hypot(curr_pose.position.x - robot_xy.x,
118+
curr_pose.position.y - robot_xy.y) > simulation_distance_limit)
119+
{
115120
break;
116121
}
117122

0 commit comments

Comments
 (0)