Skip to content

Commit 3d8e13a

Browse files
committed
refactor: streamline state calculation logic in Dynamixel hardware interface
1 parent c84b88e commit 3d8e13a

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed

src/dynamixel_hardware_interface.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -944,31 +944,25 @@ void DynamixelHardware::SetMatrix()
944944
}
945945
void DynamixelHardware::CalcTransmissionToJoint()
946946
{
947-
// Define the indices and their corresponding state types
948947
const std::array<size_t, 3> indices = {
949948
PRESENT_POSITION_INDEX,
950949
PRESENT_VELOCITY_INDEX,
951950
PRESENT_EFFORT_INDEX
952951
};
953952

954-
// Process each joint
955953
for (size_t i = 0; i < num_of_joints_; i++) {
956-
// Process each state type (position, velocity, effort)
957954
for (size_t state_idx : indices) {
958955
double value = 0.0;
959-
// Calculate value using transmission matrix
960956
for (size_t j = 0; j < num_of_transmissions_; j++) {
961957
value += transmission_to_joint_matrix_[i][j] *
962958
(*hdl_trans_states_.at(j).value_ptr_vec.at(state_idx));
963959
}
964960

965-
// Apply conversion if needed (only for position)
966961
if (state_idx == PRESENT_POSITION_INDEX &&
967962
hdl_joint_states_.at(i).name == conversion_joint_name_) {
968963
value = revoluteToPrismatic(value);
969964
}
970965

971-
// Store the calculated value
972966
*hdl_joint_states_.at(i).value_ptr_vec.at(state_idx) = value;
973967
}
974968
}
@@ -978,16 +972,10 @@ void DynamixelHardware::CalcJointToTransmission()
978972
{
979973
for (size_t i = 0; i < num_of_transmissions_; i++) {
980974
double value = 0.0;
981-
bool temp_flag = false;
982975
for (size_t j = 0; j < num_of_joints_; j++) {
983976
for(size_t k = 0; k < hdl_joint_commands_.at(j).interface_name_vec.size(); k++) {
984977
value += joint_to_transmission_matrix_[i][j] *
985978
(*hdl_joint_commands_.at(j).value_ptr_vec.at(k));
986-
if(hdl_joint_commands_.at(j).name == "l_rh_r1_joint") {
987-
if(joint_to_transmission_matrix_[i][j] == 1.0) {
988-
temp_flag = true;
989-
}
990-
}
991979
}
992980
}
993981

@@ -996,9 +984,7 @@ void DynamixelHardware::CalcJointToTransmission()
996984
hdl_trans_commands_.at(i).name == conversion_dxl_name_) {
997985
value = prismaticToRevolute(value);
998986
}
999-
if(hdl_trans_commands_.at(i).name == "dxl38") {
1000-
RCLCPP_INFO_STREAM(logger_, "hdl_trans_commands_.at(i).name: " << hdl_trans_commands_.at(i).name << ", cmd_idx: " << k << ", value: " << value);
1001-
}
987+
1002988
*hdl_trans_commands_.at(i).value_ptr_vec.at(k) = value;
1003989
}
1004990
}

0 commit comments

Comments
 (0)