File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
joint_state_broadcaster/src Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -201,6 +201,29 @@ controller_interface::CallbackReturn JointStateBroadcaster::on_activate(
201201 return CallbackReturn::ERROR;
202202 }
203203
204+ // Erase the interfaces that are not castable to double
205+ std::vector<hardware_interface::LoanedStateInterface> state_interfaces_to_keep;
206+ std::for_each (
207+ state_interfaces_.begin (), state_interfaces_.end (),
208+ [&state_interfaces_to_keep](hardware_interface::LoanedStateInterface & si)
209+ {
210+ if (si.is_castable_to_double ())
211+ {
212+ state_interfaces_to_keep.push_back (std::move (si));
213+ }
214+ else
215+ {
216+ RCLCPP_ERROR (
217+ rclcpp::get_logger (" JointStateBroadcaster" ),
218+ " State interface '%s' is not castable to double. "
219+ " It will not be used in JointStateBroadcaster." ,
220+ si.get_name ().c_str ());
221+ }
222+ });
223+
224+ state_interfaces_.clear ();
225+ state_interfaces_ = std::move (state_interfaces_to_keep);
226+
204227 init_auxiliary_data ();
205228 init_joint_state_msg ();
206229 init_dynamic_joint_state_msg ();
You can’t perform that action at this time.
0 commit comments