From f3fadb63b662b63d19f5d3cafe7b474b5eb68540 Mon Sep 17 00:00:00 2001 From: Sai Kishor Kothakota Date: Fri, 14 Feb 2025 17:45:20 +0100 Subject: [PATCH] fix introspection for handles with variable references --- .../include/hardware_interface/handle.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hardware_interface/include/hardware_interface/handle.hpp b/hardware_interface/include/hardware_interface/handle.hpp index ddb9dbd99c..ccb4e29f17 100644 --- a/hardware_interface/include/hardware_interface/handle.hpp +++ b/hardware_interface/include/hardware_interface/handle.hpp @@ -206,17 +206,17 @@ class StateInterface : public Handle void registerIntrospection() const { - if (std::holds_alternative(value_)) + if (value_ptr_ || std::holds_alternative(value_)) { std::function f = [this]() - { return value_ptr_ ? *value_ptr_ : std::numeric_limits::quiet_NaN(); }; + { return value_ptr_ ? *value_ptr_ : std::get(value_); }; DEFAULT_REGISTER_ROS2_CONTROL_INTROSPECTION("state_interface." + get_name(), f); } } void unregisterIntrospection() const { - if (std::holds_alternative(value_)) + if (value_ptr_ || std::holds_alternative(value_)) { DEFAULT_UNREGISTER_ROS2_CONTROL_INTROSPECTION("state_interface." + get_name()); } @@ -251,17 +251,17 @@ class CommandInterface : public Handle void registerIntrospection() const { - if (std::holds_alternative(value_)) + if (value_ptr_ || std::holds_alternative(value_)) { std::function f = [this]() - { return value_ptr_ ? *value_ptr_ : std::numeric_limits::quiet_NaN(); }; + { return value_ptr_ ? *value_ptr_ : std::get(value_); }; DEFAULT_REGISTER_ROS2_CONTROL_INTROSPECTION("command_interface." + get_name(), f); } } void unregisterIntrospection() const { - if (std::holds_alternative(value_)) + if (value_ptr_ || std::holds_alternative(value_)) { DEFAULT_UNREGISTER_ROS2_CONTROL_INTROSPECTION("command_interface." + get_name()); }