From ba147026816f246595bac7b13d3dcd5fc0b6539e Mon Sep 17 00:00:00 2001 From: Kenji Brameld Date: Thu, 30 Nov 2023 02:51:56 +0000 Subject: [PATCH] allow connection retries Signed-off-by: Kenji Brameld --- nao_lola_client/src/connection.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/nao_lola_client/src/connection.cpp b/nao_lola_client/src/connection.cpp index a7ae000..f84f175 100644 --- a/nao_lola_client/src/connection.cpp +++ b/nao_lola_client/src/connection.cpp @@ -21,10 +21,15 @@ Connection::Connection() : io_service(), socket(io_service), logger(rclcpp::get_logger("lola connection")) { boost::system::error_code ec; - socket.connect(ENDPOINT, ec); - if (ec) { - RCLCPP_ERROR(logger, (std::string{"Could not connect to LoLA: "} + ec.message()).c_str()); - } + rclcpp::Clock clock; + do { + socket.connect(ENDPOINT, ec); + if (ec) { + RCLCPP_WARN_SKIPFIRST_THROTTLE( + logger, clock, 1000, + (std::string{"Could not connect to LoLA, retrying: "} + ec.message()).c_str()); + } + } while (ec && rclcpp::ok()); } std::array Connection::receive()