Skip to content

Commit 4be96ec

Browse files
authored
Merge pull request #47 from ROBOTIS-GIT/feature-rcu
Add virtual_dxl feaure
2 parents 69527f7 + 1d790f7 commit 4be96ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+6197
-353
lines changed

CHANGELOG.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
Changelog for package dynamixel_hardware_interface
33
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
44

5+
1.4.7 (2025-06-19)
6+
------------------
7+
* Added virtual_dxl and support for rcu
8+
* Contributors: Woojin Wie
9+
510
1.4.6 (2025-05-30)
611
------------------
712
* Changed dynamixel_sdk_TARGETS to dynamixel_sdk_LIBRARIES in target_link_libraries

include/dynamixel_hardware_interface/dynamixel/dynamixel.hpp

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ namespace dynamixel_hardware_interface
4545
#define SYNC 0 ///< Synchronous communication.
4646
#define BULK 1 ///< Bulk communication.
4747

48+
/// @brief Maximum number of retries for communication operations
49+
#define MAX_COMM_RETRIES 5 ///< Maximum number of retries for communication operations
50+
4851
/// @brief Error codes for Dynamixel operations.
4952
enum DxlError
5053
{
@@ -99,7 +102,8 @@ typedef struct
99102
*/
100103
typedef struct
101104
{
102-
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; ///< IDs of the Dynamixel motors.
103107
std::vector<std::string> item_name; ///< List of control item names.
104108
std::vector<uint8_t> item_size; ///< Sizes of the control items.
105109
std::vector<uint16_t> item_addr; ///< Addresses of the control items.
@@ -156,6 +160,8 @@ class Dynamixel
156160
// direct inform for bulk write
157161
std::map<uint8_t /*id*/, IndirectInfo> direct_info_write_;
158162

163+
std::map<uint8_t /*id*/, uint8_t> comm_id_;
164+
159165
public:
160166
explicit Dynamixel(const char * path);
161167
~Dynamixel();
@@ -167,13 +173,13 @@ class Dynamixel
167173

168174
// DXL Read Setting
169175
DxlError SetDxlReadItems(
170-
uint8_t id, std::vector<std::string> item_names,
176+
uint8_t id, uint8_t comm_id, std::vector<std::string> item_names,
171177
std::vector<std::shared_ptr<double>> data_vec_ptr);
172178
DxlError SetMultiDxlRead();
173179

174180
// DXL Write Setting
175181
DxlError SetDxlWriteItems(
176-
uint8_t id, std::vector<std::string> item_names,
182+
uint8_t id, uint8_t comm_id, std::vector<std::string> item_names,
177183
std::vector<std::shared_ptr<double>> data_vec_ptr);
178184
DxlError SetMultiDxlWrite();
179185

@@ -183,7 +189,7 @@ class Dynamixel
183189
DxlError WriteMultiDxlData();
184190

185191
// Set Dxl Option
186-
DxlError SetOperatingMode(uint8_t id, uint8_t dynamixel_mode);
192+
// DxlError SetOperatingMode(uint8_t id, uint8_t dynamixel_mode);
187193
DxlError DynamixelEnable(std::vector<uint8_t> id_arr);
188194
DxlError DynamixelDisable(std::vector<uint8_t> id_arr);
189195

@@ -205,6 +211,12 @@ class Dynamixel
205211

206212
static std::string DxlErrorToString(DxlError error_num);
207213

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+
218+
DxlError InitTorqueStates(std::vector<uint8_t> id_arr, bool disable_torque = false);
219+
208220
private:
209221
bool checkReadType();
210222
bool checkWriteType();
@@ -237,8 +249,9 @@ class Dynamixel
237249

238250
// Read - Data Processing
239251
DxlError ProcessReadData(
240-
uint8_t id,
252+
uint8_t comm_id,
241253
uint16_t indirect_addr,
254+
const std::vector<uint8_t> & id_arr,
242255
const std::vector<std::string> & item_names,
243256
const std::vector<uint8_t> & item_sizes,
244257
const std::vector<std::shared_ptr<double>> & data_ptrs,

include/dynamixel_hardware_interface/dynamixel/dynamixel_info.hpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ typedef struct
4747
int32_t value_of_max_radian_position;
4848
int32_t value_of_min_radian_position;
4949
uint16_t model_num;
50+
double velocity_unit;
5051

5152
std::vector<ControlItem> item;
5253
} DxlInfo;
@@ -72,24 +73,25 @@ class DynamixelInfo
7273
void ReadDxlModelFile(uint8_t id, uint16_t model_num);
7374
bool GetDxlControlItem(uint8_t id, std::string item_name, uint16_t & addr, uint8_t & size);
7475
bool CheckDxlControlItem(uint8_t id, std::string item_name);
75-
bool GetDxlTypeInfo(
76-
uint8_t id,
77-
int32_t & value_of_zero_radian_position,
78-
int32_t & value_of_max_radian_position,
79-
int32_t & value_of_min_radian_position,
80-
double & min_radian,
81-
double & max_radian,
82-
double & torque_constant);
76+
// bool GetDxlTypeInfo(
77+
// uint8_t id,
78+
// int32_t & value_of_zero_radian_position,
79+
// int32_t & value_of_max_radian_position,
80+
// int32_t & value_of_min_radian_position,
81+
// double & min_radian,
82+
// double & max_radian,
83+
// double & torque_constant,
84+
// double & velocity_unit);
8385
int32_t ConvertRadianToValue(uint8_t id, double radian);
8486
double ConvertValueToRadian(uint8_t id, int32_t value);
8587
inline int16_t ConvertEffortToCurrent(uint8_t id, double effort)
8688
{return static_cast<int16_t>(effort / dxl_info_[id].torque_constant);}
8789
inline double ConvertCurrentToEffort(uint8_t id, int16_t current)
8890
{return static_cast<double>(current * dxl_info_[id].torque_constant);}
89-
inline double ConvertValueRPMToVelocityRPS(int32_t value_rpm)
90-
{return static_cast<double>(value_rpm * 0.01 / 60.0 * 2.0 * M_PI);}
91-
inline int32_t ConvertVelocityRPSToValueRPM(double vel_rps)
92-
{return static_cast<int32_t>(vel_rps * 100.0 * 60.0 / 2.0 / M_PI);}
91+
inline double ConvertValueRPMToVelocityRPS(uint8_t id, int32_t value_rpm)
92+
{return static_cast<double>(value_rpm * dxl_info_[id].velocity_unit / 60.0 * 2.0 * M_PI);}
93+
inline int32_t ConvertVelocityRPSToValueRPM(uint8_t id, double vel_rps)
94+
{return static_cast<int32_t>(vel_rps / dxl_info_[id].velocity_unit * 60.0 / 2.0 / M_PI);}
9395
};
9496

9597
} // namespace dynamixel_hardware_interface

