diff --git a/nav2_navfn_planner/src/navfn.cpp b/nav2_navfn_planner/src/navfn.cpp index 4ffafbe6b83c1e58e33aaf98d5aab560778974c7..d23761eacb2f9cfab980a7830395324a758d01e4 100644 --- a/nav2_navfn_planner/src/navfn.cpp +++ b/nav2_navfn_planner/src/navfn.cpp @@ -295,18 +295,7 @@ NavFn::calcNavFnDijkstra(bool atStart) setupNavFn(true); // calculate the nav fn and path - propNavFnDijkstra(std::max(nx * ny / 20, nx + ny), atStart); - - // path - int len = calcPath(nx * ny / 2); - - if (len > 0) { // found plan - RCLCPP_DEBUG(rclcpp::get_logger("rclcpp"), "[NavFn] Path found, %d steps\n", len); - return true; - } else { - RCLCPP_DEBUG(rclcpp::get_logger("rclcpp"), "[NavFn] No path found\n"); - return false; - } + return propNavFnDijkstra(std::max(nx * ny / 20, nx + ny), atStart); } @@ -320,18 +309,7 @@ NavFn::calcNavFnAstar() setupNavFn(true); // calculate the nav fn and path - propNavFnAstar(std::max(nx * ny / 20, nx + ny)); - - // path - int len = calcPath(nx * 4); - - if (len > 0) { // found plan - RCLCPP_DEBUG(rclcpp::get_logger("rclcpp"), "[NavFn] Path found, %d steps\n", len); - return true; - } else { - RCLCPP_DEBUG(rclcpp::get_logger("rclcpp"), "[NavFn] No path found\n"); - return false; - } + return propNavFnAstar(std::max(nx * ny / 20, nx + ny)); } // diff --git a/nav2_navfn_planner/src/navfn_planner.cpp b/nav2_navfn_planner/src/navfn_planner.cpp index 31ee9060580c8e6272b46b12b696f36b7766b8ee..6b8ccafd4762fedd9e0dfaee8044c5f68a0a646d 100644 --- a/nav2_navfn_planner/src/navfn_planner.cpp +++ b/nav2_navfn_planner/src/navfn_planner.cpp @@ -321,7 +321,13 @@ NavfnPlanner::getPlanFromPotential( planner_->setStart(map_goal); - planner_->calcPath(costmap_->getSizeInCellsX() * 4); + int path_len = planner_->calcPath(costmap_->getSizeInCellsX() * 4); + if (path_len == 0) { + RCLCPP_DEBUG(node_->get_logger(), "No path found\n"); + return false; + } + + RCLCPP_DEBUG(node_->get_logger(), "Path found, %d steps\n", path_len); // extract the plan float * x = planner_->getPathX();