From b9418f4eb210db3bd6158c28dbbae5d7ec6657de 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 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/nao_lola_client/src/connection.cpp b/nao_lola_client/src/connection.cpp index a7ae000..a18d1f1 100644 --- a/nao_lola_client/src/connection.cpp +++ b/nao_lola_client/src/connection.cpp @@ -21,10 +21,14 @@ 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()