Skip to content

Commit 5047880

Browse files
committed
potential fix
1 parent ebfc959 commit 5047880

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

whole_body_controllers/src/ik_controller.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,16 @@ auto IKController::update_system_state_values() -> controller_interface::return_
305305
std::ranges::copy(common::messages::to_vector(pose), system_state_values_.begin() + root.idx_q());
306306
}
307307

308-
for (const auto & [i, joint_name] : std::views::enumerate(manipulator_dofs_)) {
308+
for (const auto & joint_name : manipulator_dofs_) {
309309
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());
312318
}
313319

314320
if (std::ranges::any_of(system_state_values_, [](double x) { return std::isnan(x); })) {

0 commit comments

Comments
 (0)