diff --git a/nav2_smac_planner/src/analytic_expansion.cpp b/nav2_smac_planner/src/analytic_expansion.cpp index 7c73fb91da7..93026f64aa3 100644 --- a/nav2_smac_planner/src/analytic_expansion.cpp +++ b/nav2_smac_planner/src/analytic_expansion.cpp @@ -189,6 +189,10 @@ typename AnalyticExpansion::AnalyticExpansionNodes AnalyticExpansion(std::floor(d / sqrt_2)); AnalyticExpansionNodes possible_nodes; @@ -248,7 +252,8 @@ typename AnalyticExpansion::AnalyticExpansionNodes AnalyticExpansion max_cost) { + auto max_cost_it = std::max_element(node_costs.begin(), node_costs.end()); + if (max_cost_it != node_costs.end() && *max_cost_it > max_cost) { // If any element is above the comfortable cost limit, check edge cases: // (1) Check if goal is in greater than max_cost space requiring // entering it, but only entering it on final approach, not in-and-out