include/dynamixel_hardware_interface/dynamixel_hardware_interface.hpp

Lines changed: 4 additions & 10 deletions
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_;
@@ -245,6 +247,7 @@ class DynamixelHardware : public
245247
std::vector<HandlerVarType> hdl_sensor_states_;
246248

247249
///// handler controller variable
250+
std::vector<HandlerVarType> hdl_gpio_controller_states_;
248251
std::vector<HandlerVarType> hdl_gpio_controller_commands_;
249252

250253
bool is_set_hdl_{false};
@@ -262,15 +265,6 @@ class DynamixelHardware : public
262265
*/
263266
bool initItems(const std::string & type_filter);
264267

265-
/**
266-
* @brief Helper function to retry writing an item to a Dynamixel device.
267-
* @param id The ID of the Dynamixel device.
268-
* @param item_name The name of the item to write.
269-
* @param value The value to write.
270-
* @return True if write was successful, false if timeout occurred.
271-
*/
272-
bool retryWriteItem(uint8_t id, const std::string & item_name, uint32_t value);
273-
274268
/**
275269
* @brief Initializes Dynamixel items.
276270
* @return True if initialization was successful, false otherwise.
@@ -362,7 +356,7 @@ class DynamixelHardware : public
362356
size_t outer_size,
363357
size_t inner_size,
364358
std::vector<HandlerVarType> & outer_handlers,
365-
const std::vector<HandlerVarType> & inner_handlers,
359+
std::vector<HandlerVarType> & inner_handlers,
366360
double ** matrix,
367361
const std::unordered_map<std::string, std::vector<std::string>> & iface_map,
368362
const std::string & conversion_iface = "",

package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
33
<package format="3">
44
<name>dynamixel_hardware_interface</name>
5-
<version>1.4.6</version>
5+
<version>1.4.7</version>
66
<description>
77
ROS 2 package providing a hardware interface for controlling Dynamixel motors via the ROS 2 control framework.
88
</description>

param/dxl_model/2xc430_w250.model

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ value_of_max_radian_position 4095
55
value_of_min_radian_position 0
66
min_radian -3.14159265
77
max_radian 3.14159265
8+
velocity_unit 0.229
89

910
[control table]
1011
Address Size Data Name

param/dxl_model/2xl430_w250.model

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ value_of_max_radian_position 4095
55
value_of_min_radian_position 0
66
min_radian -3.14159265
77
max_radian 3.14159265
8+
velocity_unit 0.229
89

910
[control table]
1011
Address Size Data Name

param/dxl_model/dynamixel.model

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,10 @@ Number Name
4848
230 omy_end.model
4949
536 sensorxel_joy.model
5050
600 sensorxel_joy.model
51+
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)