File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
whole_body_controllers/src Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -305,10 +305,16 @@ auto IKController::update_system_state_values() -> controller_interface::return_
305
305
std::ranges::copy (common::messages::to_vector (pose), system_state_values_.begin () + root.idx_q ());
306
306
}
307
307
308
- for (const auto & [i, joint_name] : std::views::enumerate ( manipulator_dofs_) ) {
308
+ for (const auto & joint_name : manipulator_dofs_) {
309
309
const pinocchio::JointModel joint = model_->joints [model_->getJointId (joint_name)];
310
- const auto out = state_interfaces_[i].get_optional ();
311
- system_state_values_[joint.idx_q ()] = out.value_or (std::numeric_limits<double >::quiet_NaN ());
310
+ auto it = std::ranges::find_if (
311
+ state_interfaces_, [joint_name](const auto & interface) { return interface.get_prefix_name () == joint_name; });
312
+
313
+ if (it == state_interfaces_.end ()) {
314
+ RCLCPP_ERROR (logger_, " Could not find joint {} in state interfaces" , joint_name); // NOLINT
315
+ return controller_interface::return_type::ERROR;
316
+ }
317
+ system_state_values_[joint.idx_q ()] = it->get_optional ().value_or (std::numeric_limits<double >::quiet_NaN ());
312
318
}
313
319
314
320
if (std::ranges::any_of (system_state_values_, [](double x) { return std::isnan (x); })) {
You can’t perform that action at this time.
0 commit comments