Skip to content

Commit 5ae50d9

Browse files
committed
Support 'Goal Current' control for OpenMANIPULATOR-Y:
- Added new models: xh540_w150 and xc330_t288. - Introduced torque constant parameter in relevant functions.
1 parent ab7956c commit 5ae50d9

File tree

5 files changed

+26
-11
lines changed

5 files changed

+26
-11
lines changed

include/dynamixel_hardware_interface/dynamixel/dynamixel_info.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ class DynamixelInfo
7878
int32_t & value_of_max_radian_position,
7979
int32_t & value_of_min_radian_position,
8080
double & min_radian,
81-
double & max_radian);
81+
double & max_radian,
82+
double & torque_constant);
8283
int32_t ConvertRadianToValue(uint8_t id, double radian);
8384
double ConvertValueToRadian(uint8_t id, int32_t value);
8485
inline int16_t ConvertEffortToCurrent(uint8_t id, double effort)

include/dynamixel_hardware_interface/dynamixel_hardware_interface.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@
4747
#define PRESENT_VELOCITY_INDEX 1
4848
#define PRESENT_EFFORT_INDEX 2
4949

50+
#define GOAL_POSITION_INDEX 0
51+
// #define GOAL_VELOCITY_INDEX 1 // TODO: to be implemented
52+
#define GOAL_CURRENT_INDEX 1
53+
5054
namespace dynamixel_hardware_interface
5155
{
5256

src/dynamixel/dynamixel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ DxlError Dynamixel::GetDxlValueFromSyncRead()
840840
dxl_info_.ConvertValueRPMToVelocityRPS(ID, static_cast<int32_t>(dxl_getdata));
841841
} else if (indirect_info_read_[ID].item_name.at(item_index) == "Present Current") {
842842
*it_read_data.item_data_ptr_vec.at(item_index) =
843-
static_cast<int16_t>(dxl_getdata);
843+
dxl_info_.ConvertCurrentToEffort(ID, static_cast<int16_t>(dxl_getdata));
844844
} else {
845845
*it_read_data.item_data_ptr_vec.at(item_index) =
846846
static_cast<double>(dxl_getdata);
@@ -962,7 +962,7 @@ DxlError Dynamixel::GetDxlValueFromBulkRead()
962962
dxl_info_.ConvertValueRPMToVelocityRPS(ID, static_cast<int32_t>(dxl_getdata));
963963
} else if (indirect_info_read_[ID].item_name.at(item_index) == "Present Current") {
964964
*it_read_data.item_data_ptr_vec.at(item_index) =
965-
static_cast<int16_t>(dxl_getdata);
965+
dxl_info_.ConvertCurrentToEffort(ID, static_cast<int16_t>(dxl_getdata));
966966
} else {
967967
*it_read_data.item_data_ptr_vec.at(item_index) =
968968
static_cast<double>(dxl_getdata);

src/dynamixel/dynamixel_info.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,15 @@ bool DynamixelInfo::GetDxlTypeInfo(
149149
int32_t & value_of_max_radian_position,
150150
int32_t & value_of_min_radian_position,
151151
double & min_radian,
152-
double & max_radian)
152+
double & max_radian,
153+
double & torque_constant)
153154
{
154155
value_of_zero_radian_position = dxl_info_[id].value_of_zero_radian_position;
155156
value_of_max_radian_position = dxl_info_[id].value_of_max_radian_position;
156157
value_of_min_radian_position = dxl_info_[id].value_of_min_radian_position;
157158
min_radian = dxl_info_[id].min_radian;
158159
max_radian = dxl_info_[id].max_radian;
160+
torque_constant = dxl_info_[id].torque_constant;
159161
return true;
160162
}
161163

src/dynamixel_hardware_interface.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -712,13 +712,13 @@ bool DynamixelHardware::InitDxlWriteItems()
712712
if (gpio.command_interfaces.size()) {
713713
uint8_t id = static_cast<uint8_t>(stoi(gpio.parameters.at("ID")));
714714
for (auto it : gpio.command_interfaces) {
715-
HandlerVarType temp_write;
716-
temp_write.id = id;
717-
temp_write.name = gpio.name;
715+
HandlerVarType temp_write;
716+
temp_write.id = id;
717+
temp_write.name = gpio.name;
718718

719719
temp_write.interface_name_vec.push_back(it.name);
720-
temp_write.value_ptr_vec.push_back(std::make_shared<double>(0.0));
721-
hdl_trans_commands_.push_back(temp_write);
720+
temp_write.value_ptr_vec.push_back(std::make_shared<double>(0.0));
721+
hdl_trans_commands_.push_back(temp_write);
722722
}
723723
}
724724
}
@@ -853,14 +853,22 @@ void DynamixelHardware::CalcJointToTransmission()
853853
double value = 0.0;
854854
for (size_t j = 0; j < num_of_joints_; j++) {
855855
value += joint_to_transmission_matrix_[i][j] *
856-
(*hdl_joint_commands_.at(j).value_ptr_vec.at(0));
856+
(*hdl_joint_commands_.at(j).value_ptr_vec.at(GOAL_POSITION_INDEX));
857857
}
858858

859859
if (hdl_trans_commands_.at(i).name == conversion_dxl_name_) {
860860
value = prismaticToRevolute(value);
861861
}
862+
*hdl_trans_commands_.at(i).value_ptr_vec.at(GOAL_POSITION_INDEX) = value;
863+
}
862864

863-
*hdl_trans_commands_.at(i).value_ptr_vec.at(0) = value;
865+
for (size_t i = 0; i < num_of_transmissions_; i++) {
866+
double value = 0.0;
867+
for (size_t j = 0; j < num_of_joints_; j++) {
868+
value += joint_to_transmission_matrix_[i][j] *
869+
(*hdl_joint_commands_.at(j).value_ptr_vec.at(GOAL_CURRENT_INDEX));
870+
}
871+
*hdl_trans_commands_.at(i).value_ptr_vec.at(GOAL_CURRENT_INDEX) = value;
864872
}
865873
}
866874

0 commit comments

Comments
 (0)