Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ba695c9
feat: Add GPIO controller state handling and rcu model for ffw
Woojin-Crive Jun 5, 2025
013ee93
feat: Enhance Dynamixel interface with communication ID handling and …
Woojin-Crive Jun 11, 2025
28c35b6
refactor: Update Dynamixel interface for improved handler management …
Woojin-Crive Jun 12, 2025
06e8de3
feat: Introduce torque initialization handling and communication retr…
Woojin-Crive Jun 16, 2025
3dae77e
refactor: Improve formatting
Woojin-Crive Jun 16, 2025
bb268c6
refactor: Update position parameter in transmission calculation for c…
Woojin-Crive Jun 16, 2025
ed1d1ee
refactor: Remove unused retryWriteItem function from Dynamixel interface
Woojin-Crive Jun 16, 2025
6aebda4
refactor: Remove duplicate entries for Indirect Address in model file
Woojin-Crive Jun 16, 2025
d157ee4
refactor: Clarify documentation for Dynamixel motor ID array
Woojin-Crive Jun 16, 2025
ba7957c
refactor: Update Dynamixel value handling for consistency and clarity
Woojin-Crive Jun 17, 2025
d88ff3b
feat: Add velocity unit handling to Dynamixel model processing
Woojin-Crive Jun 17, 2025
6f696f4
feat: Add velocity unit parameter to multiple Dynamixel model files
Woojin-Crive Jun 17, 2025
00f7d86
refactor: Improve warning message formatting
Woojin-Crive Jun 17, 2025
4392276
refactor: Optimize early return checks in Dynamixel data handling
Woojin-Crive Jun 18, 2025
bf0452f
fix: Enhance warning messages in Dynamixel model file handling to inc…
Woojin-Crive Jun 18, 2025
6e1ed52
refactor: Replace sleep functions with std::this_thread::sleep_for fo…
Woojin-Crive Jun 18, 2025
44d3f8f
fix: Add thread header for dynamixel.cpp
Woojin-Crive Jun 19, 2025
7e20f4e
fix: Handle empty read data list in Dynamixel read operations
Woojin-Crive Jun 19, 2025
f9d5233
fix: Add check for empty ID array in Sync Read Handler to prevent unn…
Woojin-Crive Jun 19, 2025
1d790f7
chore: Update version to 1.4.7 and add new features
Woojin-Crive Jun 19, 2025
4be96ec
Merge pull request #47 from ROBOTIS-GIT/feature-rcu
Woojin-Crive Jun 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Changelog for package dynamixel_hardware_interface
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1.4.7 (2025-06-19)
------------------
* Added virtual_dxl and support for rcu
* Contributors: Woojin Wie

1.4.6 (2025-05-30)
------------------
* Changed dynamixel_sdk_TARGETS to dynamixel_sdk_LIBRARIES in target_link_libraries
Expand Down
23 changes: 18 additions & 5 deletions include/dynamixel_hardware_interface/dynamixel/dynamixel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ namespace dynamixel_hardware_interface
#define SYNC 0 ///< Synchronous communication.
#define BULK 1 ///< Bulk communication.

/// @brief Maximum number of retries for communication operations
#define MAX_COMM_RETRIES 5 ///< Maximum number of retries for communication operations

