Skip to content

Commit 013ee93

Browse files
committed
feat: Enhance Dynamixel interface with communication ID handling and virtual DXL support
- Added `comm_id` to `HandlerVarType` for better communication management. - Updated methods to utilize `comm_id` for reading and writing operations. - Introduced handling for virtual DXL components in GPIO initialization and state management. - Improved error handling and logging for GPIO parameter checks. - Updated model files to include new virtual DXL models.
1 parent ba695c9 commit 013ee93

File tree

12 files changed

+5717
-1780
lines changed

12 files changed

+5717
-1780
lines changed

include/dynamixel_hardware_interface/dynamixel/dynamixel.hpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ typedef struct
102102
*/
103103
typedef struct
104104
{
105-
uint8_t id; ///< ID of the Dynamixel motor.
105+
uint8_t comm_id; ///< ID of the Dynamixel to be communicated.
106+
std::vector<uint8_t> id_arr; ///< ID of the Dynamixel motor.
106107
std::vector<std::string> item_name; ///< List of control item names.
107108
std::vector<uint8_t> item_size; ///< Sizes of the control items.
108109
std::vector<uint16_t> item_addr; ///< Addresses of the control items.
@@ -159,6 +160,8 @@ class Dynamixel
159160
// direct inform for bulk write
160161
std::map<uint8_t /*id*/, IndirectInfo> direct_info_write_;
161162

163+
std::map<uint8_t /*id*/, uint8_t> comm_id_;
164+
162165
public:
163166
explicit Dynamixel(const char * path);
164167
~Dynamixel();
@@ -170,13 +173,13 @@ class Dynamixel
170173

171174
// DXL Read Setting
172175
DxlError SetDxlReadItems(
173-
uint8_t id, std::vector<std::string> item_names,
176+
uint8_t id, uint8_t comm_id, std::vector<std::string> item_names,
174177
std::vector<std::shared_ptr<double>> data_vec_ptr);
175178
DxlError SetMultiDxlRead();
176179

177180
// DXL Write Setting
178181
DxlError SetDxlWriteItems(
179-
uint8_t id, std::vector<std::string> item_names,
182+
uint8_t id, uint8_t comm_id, std::vector<std::string> item_names,
180183
std::vector<std::shared_ptr<double>> data_vec_ptr);
181184
DxlError SetMultiDxlWrite();
182185

@@ -186,7 +189,7 @@ class Dynamixel
186189
DxlError WriteMultiDxlData();
187190

188191
// Set Dxl Option
189-
DxlError SetOperatingMode(uint8_t id, uint8_t dynamixel_mode);
192+
// DxlError SetOperatingMode(uint8_t id, uint8_t dynamixel_mode);
190193
DxlError DynamixelEnable(std::vector<uint8_t> id_arr);
191194
DxlError DynamixelDisable(std::vector<uint8_t> id_arr);
192195

@@ -208,6 +211,10 @@ class Dynamixel
208211

209212
static std::string DxlErrorToString(DxlError error_num);
210213

214+
DxlError ReadDxlModelFile(uint8_t id, uint16_t model_num);
215+
216+
void SetCommId(uint8_t id, uint8_t comm_id) {comm_id_[id] = comm_id;}
217+
211218
private:
212219
bool checkReadType();
213220
bool checkWriteType();
@@ -240,8 +247,9 @@ class Dynamixel
240247

241248
// Read - Data Processing
242249
DxlError ProcessReadData(
243-
uint8_t id,
250+
uint8_t comm_id,
244251
uint16_t indirect_addr,
252+
const std::vector<uint8_t> & id_arr,
245253
const std::vector<std::string> & item_names,
246254
const std::vector<uint8_t> & item_sizes,
247255
const std::vector<std::shared_ptr<double>> & data_ptrs,

include/dynamixel_hardware_interface/dynamixel_hardware_interface.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ constexpr char HW_IF_TORQUE_ENABLE[] = "torque_enable";
6262
typedef struct HandlerVarType_
6363
{
6464
uint8_t id; /**< ID of the Dynamixel component. */
65+
uint8_t comm_id; /**< ID of the Dynamixel to be communicated. */
6566
std::string name; /**< Name of the component. */
6667
std::vector<std::string> interface_name_vec; /**< Vector of interface names. */
6768
std::vector<std::shared_ptr<double>> value_ptr_vec; /**< Vector interface values. */
@@ -227,6 +228,7 @@ class DynamixelHardware : public
227228
std::string port_name_;
228229
std::string baud_rate_;
229230
std::vector<uint8_t> dxl_id_;
231+
std::vector<uint8_t> virtual_dxl_id_;
230232

231233
std::vector<uint8_t> sensor_id_;
232234
std::map<uint8_t /*id*/, std::string /*interface_name*/> sensor_item_;
@@ -270,7 +272,7 @@ class DynamixelHardware : public
270272
* @param value The value to write.
271273
* @return True if write was successful, false if timeout occurred.
272274
*/
273-
bool retryWriteItem(uint8_t id, const std::string & item_name, uint32_t value);
275+
// bool retryWriteItem(uint8_t id, const std::string & item_name, uint32_t value);
274276

275277
/**
276278
* @brief Initializes Dynamixel items.

param/dxl_model/dynamixel.model

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,9 @@ Number Name
4949
536 sensorxel_joy.model
5050
600 sensorxel_joy.model
5151
602 ffw_g10_rcu.model
52+
620 ffw_sg2_steer_1.model
53+
621 ffw_sg2_steer_2.model
54+
622 ffw_sg2_steer_3.model
55+
623 ffw_sg2_drive_1.model
56+
624 ffw_sg2_drive_2.model
57+
625 ffw_sg2_drive_3.model

0 commit comments

Comments
 (0)