Skip to content

Commit 303fdc7

Browse files
doisygGuillaume Doisy
authored andcommitted
Add min_distance_to_obstacle parameter to RPP (#4543)
* min_distance_to_obstacle Signed-off-by: Guillaume Doisy <[email protected]> * suggestion to time base and combine Signed-off-by: Guillaume Doisy <[email protected]> * typo Signed-off-by: Guillaume Doisy <[email protected]> * use min_approach_linear_velocity Signed-off-by: Guillaume Doisy <[email protected]> --------- Signed-off-by: Guillaume Doisy <[email protected]> Co-authored-by: Guillaume Doisy <[email protected]>
1 parent 8febffe commit 303fdc7

File tree

5 files changed

+21
-1
lines changed

5 files changed

+21
-1
lines changed

nav2_regulated_pure_pursuit_controller/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ Note: The maximum allowed time to collision is thresholded by the lookahead poin
9191
| `max_angular_accel` | Maximum allowable angular acceleration while rotating to heading, if enabled |
9292
| `max_robot_pose_search_dist` | Maximum integrated distance along the path to bound the search for the closest pose to the robot. This is set by default to the maximum costmap extent, so it shouldn't be set manually unless there are loops within the local costmap. |
9393
| `interpolate_curvature_after_goal` | Needs use_fixed_curvature_lookahead to be true. Interpolate a carrot after the goal dedicated to the curvature calculation (to avoid oscillations at the end of the path) |
94+
| `min_distance_to_obstacle` | The shortest distance at which the robot is allowed to be from an obstacle along its trajectory. Set <= 0.0 to disable. It is limited to maximum distance of lookahead distance selected. |
9495

9596
Example fully-described XML with default parameter values:
9697

nav2_regulated_pure_pursuit_controller/include/nav2_regulated_pure_pursuit_controller/parameter_handler.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ struct Parameters
4242
double min_approach_linear_velocity;
4343
double approach_velocity_scaling_dist;
4444
double max_allowed_time_to_collision_up_to_carrot;
45+
double min_distance_to_obstacle;
4546
bool use_regulated_linear_velocity_scaling;
4647
bool use_cost_regulated_linear_velocity_scaling;
4748
double cost_scaling_dist;

nav2_regulated_pure_pursuit_controller/src/collision_checker.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,16 @@ bool CollisionChecker::isCollisionImminent(
9292
curr_pose.theta = tf2::getYaw(robot_pose.pose.orientation);
9393

9494
// only forward simulate within time requested
95+
double max_allowed_time_to_collision_check = params_->max_allowed_time_to_collision_up_to_carrot;
96+
if (params_->min_distance_to_obstacle > 0.0) {
97+
max_allowed_time_to_collision_check = std::max(
98+
params_->max_allowed_time_to_collision_up_to_carrot,
99+
params_->min_distance_to_obstacle / std::max(std::abs(linear_vel),
100+
params_->min_approach_linear_velocity)
101+
);
102+
}
95103
int i = 1;
96-
while (i * projection_time < params_->max_allowed_time_to_collision_up_to_carrot) {
104+
while (i * projection_time < max_allowed_time_to_collision_check) {
97105
i++;
98106

99107
// apply velocity at curr_pose over distance

nav2_regulated_pure_pursuit_controller/src/parameter_handler.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ ParameterHandler::ParameterHandler(
6161
declare_parameter_if_not_declared(
6262
node, plugin_name_ + ".max_allowed_time_to_collision_up_to_carrot",
6363
rclcpp::ParameterValue(1.0));
64+
declare_parameter_if_not_declared(
65+
node, plugin_name_ + ".min_distance_to_obstacle",
66+
rclcpp::ParameterValue(-1.0));
6467
declare_parameter_if_not_declared(
6568
node, plugin_name_ + ".use_regulated_linear_velocity_scaling", rclcpp::ParameterValue(true));
6669
declare_parameter_if_not_declared(
@@ -131,6 +134,9 @@ ParameterHandler::ParameterHandler(
131134
node->get_parameter(
132135
plugin_name_ + ".max_allowed_time_to_collision_up_to_carrot",
133136
params_.max_allowed_time_to_collision_up_to_carrot);
137+
node->get_parameter(
138+
plugin_name_ + ".min_distance_to_obstacle",
139+
params_.min_distance_to_obstacle);
134140
node->get_parameter(
135141
plugin_name_ + ".use_regulated_linear_velocity_scaling",
136142
params_.use_regulated_linear_velocity_scaling);
@@ -278,6 +284,8 @@ ParameterHandler::updateParametersCallback(
278284
params_.curvature_lookahead_dist = parameter.as_double();
279285
} else if (param_name == plugin_name_ + ".max_allowed_time_to_collision_up_to_carrot") {
280286
params_.max_allowed_time_to_collision_up_to_carrot = parameter.as_double();
287+
} else if (param_name == plugin_name_ + ".min_distance_to_obstacle") {
288+
params_.min_distance_to_obstacle = parameter.as_double();
281289
} else if (param_name == plugin_name_ + ".cost_scaling_dist") {
282290
params_.cost_scaling_dist = parameter.as_double();
283291
} else if (param_name == plugin_name_ + ".cost_scaling_gain") {

nav2_regulated_pure_pursuit_controller/test/test_regulated_pp.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,7 @@ TEST(RegulatedPurePursuitTest, testDynamicParameter)
720720
rclcpp::Parameter("test.rotate_to_heading_angular_vel", 18.0),
721721
rclcpp::Parameter("test.min_approach_linear_velocity", 1.0),
722722
rclcpp::Parameter("test.max_allowed_time_to_collision_up_to_carrot", 2.0),
723+
rclcpp::Parameter("test.min_distance_to_obstacle", 2.0),
723724
rclcpp::Parameter("test.cost_scaling_dist", 2.0),
724725
rclcpp::Parameter("test.cost_scaling_gain", 4.0),
725726
rclcpp::Parameter("test.regulated_linear_scaling_min_radius", 10.0),
@@ -749,6 +750,7 @@ TEST(RegulatedPurePursuitTest, testDynamicParameter)
749750
EXPECT_EQ(
750751
node->get_parameter(
751752
"test.max_allowed_time_to_collision_up_to_carrot").as_double(), 2.0);
753+
EXPECT_EQ(node->get_parameter("test.min_distance_to_obstacle").as_double(), 2.0);
752754
EXPECT_EQ(node->get_parameter("test.cost_scaling_dist").as_double(), 2.0);
753755
EXPECT_EQ(node->get_parameter("test.cost_scaling_gain").as_double(), 4.0);
754756
EXPECT_EQ(node->get_parameter("test.regulated_linear_scaling_min_radius").as_double(), 10.0);

0 commit comments

Comments
 (0)