From 52eae6158cefaa5488f9bc3ef2eac3aa2e5d6f20 Mon Sep 17 00:00:00 2001 From: Sai Kishor Kothakota Date: Tue, 10 Dec 2024 23:23:30 +0100 Subject: [PATCH] Add condition in all the hardware component test plugins --- .../test/test_components/test_actuator.cpp | 9 +++++++++ .../test/test_components/test_sensor.cpp | 9 +++++++++ .../test/test_components/test_system.cpp | 9 +++++++++ 3 files changed, 27 insertions(+) diff --git a/hardware_interface_testing/test/test_components/test_actuator.cpp b/hardware_interface_testing/test/test_components/test_actuator.cpp index 86debc1f4d..630cb9f27c 100644 --- a/hardware_interface_testing/test/test_components/test_actuator.cpp +++ b/hardware_interface_testing/test/test_components/test_actuator.cpp @@ -15,6 +15,7 @@ #include #include "hardware_interface/actuator_interface.hpp" +#include "rclcpp/logging.hpp" #include "ros2_control_test_assets/test_hardware_interface_constants.hpp" using hardware_interface::ActuatorInterface; @@ -35,6 +36,14 @@ class TestActuator : public ActuatorInterface { return CallbackReturn::ERROR; } + if (get_hardware_info().rw_rate == 0u) + { + RCLCPP_WARN( + get_logger(), + "Actuator hardware component '%s' from plugin '%s' failed to initialize as rw_rate is 0.", + get_hardware_info().name.c_str(), get_hardware_info().hardware_plugin_name.c_str()); + return CallbackReturn::ERROR; + } /* * a hardware can optional prove for incorrect info here. diff --git a/hardware_interface_testing/test/test_components/test_sensor.cpp b/hardware_interface_testing/test/test_components/test_sensor.cpp index 16692f55d9..40f27530c0 100644 --- a/hardware_interface_testing/test/test_components/test_sensor.cpp +++ b/hardware_interface_testing/test/test_components/test_sensor.cpp @@ -15,6 +15,7 @@ #include #include "hardware_interface/sensor_interface.hpp" +#include "rclcpp/logging.hpp" using hardware_interface::return_type; using hardware_interface::SensorInterface; @@ -33,6 +34,14 @@ class TestSensor : public SensorInterface { return CallbackReturn::ERROR; } + if (get_hardware_info().rw_rate == 0u) + { + RCLCPP_WARN( + get_logger(), + "Sensor hardware component '%s' from plugin '%s' failed to initialize as rw_rate is 0.", + get_hardware_info().name.c_str(), get_hardware_info().hardware_plugin_name.c_str()); + return CallbackReturn::ERROR; + } return CallbackReturn::SUCCESS; } diff --git a/hardware_interface_testing/test/test_components/test_system.cpp b/hardware_interface_testing/test/test_components/test_system.cpp index 795787eb9e..395935e314 100644 --- a/hardware_interface_testing/test/test_components/test_system.cpp +++ b/hardware_interface_testing/test/test_components/test_system.cpp @@ -17,6 +17,7 @@ #include "hardware_interface/system_interface.hpp" #include "hardware_interface/types/hardware_interface_type_values.hpp" +#include "rclcpp/logging.hpp" #include "ros2_control_test_assets/test_hardware_interface_constants.hpp" using hardware_interface::CommandInterface; @@ -39,6 +40,14 @@ class TestSystem : public SystemInterface return CallbackReturn::ERROR; } + if (get_hardware_info().rw_rate == 0u) + { + RCLCPP_WARN( + get_logger(), + "System hardware component '%s' from plugin '%s' failed to initialize as rw_rate is 0.", + get_hardware_info().name.c_str(), get_hardware_info().hardware_plugin_name.c_str()); + return CallbackReturn::ERROR; + } return CallbackReturn::SUCCESS; }