Skip to content

Commit

Permalink
fixed increment
Browse files Browse the repository at this point in the history
  • Loading branch information
mhubii committed Nov 20, 2024
1 parent 7afb59f commit 8639214
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,13 @@ LBRJointPositionCommandController::update(const rclcpp::Time & /*time*/,
if (!lbr_joint_position_command || !(*lbr_joint_position_command)) {
return controller_interface::return_type::OK;
}
std::for_each(command_interfaces_.begin(), command_interfaces_.end(),
[lbr_joint_position_command, idx = 0](auto &command_interface) mutable {
command_interface.set_value((*lbr_joint_position_command)->joint_position[++idx]);
});
std::for_each(
command_interfaces_.begin(), command_interfaces_.end(),
[lbr_joint_position_command, idx = 0](auto &command_interface) mutable {
command_interface.set_value(
(*lbr_joint_position_command)
->joint_position[idx++]); // important to post-increment idx, don't use ++idx
});
return controller_interface::return_type::OK;
}

Expand Down

0 comments on commit 8639214

Please sign in to comment.