Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
20 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
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
21 changes: 16 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 write operations
#define MAX_WRITE_RETRIES 10 ///< Maximum number of retries for write 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; ///< ID of the Dynamixel motor.
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);
DxlError DynamixelEnable(std::vector<uint8_t> id_arr);
DxlError DynamixelDisable(std::vector<uint8_t> id_arr);

Expand All @@ -205,6 +211,10 @@ 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;}

private:
bool checkReadType();
bool checkWriteType();
Expand Down Expand Up @@ -237,8 +247,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
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 @@ -269,7 +272,7 @@ class DynamixelHardware : public
* @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);
// bool retryWriteItem(uint8_t id, const std::string & item_name, uint32_t value);

/**
* @brief Initializes Dynamixel items.
Expand Down Expand Up @@ -362,7 +365,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,
double ** matrix,
const std::unordered_map<std::string, std::vector<std::string>> & iface_map,
const std::string & conversion_iface = "",
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