File tree Expand file tree Collapse file tree 1 file changed +22
-3
lines changed
joint_state_broadcaster/src Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -414,10 +414,29 @@ controller_interface::return_type JointStateBroadcaster::update(
414
414
for (auto i = 0u ; i < state_interfaces_.size (); ++i)
415
415
{
416
416
// no retries, just try to get the latest value once
417
- const auto & opt = state_interfaces_[i].get_optional (0 );
418
- if (opt.has_value ())
417
+ if (state_interfaces_[i].get_data_type () == hardware_interface::HandleDataType::DOUBLE)
419
418
{
420
- *mapped_values_[i] = opt.value ();
419
+ const auto & opt = state_interfaces_[i].get_optional (0 );
420
+ if (opt.has_value ())
421
+ {
422
+ *mapped_values_[i] = opt.value ();
423
+ }
424
+ }
425
+ else if (state_interfaces_[i].get_data_type () == hardware_interface::HandleDataType::BOOL)
426
+ {
427
+ const auto & opt = state_interfaces_[i].get_optional <bool >(0 );
428
+ if (opt.has_value ())
429
+ {
430
+ *mapped_values_[i] = static_cast <double >(opt.value ());
431
+ }
432
+ }
433
+ else
434
+ {
435
+ RCLCPP_DEBUG (
436
+ get_node ()->get_logger (),
437
+ " Unsupported data type for state interface '%s'. "
438
+ " Only double and bool are supported." ,
439
+ state_interfaces_[i].get_name ().c_str ());
421
440
}
422
441
}
423
442
You can’t perform that action at this time.
0 commit comments