Skip to content

Commit 13cbd0a

Browse files
committed
Refactor transmission command calculation to conditionally handle 'Goal Current' interface. Ensured proper checks for interface names before accumulating values for transmission commands.
1 parent b675c80 commit 13cbd0a

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/dynamixel_hardware_interface.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -869,12 +869,18 @@ void DynamixelHardware::CalcJointToTransmission()
869869
}
870870

871871
for (size_t i = 0; i < num_of_transmissions_; i++) {
872-
double value = 0.0;
873-
for (size_t j = 0; j < num_of_joints_; j++) {
874-
value += joint_to_transmission_matrix_[i][j] *
875-
(*hdl_joint_commands_.at(j).value_ptr_vec.at(GOAL_CURRENT_INDEX));
872+
if(hdl_trans_commands_.at(i).interface_name_vec.size() > GOAL_CURRENT_INDEX && hdl_trans_commands_.at(i).interface_name_vec.at(GOAL_CURRENT_INDEX) == "Goal Current")
873+
{
874+
double value = 0.0;
875+
for (size_t j = 0; j < num_of_joints_; j++) {
876+
if(hdl_joint_commands_.at(j).interface_name_vec.size() > GOAL_CURRENT_INDEX && hdl_joint_commands_.at(j).interface_name_vec.at(GOAL_CURRENT_INDEX) == hardware_interface::HW_IF_EFFORT)
877+
{
878+
value += joint_to_transmission_matrix_[i][j] *
879+
(*hdl_joint_commands_.at(j).value_ptr_vec.at(GOAL_CURRENT_INDEX));
880+
}
881+
}
882+
*hdl_trans_commands_.at(i).value_ptr_vec.at(GOAL_CURRENT_INDEX) = value;
876883
}
877-
*hdl_trans_commands_.at(i).value_ptr_vec.at(GOAL_CURRENT_INDEX) = value;
878884
}
879885
}
880886

0 commit comments

Comments
 (0)