Skip to content

Commit

Permalink
nav2_dwb_controller: add max_deviation parameter
Browse files Browse the repository at this point in the history
Until now, the maximum authorized deviation from the path was
implicitly set to the local costmap half-width. This new parameter
allows to define a custom deviation tolerance. When the threshold is
reached, a nav2_core::PlannerException is thrown.
  • Loading branch information
DylanDeCoeyer-Quimesis committed Jan 18, 2023
1 parent 0fb6fe2 commit ee23251
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ class DWBLocalPlanner : public nav2_core::Controller
nav_2d_msgs::msg::Path2D global_plan_; ///< Saved Global Plan
bool prune_plan_;
double prune_distance_;
double max_deviation_;
bool debug_trajectory_details_;
rclcpp::Duration transform_tolerance_{0, 0};
bool shorten_transformed_plan_;
Expand Down
6 changes: 5 additions & 1 deletion nav2_dwb_controller/dwb_core/src/dwb_local_planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ void DWBLocalPlanner::configure(
declare_parameter_if_not_declared(
node, dwb_plugin_name_ + ".prune_distance",
rclcpp::ParameterValue(1.0));
declare_parameter_if_not_declared(
node, dwb_plugin_name_ + ".max_deviation",
rclcpp::ParameterValue(1.0));
declare_parameter_if_not_declared(
node, dwb_plugin_name_ + ".shorten_distance",
rclcpp::ParameterValue(2.0));
Expand Down Expand Up @@ -118,6 +121,7 @@ void DWBLocalPlanner::configure(

node->get_parameter(dwb_plugin_name_ + ".prune_plan", prune_plan_);
node->get_parameter(dwb_plugin_name_ + ".prune_distance", prune_distance_);
node->get_parameter(dwb_plugin_name_ + ".max_deviation", max_deviation_);
node->get_parameter(dwb_plugin_name_ + ".shorten_distance", shorten_distance_);
node->get_parameter(dwb_plugin_name_ + ".debug_trajectory_details", debug_trajectory_details_);
node->get_parameter(dwb_plugin_name_ + ".trajectory_generator_name", traj_generator_name);
Expand Down Expand Up @@ -503,7 +507,7 @@ DWBLocalPlanner::transformGlobalPlan(
}
}

if (smallest_distance == dist_threshold)
if (smallest_distance == dist_threshold || smallest_distance > max_deviation_)
{
throw nav2_core::ControllerException("The robot is too far from the path.");
}
Expand Down

0 comments on commit ee23251

Please sign in to comment.