@@ -160,7 +160,7 @@ hardware_interface::CallbackReturn DynamixelHardware::on_init(
160
160
RCLCPP_INFO_STREAM (logger_, " Trying to connect to the communication port..." );
161
161
break ;
162
162
} else {
163
- sleep ( 1 );
163
+ std::this_thread::sleep_for ( std::chrono::seconds ( 1 ) );
164
164
if (i == 9 ) {
165
165
RCLCPP_ERROR_STREAM (logger_, " Cannot connect communication port! :(" );
166
166
return hardware_interface::CallbackReturn::ERROR;
@@ -186,7 +186,7 @@ hardware_interface::CallbackReturn DynamixelHardware::on_init(
186
186
RCLCPP_INFO_STREAM (logger_, " Trying to connect to the communication port..." );
187
187
break ;
188
188
} else {
189
- sleep ( 1 );
189
+ std::this_thread::sleep_for ( std::chrono::seconds ( 1 ) );
190
190
if (i == 9 ) {
191
191
RCLCPP_ERROR_STREAM (logger_, " Cannot connect communication port! :(" );
192
192
return hardware_interface::CallbackReturn::ERROR;
@@ -499,7 +499,7 @@ hardware_interface::CallbackReturn DynamixelHardware::start()
499
499
500
500
// sync commands = states joint
501
501
SyncJointCommandWithStates ();
502
- usleep ( 500 * 1000 );
502
+ std::this_thread::sleep_for ( std::chrono::milliseconds ( 500 ) );
503
503
504
504
// Enable torque only for Dynamixels that have torque enabled in their parameters
505
505
std::vector<uint8_t > torque_enabled_ids;
@@ -516,7 +516,7 @@ hardware_interface::CallbackReturn DynamixelHardware::start()
516
516
break ;
517
517
}
518
518
RCLCPP_ERROR_STREAM (logger_, " Failed to enable torque for Dynamixels, retry..." );
519
- usleep ( 100 * 1000 );
519
+ std::this_thread::sleep_for ( std::chrono::milliseconds ( 100 ) );
520
520
}
521
521
}
522
522
@@ -703,7 +703,7 @@ bool DynamixelHardware::CommReset()
703
703
704
704
auto start_time = this ->now ();
705
705
while ((this ->now () - start_time) < rclcpp::Duration (3 , 0 )) {
706
- usleep ( 200 * 1000 );
706
+ std::this_thread::sleep_for ( std::chrono::milliseconds ( 200 ) );
707
707
RCLCPP_INFO_STREAM (logger_, " Reset Start" );
708
708
bool result = true ;
709
709
for (auto id : dxl_id_) {
@@ -712,7 +712,7 @@ bool DynamixelHardware::CommReset()
712
712
result = false ;
713
713
break ;
714
714
}
715
- usleep ( 200 * 1000 );
715
+ std::this_thread::sleep_for ( std::chrono::milliseconds ( 200 ) );
716
716
}
717
717
if (!result) {continue ;}
718
718
if (!InitControllerItems ()) {continue ;}
@@ -721,13 +721,13 @@ bool DynamixelHardware::CommReset()
721
721
if (!InitDxlWriteItems ()) {continue ;}
722
722
723
723
RCLCPP_INFO_STREAM (logger_, " RESET Success" );
724
- usleep ( 1000 * 1000 );
724
+ std::this_thread::sleep_for ( std::chrono::seconds ( 1 ) );
725
725
start ();
726
726
dxl_status_ = DXL_OK;
727
727
return true ;
728
728
}
729
729
RCLCPP_ERROR_STREAM (logger_, " RESET Failure" );
730
- usleep ( 1000 * 1000 );
730
+ std::this_thread::sleep_for ( std::chrono::seconds ( 1 ) );
731
731
start ();
732
732
return false ;
733
733
}
0 commit comments