@@ -297,7 +297,7 @@ auto IKController::update_system_state_values() -> controller_interface::return_
297
297
// the states first, then save them.
298
298
if (params_.use_external_measured_vehicle_states ) {
299
299
const auto * state_msg = vehicle_state_.readFromRT ();
300
- const auto state = common::messages::to_vector (*state_msg);
300
+ const std::vector< double > state = common::messages::to_vector (*state_msg);
301
301
std::ranges::copy (state.begin (), state.begin () + free_flyer_pos_dofs_.size (), position_state_values_.begin ());
302
302
std::ranges::copy (state.begin () + free_flyer_pos_dofs_.size (), state.end (), velocity_state_values_.begin ());
303
303
} else {
@@ -336,21 +336,25 @@ auto IKController::update_system_state_values() -> controller_interface::return_
336
336
337
337
auto find_interface = [](const auto & interfaces, const std::string & name, const std::string & type) {
338
338
return std::ranges::find_if (interfaces, [&name, &type](const auto & interface) {
339
- return interface.get_interface_name () == std::format (" {}/{}" , name, type);
339
+ return interface.get_name () == std::format (" {}/{}" , name, type);
340
340
});
341
341
};
342
342
343
343
// save the manipulator states
344
- for (const auto & [i, joint_name] : std::views::enumerate ( params_.controlled_joints ) ) {
344
+ for (const auto & joint_name : params_.controlled_joints ) {
345
345
const pinocchio::JointModel joint = model_->joints [model_->getJointId (joint_name)];
346
346
347
347
const auto pos_it = find_interface (state_interfaces_, joint_name, hardware_interface::HW_IF_POSITION);
348
- const double pos = pos_it->get_optional ().value_or (std::numeric_limits<double >::quiet_NaN ());
349
- position_state_values_[free_flyer_pos_dofs_.size () + i] = pos;
348
+ if (pos_it != state_interfaces_.end ()) {
349
+ const double pos = pos_it->get_optional ().value_or (std::numeric_limits<double >::quiet_NaN ());
350
+ position_state_values_[joint.idx_q ()] = pos;
351
+ }
350
352
351
353
const auto vel_it = find_interface (state_interfaces_, joint_name, hardware_interface::HW_IF_VELOCITY);
352
- const double vel = vel_it->get_optional ().value_or (std::numeric_limits<double >::quiet_NaN ());
353
- velocity_state_values_[free_flyer_vel_dofs_.size () + i] = vel;
354
+ if (vel_it != state_interfaces_.end ()) {
355
+ const double vel = vel_it->get_optional ().value_or (std::numeric_limits<double >::quiet_NaN ());
356
+ velocity_state_values_[joint.idx_v ()] = vel;
357
+ }
354
358
}
355
359
356
360
if (std::ranges::any_of (position_state_values_, [](double x) { return std::isnan (x); })) {
0 commit comments