From 6858e48188fde3e4478fd30a34297cd11e5c519f Mon Sep 17 00:00:00 2001 From: Mukunda Bharatheesha Date: Tue, 11 Feb 2025 15:18:51 +0100 Subject: [PATCH] Always wait on hardware if hardware is true. --- .../velodyne_hw_interface.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/nebula_hw_interfaces/src/nebula_velodyne_hw_interfaces/velodyne_hw_interface.cpp b/nebula_hw_interfaces/src/nebula_velodyne_hw_interfaces/velodyne_hw_interface.cpp index 1f70ee67..9e28f5e0 100644 --- a/nebula_hw_interfaces/src/nebula_velodyne_hw_interfaces/velodyne_hw_interface.cpp +++ b/nebula_hw_interfaces/src/nebula_velodyne_hw_interfaces/velodyne_hw_interface.cpp @@ -107,16 +107,19 @@ Status VelodyneHwInterface::get_sensor_configuration(SensorConfigurationBase & s VelodyneStatus VelodyneHwInterface::init_http_client() { - try { - http_client_driver_->init_client(sensor_configuration_->sensor_ip, 80); - if (!http_client_driver_->client()->isOpen()) { - http_client_driver_->client()->open(); + while (true) { + try { + http_client_driver_->init_client(sensor_configuration_->sensor_ip, 80); + if (!http_client_driver_->client()->isOpen()) { + http_client_driver_->client()->open(); + } + return Status::OK; + } catch (const std::exception & ex) { + std::cerr << "Error initializing lidar: " << ex.what() << std::endl; + std::cerr << "Retrying after 5 seconds..." << std::endl; + std::this_thread::sleep_for(std::chrono::seconds(5)); } - } catch (const std::exception & ex) { - VelodyneStatus status = Status::HTTP_CONNECTION_ERROR; - return status; } - return Status::OK; } void VelodyneHwInterface::string_callback(const std::string & str)