Skip to content

Commit 4ba0c3b

Browse files
committed
[RPP] Add parameter to enable/disable collision detection
1 parent ff00365 commit 4ba0c3b

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

nav2_regulated_pure_pursuit_controller/include/nav2_regulated_pure_pursuit_controller/regulated_pure_pursuit_controller.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ class RegulatedPurePursuitController : public nav2_core::Controller
292292
double approach_velocity_scaling_dist_;
293293
double control_duration_;
294294
double max_allowed_time_to_collision_up_to_carrot_;
295+
bool use_collision_detection_;
295296
bool use_regulated_linear_velocity_scaling_;
296297
bool use_cost_regulated_linear_velocity_scaling_;
297298
double cost_scaling_dist_;

nav2_regulated_pure_pursuit_controller/src/regulated_pure_pursuit_controller.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ void RegulatedPurePursuitController::configure(
8585
declare_parameter_if_not_declared(
8686
node, plugin_name_ + ".max_allowed_time_to_collision_up_to_carrot",
8787
rclcpp::ParameterValue(1.0));
88+
declare_parameter_if_not_declared(
89+
node, plugin_name_ + ".use_collision_detection",
90+
rclcpp::ParameterValue(true));
8891
declare_parameter_if_not_declared(
8992
node, plugin_name_ + ".use_regulated_linear_velocity_scaling", rclcpp::ParameterValue(true));
9093
declare_parameter_if_not_declared(
@@ -142,6 +145,9 @@ void RegulatedPurePursuitController::configure(
142145
node->get_parameter(
143146
plugin_name_ + ".max_allowed_time_to_collision_up_to_carrot",
144147
max_allowed_time_to_collision_up_to_carrot_);
148+
node->get_parameter(
149+
plugin_name_ + ".use_collision_detection",
150+
use_collision_detection_);
145151
node->get_parameter(
146152
plugin_name_ + ".use_regulated_linear_velocity_scaling",
147153
use_regulated_linear_velocity_scaling_);
@@ -346,7 +352,7 @@ geometry_msgs::msg::TwistStamped RegulatedPurePursuitController::computeVelocity
346352

347353
// Collision checking on this velocity heading
348354
const double & carrot_dist = hypot(carrot_pose.pose.position.x, carrot_pose.pose.position.y);
349-
if (isCollisionImminent(pose, linear_vel, angular_vel, carrot_dist)) {
355+
if (use_collision_detection_ && isCollisionImminent(pose, linear_vel, angular_vel, carrot_dist)) {
350356
throw nav2_core::PlannerException("RegulatedPurePursuitController detected collision ahead!");
351357
}
352358

0 commit comments

Comments
 (0)