Skip to content

Commit

Permalink
Add condition in all the hardware component test plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
saikishor committed Dec 10, 2024
1 parent 5ae663e commit 52eae61
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <vector>

#include "hardware_interface/actuator_interface.hpp"
#include "rclcpp/logging.hpp"
#include "ros2_control_test_assets/test_hardware_interface_constants.hpp"

using hardware_interface::ActuatorInterface;
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <vector>

#include "hardware_interface/sensor_interface.hpp"
#include "rclcpp/logging.hpp"

using hardware_interface::return_type;
using hardware_interface::SensorInterface;
Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down

0 comments on commit 52eae61

Please sign in to comment.