diff --git a/ur_robot_driver/src/hardware_interface.cpp b/ur_robot_driver/src/hardware_interface.cpp index 024a662ff..bb0deeb41 100644 --- a/ur_robot_driver/src/hardware_interface.cpp +++ b/ur_robot_driver/src/hardware_interface.cpp @@ -470,13 +470,15 @@ URPositionHardwareInterface::on_activate(const rclcpp_lifecycle::State& previous } hardware_interface::CallbackReturn -URPositionHardwareInterface::on_deactivate(const rclcpp_lifecycle::State& previous_state) +URPositionHardwareInterface::on_cleanup(const rclcpp_lifecycle::State& previous_state) { RCLCPP_INFO(rclcpp::get_logger("URPositionHardwareInterface"), "Stopping ...please wait..."); - async_thread_shutdown_ = true; - async_thread_->join(); - async_thread_.reset(); + if (async_thread_) { + async_thread_shutdown_ = true; + async_thread_->join(); + async_thread_.reset(); + } ur_driver_.reset();