diff --git a/nav2_navfn_planner/src/navfn_planner.cpp b/nav2_navfn_planner/src/navfn_planner.cpp index 2258b5e19f..1b2e2d5e95 100644 --- a/nav2_navfn_planner/src/navfn_planner.cpp +++ b/nav2_navfn_planner/src/navfn_planner.cpp @@ -320,7 +320,10 @@ NavfnPlanner::getPlanFromPotential( planner_->setStart(map_goal); - int path_len = planner_->calcPath(costmap_->getSizeInCellsX() * 4); + const int & max_cycles = (costmap_->getSizeInCellsX() >= costmap_->getSizeInCellsY()) ? + (costmap_->getSizeInCellsX() * 4) : (costmap_->getSizeInCellsY() * 4); + + int path_len = planner_->calcPath(max_cycles); if (path_len == 0) { return false; }