/// @brief Error codes for Dynamixel operations.
enum DxlError
{
Expand Down Expand Up @@ -99,7 +102,8 @@ typedef struct
*/
typedef struct
{
uint8_t id; ///< ID of the Dynamixel motor.
uint8_t comm_id; ///< ID of the Dynamixel to be communicated.
std::vector<uint8_t> id_arr; ///< IDs of the Dynamixel motors.
std::vector<std::string> item_name; ///< List of control item names.
std::vector<uint8_t> item_size; ///< Sizes of the control items.
std::vector<uint16_t> item_addr; ///< Addresses of the control items.
Expand Down Expand Up @@ -156,6 +160,8 @@ class Dynamixel
// direct inform for bulk write
std::map<uint8_t /*id*/, IndirectInfo> direct_info_write_;

std::map<uint8_t /*id*/, uint8_t> comm_id_;

public:
explicit Dynamixel(const char * path);
~Dynamixel();
Expand All @@ -167,13 +173,13 @@ class Dynamixel

// DXL Read Setting
DxlError SetDxlReadItems(
uint8_t id, std::vector<std::string> item_names,
uint8_t id, uint8_t comm_id, std::vector<std::string> item_names,
std::vector<std::shared_ptr<double>> data_vec_ptr);
DxlError SetMultiDxlRead();

// DXL Write Setting
DxlError SetDxlWriteItems(
uint8_t id, std::vector<std::string> item_names,
uint8_t id, uint8_t comm_id, std::vector<std::string> item_names,
std::vector<std::shared_ptr<double>> data_vec_ptr);
DxlError SetMultiDxlWrite();

Expand All @@ -183,7 +189,7 @@ class Dynamixel
DxlError WriteMultiDxlData();

// Set Dxl Option
DxlError SetOperatingMode(uint8_t id, uint8_t dynamixel_mode);
// DxlError SetOperatingMode(uint8_t id, uint8_t dynamixel_mode);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The declaration for SetOperatingMode is commented out. If this function is no longer needed, it's better to remove the declaration entirely to improve code clarity and reduce dead code. If it's temporarily disabled, a // TODO: ... comment explaining why and when it might be reinstated would be helpful.

DxlError DynamixelEnable(std::vector<uint8_t> id_arr);
DxlError DynamixelDisable(std::vector<uint8_t> id_arr);

Expand All @@ -205,6 +211,12 @@ class Dynamixel

static std::string DxlErrorToString(DxlError error_num);

DxlError ReadDxlModelFile(uint8_t id, uint16_t model_num);

void SetCommId(uint8_t id, uint8_t comm_id) {comm_id_[id] = comm_id;}

DxlError InitTorqueStates(std::vector<uint8_t> id_arr, bool disable_torque = false);

private:
bool checkReadType();
bool checkWriteType();
Expand Down Expand Up @@ -237,8 +249,9 @@ class Dynamixel

// Read - Data Processing
DxlError ProcessReadData(
uint8_t id,
uint8_t comm_id,
uint16_t indirect_addr,
const std::vector<uint8_t> & id_arr,
const std::vector<std::string> & item_names,
const std::vector<uint8_t> & item_sizes,
const std::vector<std::shared_ptr<double>> & data_ptrs,
Expand Down
26 changes: 14 additions & 12 deletions include/dynamixel_hardware_interface/dynamixel/dynamixel_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ typedef struct
int32_t value_of_max_radian_position;
int32_t value_of_min_radian_position;
uint16_t model_num;
double velocity_unit;

std::vector<ControlItem> item;
} DxlInfo;
Expand All @@ -72,24 +73,25 @@ class DynamixelInfo
void ReadDxlModelFile(uint8_t id, uint16_t model_num);
bool GetDxlControlItem(uint8_t id, std::string item_name, uint16_t & addr, uint8_t & size);
bool CheckDxlControlItem(uint8_t id, std::string item_name);
bool GetDxlTypeInfo(
uint8_t id,
int32_t & value_of_zero_radian_position,
int32_t & value_of_max_radian_position,
int32_t & value_of_min_radian_position,
double & min_radian,
double & max_radian,
double & torque_constant);
// bool GetDxlTypeInfo(
// uint8_t id,
// int32_t & value_of_zero_radian_position,
// int32_t & value_of_max_radian_position,
// int32_t & value_of_min_radian_position,
// double & min_radian,
// double & max_radian,
// double & torque_constant,
// double & velocity_unit);
Comment on lines +76 to +84
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The declaration for GetDxlTypeInfo is commented out. Similar to SetOperatingMode, if this function is deprecated, please remove its declaration. If it's planned for future use or is temporarily disabled, a // TODO: ... comment would clarify its status.

int32_t ConvertRadianToValue(uint8_t id, double radian);
double ConvertValueToRadian(uint8_t id, int32_t value);
inline int16_t ConvertEffortToCurrent(uint8_t id, double effort)
{return static_cast<int16_t>(effort / dxl_info_[id].torque_constant);}
inline double ConvertCurrentToEffort(uint8_t id, int16_t current)
{return static_cast<double>(current * dxl_info_[id].torque_constant);}
inline double ConvertValueRPMToVelocityRPS(int32_t value_rpm)
{return static_cast<double>(value_rpm * 0.01 / 60.0 * 2.0 * M_PI);}
inline int32_t ConvertVelocityRPSToValueRPM(double vel_rps)
{return static_cast<int32_t>(vel_rps * 100.0 * 60.0 / 2.0 / M_PI);}
inline double ConvertValueRPMToVelocityRPS(uint8_t id, int32_t value_rpm)
{return static_cast<double>(value_rpm * dxl_info_[id].velocity_unit / 60.0 * 2.0 * M_PI);}
inline int32_t ConvertVelocityRPSToValueRPM(uint8_t id, double vel_rps)
{return static_cast<int32_t>(vel_rps / dxl_info_[id].velocity_unit * 60.0 / 2.0 / M_PI);}
};

} // namespace dynamixel_hardware_interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ constexpr char HW_IF_TORQUE_ENABLE[] = "torque_enable";
typedef struct HandlerVarType_
{
uint8_t id; /**< ID of the Dynamixel component. */
uint8_t comm_id; /**< ID of the Dynamixel to be communicated. */
std::string name; /**< Name of the component. */
std::vector<std::string> interface_name_vec; /**< Vector of interface names. */
std::vector<std::shared_ptr<double>> value_ptr_vec; /**< Vector interface values. */
Expand Down Expand Up @@ -227,6 +228,7 @@ class DynamixelHardware : public
std::string port_name_;
std::string baud_rate_;
std::vector<uint8_t> dxl_id_;
std::vector<uint8_t> virtual_dxl_id_;

std::vector<uint8_t> sensor_id_;
std::map<uint8_t /*id*/, std::string /*interface_name*/> sensor_item_;
Expand All @@ -245,6 +247,7 @@ class DynamixelHardware : public
std::vector<HandlerVarType> hdl_sensor_states_;

///// handler controller variable
std::vector<HandlerVarType> hdl_gpio_controller_states_;
std::vector<HandlerVarType> hdl_gpio_controller_commands_;

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

/**
* @brief Helper function to retry writing an item to a Dynamixel device.
* @param id The ID of the Dynamixel device.
* @param item_name The name of the item to write.
* @param value The value to write.
* @return True if write was successful, false if timeout occurred.
*/
bool retryWriteItem(uint8_t id, const std::string & item_name, uint32_t value);

/**
* @brief Initializes Dynamixel items.
* @return True if initialization was successful, false otherwise.
Expand Down Expand Up @@ -362,7 +356,7 @@ class DynamixelHardware : public
size_t outer_size,
size_t inner_size,
std::vector<HandlerVarType> & outer_handlers,
const std::vector<HandlerVarType> & inner_handlers,
std::vector<HandlerVarType> & inner_handlers,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The inner_handlers parameter in MapInterfaces was changed from const std::vector<HandlerVarType>& to std::vector<HandlerVarType>&. If this function does not modify inner_handlers (it appears to only read from it), it should be passed by const& to maintain const-correctness and prevent accidental modifications.

Suggested change
std::vector<HandlerVarType> & inner_handlers,
const std::vector<HandlerVarType> & inner_handlers,

double ** matrix,
const std::unordered_map<std::string, std::vector<std::string>> & iface_map,
const std::string & conversion_iface = "",
Expand Down
2 changes: 1 addition & 1 deletion package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>dynamixel_hardware_interface</name>
<version>1.4.6</version>
<version>1.4.7</version>
<description>
ROS 2 package providing a hardware interface for controlling Dynamixel motors via the ROS 2 control framework.
</description>
Expand Down
1 change: 1 addition & 0 deletions param/dxl_model/2xc430_w250.model
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ value_of_max_radian_position 4095
value_of_min_radian_position 0
min_radian -3.14159265
max_radian 3.14159265
velocity_unit 0.229

[control table]
Address Size Data Name
Expand Down
1 change: 1 addition & 0 deletions param/dxl_model/2xl430_w250.model
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ value_of_max_radian_position 4095
value_of_min_radian_position 0
min_radian -3.14159265
max_radian 3.14159265
velocity_unit 0.229

[control table]
Address Size Data Name
Expand Down
7 changes: 7 additions & 0 deletions param/dxl_model/dynamixel.model
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,10 @@ Number Name
230 omy_end.model
536 sensorxel_joy.model
600 sensorxel_joy.model
602 ffw_g10_rcu.model
620 ffw_sg2_steer_1.model
621 ffw_sg2_steer_2.model
622 ffw_sg2_steer_3.model
623 ffw_sg2_drive_1.model
624 ffw_sg2_drive_2.model
625 ffw_sg2_drive_3.model
Loading
Loading