Skip to content

Commit 9394fd2

Browse files
authored
Fix introspection for handles with variable references (#2050)
1 parent a9aca64 commit 9394fd2

File tree

1 file changed

+6
-6
lines changed
  • hardware_interface/include/hardware_interface

1 file changed

+6
-6
lines changed

Diff for: hardware_interface/include/hardware_interface/handle.hpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -257,17 +257,17 @@ class StateInterface : public Handle
257257

258258
void registerIntrospection() const
259259
{
260-
if (std::holds_alternative<double>(value_))
260+
if (value_ptr_ || std::holds_alternative<double>(value_))
261261
{
262262
std::function<double()> f = [this]()
263-
{ return value_ptr_ ? *value_ptr_ : std::numeric_limits<double>::quiet_NaN(); };
263+
{ return value_ptr_ ? *value_ptr_ : std::get<double>(value_); };
264264
DEFAULT_REGISTER_ROS2_CONTROL_INTROSPECTION("state_interface." + get_name(), f);
265265
}
266266
}
267267

268268
void unregisterIntrospection() const
269269
{
270-
if (std::holds_alternative<double>(value_))
270+
if (value_ptr_ || std::holds_alternative<double>(value_))
271271
{
272272
DEFAULT_UNREGISTER_ROS2_CONTROL_INTROSPECTION("state_interface." + get_name());
273273
}
@@ -302,17 +302,17 @@ class CommandInterface : public Handle
302302

303303
void registerIntrospection() const
304304
{
305-
if (std::holds_alternative<double>(value_))
305+
if (value_ptr_ || std::holds_alternative<double>(value_))
306306
{
307307
std::function<double()> f = [this]()
308-
{ return value_ptr_ ? *value_ptr_ : std::numeric_limits<double>::quiet_NaN(); };
308+
{ return value_ptr_ ? *value_ptr_ : std::get<double>(value_); };
309309
DEFAULT_REGISTER_ROS2_CONTROL_INTROSPECTION("command_interface." + get_name(), f);
310310
}
311311
}
312312

313313
void unregisterIntrospection() const
314314
{
315-
if (std::holds_alternative<double>(value_))
315+
if (value_ptr_ || std::holds_alternative<double>(value_))
316316
{
317317
DEFAULT_UNREGISTER_ROS2_CONTROL_INTROSPECTION("command_interface." + get_name());
318318
}

0 commit comments

Comments
 (0)