From a160af8de3215aa1887300931cf0d91c5940e78f Mon Sep 17 00:00:00 2001 From: Pimpest <82343504+Pimpest@users.noreply.github.com> Date: Fri, 2 May 2025 19:00:34 +0200 Subject: [PATCH] Fixed path_buffer waiting for a-star to finish --- mg_navigation/src/path_buffer.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mg_navigation/src/path_buffer.cpp b/mg_navigation/src/path_buffer.cpp index 09776a1..41ab424 100644 --- a/mg_navigation/src/path_buffer.cpp +++ b/mg_navigation/src/path_buffer.cpp @@ -2,6 +2,9 @@ #include +#include +using namespace std::chrono_literals; + namespace mg { PathBuffer::PathBuffer(rclcpp::Node* node) : current(-1), node_(node) { @@ -20,7 +23,6 @@ namespace mg { && glm::distance2(pos, IdToCoords(path_msg_->indicies[current])) < lookahead * lookahead) { current++; } - if (current == (int)path_msg_->indicies.size()) { double best = 10000000; int id = 0; @@ -46,7 +48,7 @@ namespace mg { req->y = goal_->y; resp_ = client_->async_send_request(req).share(); } - if (resp_.valid()) { + if (resp_.wait_for(0s) == std::future_status::ready) { path_msg_ = resp_.get(); auto req = std::make_shared();