Skip to content

Commit 2804f39

Browse files
committed
feat: Enhance DXL item initialization by prioritizing 'Limit' parameters.
1 parent 945fc5c commit 2804f39

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/dynamixel_hardware_interface.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,8 +551,27 @@ bool DynamixelHardware::InitDxlItems()
551551
RCLCPP_INFO_STREAM(logger_, "$$$$$ Init Dxl Items");
552552
for (const hardware_interface::ComponentInfo & gpio : info_.gpios) {
553553
uint8_t id = static_cast<uint8_t>(stoi(gpio.parameters.at("ID")));
554+
555+
// First write items containing "Limit"
554556
for (auto it : gpio.parameters) {
555-
if (it.first != "ID" && it.first != "type") {
557+
if (it.first != "ID" && it.first != "type" && it.first.find("Limit") != std::string::npos) {
558+
if (dxl_comm_->WriteItem(
559+
id, it.first,
560+
static_cast<uint32_t>(stoi(it.second))) != DxlError::OK)
561+
{
562+
RCLCPP_ERROR_STREAM(logger_, "[ID:" << std::to_string(id) << "] Write Item error");
563+
return false;
564+
}
565+
RCLCPP_INFO_STREAM(
566+
logger_,
567+
"[ID:" << std::to_string(id) << "] item_name:" << it.first.c_str() << "\tdata:" <<
568+
stoi(it.second));
569+
}
570+
}
571+
572+
// Then write the remaining items
573+
for (auto it : gpio.parameters) {
574+
if (it.first != "ID" && it.first != "type" && it.first.find("Limit") == std::string::npos) {
556575
if (dxl_comm_->WriteItem(
557576
id, it.first,
558577
static_cast<uint32_t>(stoi(it.second))) != DxlError::OK)

0 commit comments

Comments
 (0)