diff --git a/hardware_interface/include/hardware_interface/actuator_interface.hpp b/hardware_interface/include/hardware_interface/actuator_interface.hpp index 4bd788603c..9ffa7bc436 100644 --- a/hardware_interface/include/hardware_interface/actuator_interface.hpp +++ b/hardware_interface/include/hardware_interface/actuator_interface.hpp @@ -310,6 +310,36 @@ class ActuatorInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNod return actuator_commands_.at(interface_name)->get_value(); } + void set_warning_code(const std::string & interface_name, const double & warning_code) + { + actuator_states_.at(interface_name)->warning_code(warning_code); + } + + double get_warning_code(const std::string & interface_name) const + { + return actuator_states_.at(interface_name)->warning_code(); + } + + void set_error_code(const std::string & interface_name, const double & error_code) + { + actuator_states_.at(interface_name)->error_code(error_code); + } + + double get_error_code(const std::string & interface_name) const + { + return actuator_states_.at(interface_name)->error_code(); + } + + void set_report_message(const std::string & interface_name, const double & report_message) + { + actuator_states_.at(interface_name)->report_message(report_message); + } + + double get_report_message(const std::string & interface_name) const + { + return actuator_states_.at(interface_name)->report_message(); + } + protected: HardwareInfo info_; std::map joint_state_interfaces_; diff --git a/hardware_interface/include/hardware_interface/handle.hpp b/hardware_interface/include/hardware_interface/handle.hpp index a91e51f973..c4718feb75 100644 --- a/hardware_interface/include/hardware_interface/handle.hpp +++ b/hardware_interface/include/hardware_interface/handle.hpp @@ -132,6 +132,39 @@ class StateInterface : public Handle StateInterface(StateInterface && other) = default; + double warning_code() const + { + const double * warning_code = std::get_if(&value_); + // This means the value does not store the expected datatype. How should we handle this + // properly? + THROW_ON_NOT_NULLPTR(warning_code); + return *warning_code; + } + + void warning_code(const double & warning_code) { value_ = warning_code; } + + double error_code() const + { + const auto error_code = std::get_if(&value_); + // This means the value does not store the expected datatype. How should we handle this + // properly? + THROW_ON_NOT_NULLPTR(error_code); + return *error_code; + } + + void error_code(const double & error_code) { value_ = error_code; } + + double report_message() const + { + const auto report_message = std::get_if(&value_); + // This means the value does not store the expected datatype. How should we handle this + // properly? + THROW_ON_NOT_NULLPTR(report_message); + return *report_message; + } + + void report_message(const double & report_message) { value_ = report_message; } + using Handle::Handle; }; diff --git a/hardware_interface/include/hardware_interface/loaned_state_interface.hpp b/hardware_interface/include/hardware_interface/loaned_state_interface.hpp index 4fe67d1290..8498541880 100644 --- a/hardware_interface/include/hardware_interface/loaned_state_interface.hpp +++ b/hardware_interface/include/hardware_interface/loaned_state_interface.hpp @@ -65,6 +65,12 @@ class LoanedStateInterface double get_value() const { return state_interface_.get_value(); } + double get_warning_code() const { return state_interface_.warning_code(); } + + double get_error_code() const { return state_interface_.error_code(); } + + double get_report_message() const { return state_interface_.report_message(); } + protected: StateInterface & state_interface_; Deleter deleter_; diff --git a/hardware_interface/include/hardware_interface/sensor_interface.hpp b/hardware_interface/include/hardware_interface/sensor_interface.hpp index 040b459ffe..119c0d3378 100644 --- a/hardware_interface/include/hardware_interface/sensor_interface.hpp +++ b/hardware_interface/include/hardware_interface/sensor_interface.hpp @@ -200,6 +200,36 @@ class SensorInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNodeI return sensor_states_.at(interface_name)->get_value(); } + void set_warning_code(const std::string & interface_name, const double & warning_code) + { + sensor_states_.at(interface_name)->warning_code(warning_code); + } + + double get_warning_code(const std::string & interface_name) const + { + return sensor_states_.at(interface_name)->warning_code(); + } + + void set_error_code(const std::string & interface_name, const double & error_code) + { + sensor_states_.at(interface_name)->error_code(error_code); + } + + double get_error_code(const std::string & interface_name) const + { + return sensor_states_.at(interface_name)->error_code(); + } + + void set_report_message(const std::string & interface_name, const double & report_message) + { + sensor_states_.at(interface_name)->report_message(report_message); + } + + double get_report_message(const std::string & interface_name) const + { + return sensor_states_.at(interface_name)->report_message(); + } + protected: HardwareInfo info_; diff --git a/hardware_interface/include/hardware_interface/system_interface.hpp b/hardware_interface/include/hardware_interface/system_interface.hpp index c152f16bf7..f998b7253a 100644 --- a/hardware_interface/include/hardware_interface/system_interface.hpp +++ b/hardware_interface/include/hardware_interface/system_interface.hpp @@ -348,6 +348,36 @@ class SystemInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNodeI return system_commands_.at(interface_name)->get_value(); } + void set_warning_code(const std::string & interface_name, const double & warning_code) + { + system_states_.at(interface_name)->warning_code(warning_code); + } + + double get_warning_code(const std::string & interface_name) const + { + return system_states_.at(interface_name)->warning_code(); + } + + void set_error_code(const std::string & interface_name, const double & error_code) + { + system_states_.at(interface_name)->error_code(error_code); + } + + double get_error_code(const std::string & interface_name) const + { + return system_states_.at(interface_name)->error_code(); + } + + void set_report_message(const std::string & interface_name, const double & report_message) + { + system_states_.at(interface_name)->report_message(report_message); + } + + double get_report_message(const std::string & interface_name) const + { + return system_states_.at(interface_name)->report_message(); + } + protected: HardwareInfo info_; std::map joint_state_interfaces_; diff --git a/hardware_interface/include/hardware_interface/types/hardware_interface_error_codes.hpp b/hardware_interface/include/hardware_interface/types/hardware_interface_error_codes.hpp new file mode 100644 index 0000000000..77fc1aa713 --- /dev/null +++ b/hardware_interface/include/hardware_interface/types/hardware_interface_error_codes.hpp @@ -0,0 +1,60 @@ +// 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_ERROR_CODES_HPP_ +#define HARDWARE_INTERFACE__TYPES__HARDWARE_INTERFACE_ERROR_CODES_HPP_ + +#include + +namespace hardware_interface +{ +enum class error_code : std::uint8_t +{ + ERROR_CODE_0 = 0, + ERROR_CODE_1 = 1, + ERROR_CODE_2 = 2, + ERROR_CODE_3 = 3, + ERROR_CODE_4 = 4, + ERROR_CODE_5 = 5, + ERROR_CODE_6 = 6, + ERROR_CODE_7 = 7, + ERROR_CODE_8 = 8, + ERROR_CODE_9 = 9, + ERROR_CODE_10 = 10, + ERROR_CODE_11 = 11, + ERROR_CODE_12 = 12, + ERROR_CODE_13 = 13, + ERROR_CODE_14 = 14, + ERROR_CODE_15 = 15, + ERROR_CODE_16 = 16, + ERROR_CODE_17 = 17, + ERROR_CODE_18 = 18, + ERROR_CODE_19 = 19, + ERROR_CODE_20 = 20, + ERROR_CODE_21 = 21, + ERROR_CODE_22 = 22, + ERROR_CODE_23 = 23, + ERROR_CODE_24 = 24, + ERROR_CODE_25 = 25, + ERROR_CODE_26 = 26, + ERROR_CODE_27 = 27, + ERROR_CODE_28 = 28, + ERROR_CODE_29 = 29, + ERROR_CODE_30 = 30, + ERROR_CODE_31 = 31, +}; + +} // namespace hardware_interface + +#endif // HARDWARE_INTERFACE__TYPES__HARDWARE_INTERFACE_ERROR_CODES_HPP_ diff --git a/hardware_interface/include/hardware_interface/types/hardware_interface_warning_codes.hpp b/hardware_interface/include/hardware_interface/types/hardware_interface_warning_codes.hpp new file mode 100644 index 0000000000..8fef45531d --- /dev/null +++ b/hardware_interface/include/hardware_interface/types/hardware_interface_warning_codes.hpp @@ -0,0 +1,60 @@ +// 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_WARNING_CODES_HPP_ +#define HARDWARE_INTERFACE__TYPES__HARDWARE_INTERFACE_WARNING_CODES_HPP_ + +#include + +namespace hardware_interface +{ +enum class warning_code : std::int8_t +{ + WARNING_CODE_0 = 0, + WARNING_CODE_1 = 1, + WARNING_CODE_2 = 2, + WARNING_CODE_3 = 3, + WARNING_CODE_4 = 4, + WARNING_CODE_5 = 5, + WARNING_CODE_6 = 6, + WARNING_CODE_7 = 7, + WARNING_CODE_8 = 8, + WARNING_CODE_9 = 9, + WARNING_CODE_10 = 10, + WARNING_CODE_11 = 11, + WARNING_CODE_12 = 12, + WARNING_CODE_13 = 13, + WARNING_CODE_14 = 14, + WARNING_CODE_15 = 15, + WARNING_CODE_16 = 16, + WARNING_CODE_17 = 17, + WARNING_CODE_18 = 18, + WARNING_CODE_19 = 19, + WARNING_CODE_20 = 20, + WARNING_CODE_21 = 21, + WARNING_CODE_22 = 22, + WARNING_CODE_23 = 23, + WARNING_CODE_24 = 24, + WARNING_CODE_25 = 25, + WARNING_CODE_26 = 26, + WARNING_CODE_27 = 27, + WARNING_CODE_28 = 28, + WARNING_CODE_29 = 29, + WARNING_CODE_30 = 30, + WARNING_CODE_31 = 31, +}; + +} // namespace hardware_interface + +#endif // HARDWARE_INTERFACE__TYPES__HARDWARE_INTERFACE_WARNING_CODES_HPP_