Skip to content

Commit f2a7e3c

Browse files
committed
fix: lint error handling
1 parent 3692a1d commit f2a7e3c

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

include/dynamixel_hardware_interface/dynamixel_hardware_interface.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ class DynamixelHardware : public
261261
* @param type_filter The type of items to initialize ("controller" or "dxl" or "sensor").
262262
* @return True if initialization was successful, false otherwise.
263263
*/
264-
bool initItems(const std::string& type_filter);
264+
bool initItems(const std::string & type_filter);
265265

266266
/**
267267
* @brief Helper function to retry writing an item to a Dynamixel device.
@@ -270,7 +270,7 @@ class DynamixelHardware : public
270270
* @param value The value to write.
271271
* @return True if write was successful, false if timeout occurred.
272272
*/
273-
bool retryWriteItem(uint8_t id, const std::string& item_name, uint32_t value);
273+
bool retryWriteItem(uint8_t id, const std::string & item_name, uint32_t value);
274274

275275
/**
276276
* @brief Initializes Dynamixel items.

src/dynamixel_hardware_interface.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ hardware_interface::CallbackReturn DynamixelHardware::on_init(
117117
int trying_cnt = 60;
118118
int cnt = 0;
119119

120-
if(controller_id_.size() > 0 ) {
120+
if (controller_id_.size() > 0) {
121121
while (trying_connect) {
122122
std::vector<uint8_t> id_arr;
123123
for (auto controller : controller_id_) {
@@ -614,24 +614,25 @@ bool DynamixelHardware::CommReset()
614614
return false;
615615
}
616616

617-
bool DynamixelHardware::retryWriteItem(uint8_t id, const std::string& item_name, uint32_t value) {
617+
bool DynamixelHardware::retryWriteItem(uint8_t id, const std::string & item_name, uint32_t value)
618+
{
618619
rclcpp::Time start_time = this->now();
619620
rclcpp::Duration error_duration(0, 0);
620-
621+
621622
while (true) {
622623
if (dxl_comm_->WriteItem(id, item_name, value) == DxlError::OK) {
623624
RCLCPP_INFO_STREAM(
624625
logger_,
625626
"[ID:" << std::to_string(id) << "] item_name:" << item_name.c_str() << "\tdata:" << value);
626627
return true;
627628
}
628-
629+
629630
error_duration = this->now() - start_time;
630631
if (error_duration.seconds() * 1000 >= err_timeout_ms_) {
631632
RCLCPP_ERROR_STREAM(
632633
logger_,
633-
"[ID:" << std::to_string(id) << "] Write Item error (Timeout: " <<
634-
error_duration.seconds() * 1000 << "ms/" << err_timeout_ms_ << "ms)");
634+
"[ID:" << std::to_string(id) << "] Write Item error (Timeout: " <<
635+
error_duration.seconds() * 1000 << "ms/" << err_timeout_ms_ << "ms)");
635636
return false;
636637
}
637638
RCLCPP_WARN_STREAM(
@@ -640,14 +641,15 @@ bool DynamixelHardware::retryWriteItem(uint8_t id, const std::string& item_name,
640641
}
641642
}
642643

643-
bool DynamixelHardware::initItems(const std::string& type_filter) {
644+
bool DynamixelHardware::initItems(const std::string & type_filter)
645+
{
644646
RCLCPP_INFO_STREAM(logger_, "$$$$$ Init Items for type: " << type_filter);
645647
for (const hardware_interface::ComponentInfo & gpio : info_.gpios) {
646648
if (gpio.parameters.at("type") != type_filter) {
647649
continue;
648650
}
649651
uint8_t id = static_cast<uint8_t>(stoi(gpio.parameters.at("ID")));
650-
652+
651653
// First write items containing "Limit"
652654
for (auto it : gpio.parameters) {
653655
if (it.first != "ID" && it.first != "type" && it.first.find("Limit") != std::string::npos) {

0 commit comments

Comments
 (0)