From 8a82145cc3e6d79b933eaaccab49c310780830f7 Mon Sep 17 00:00:00 2001 From: Sanjeev Kumar Date: Thu, 19 Dec 2024 21:38:14 +0100 Subject: [PATCH] Refactor: Moved TriggerType enum to dedicated file to avoid repetition across classes --- .../hardware_interface/actuator_interface.hpp | 6 +--- .../hardware_interface/system_interface.hpp | 6 +--- .../types/hardware_interface_trigger_type.hpp | 28 +++++++++++++++++++ 3 files changed, 30 insertions(+), 10 deletions(-) create mode 100644 hardware_interface/include/hardware_interface/types/hardware_interface_trigger_type.hpp diff --git a/hardware_interface/include/hardware_interface/actuator_interface.hpp b/hardware_interface/include/hardware_interface/actuator_interface.hpp index 6ca478231f..1f96744f7d 100644 --- a/hardware_interface/include/hardware_interface/actuator_interface.hpp +++ b/hardware_interface/include/hardware_interface/actuator_interface.hpp @@ -26,6 +26,7 @@ #include "hardware_interface/handle.hpp" #include "hardware_interface/hardware_info.hpp" #include "hardware_interface/types/hardware_interface_return_values.hpp" +#include "hardware_interface/types/hardware_interface_trigger_type.hpp" #include "hardware_interface/types/lifecycle_state_names.hpp" #include "lifecycle_msgs/msg/state.hpp" #include "rclcpp/duration.hpp" @@ -546,11 +547,6 @@ class ActuatorInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNod // interface names to Handle accessed through getters/setters std::unordered_map actuator_states_; std::unordered_map actuator_commands_; - enum class TriggerType - { - READ, - WRITE - }; std::atomic next_trigger_ = TriggerType::READ; }; diff --git a/hardware_interface/include/hardware_interface/system_interface.hpp b/hardware_interface/include/hardware_interface/system_interface.hpp index ec649b0225..a8c34e5a06 100644 --- a/hardware_interface/include/hardware_interface/system_interface.hpp +++ b/hardware_interface/include/hardware_interface/system_interface.hpp @@ -26,6 +26,7 @@ #include "hardware_interface/handle.hpp" #include "hardware_interface/hardware_info.hpp" #include "hardware_interface/types/hardware_interface_return_values.hpp" +#include "hardware_interface/types/hardware_interface_trigger_type.hpp" #include "hardware_interface/types/hardware_interface_type_values.hpp" #include "hardware_interface/types/lifecycle_state_names.hpp" #include "lifecycle_msgs/msg/state.hpp" @@ -585,11 +586,6 @@ class SystemInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNodeI // interface names to Handle accessed through getters/setters std::unordered_map system_states_; std::unordered_map system_commands_; - enum class TriggerType - { - READ, - WRITE - }; std::atomic next_trigger_ = TriggerType::READ; }; diff --git a/hardware_interface/include/hardware_interface/types/hardware_interface_trigger_type.hpp b/hardware_interface/include/hardware_interface/types/hardware_interface_trigger_type.hpp new file mode 100644 index 0000000000..fa764d2c28 --- /dev/null +++ b/hardware_interface/include/hardware_interface/types/hardware_interface_trigger_type.hpp @@ -0,0 +1,28 @@ +// Copyright 2017 Open Source Robotics Foundation, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef HARDWARE_INTERFACE__TYPES__HARDWARE_INTERFACE_TRIGGER_TYPE_HPP_ +#define HARDWARE_INTERFACE__TYPES__HARDWARE_INTERFACE_TRIGGER_TYPE_HPP_ + +namespace hardware_interface +{ +enum class TriggerType +{ + READ, + WRITE +}; + +} // namespace hardware_interface + +#endif // HARDWARE_INTERFACE__TYPES__HARDWARE_INTERFACE_TRIGGER_TYPE_HPP_ \ No newline at end of file