diff --git a/canopen_base_driver/include/canopen_base_driver/node_interfaces/node_canopen_base_driver_impl.hpp b/canopen_base_driver/include/canopen_base_driver/node_interfaces/node_canopen_base_driver_impl.hpp index e6acf3a2e..03e88bc41 100644 --- a/canopen_base_driver/include/canopen_base_driver/node_interfaces/node_canopen_base_driver_impl.hpp +++ b/canopen_base_driver/include/canopen_base_driver/node_interfaces/node_canopen_base_driver_impl.hpp @@ -220,7 +220,9 @@ template void NodeCanopenBaseDriver::deactivate(bool called_from_base) { nmt_state_publisher_thread_.join(); - poll_timer_->cancel(); + if (poll_timer_) { + poll_timer_->cancel(); + } emcy_queue_.reset(); rpdo_queue_.reset(); if (diagnostic_enabled_.load()) diff --git a/canopen_core/include/canopen_core/device_container.hpp b/canopen_core/include/canopen_core/device_container.hpp index f22c3a101..ddc421265 100644 --- a/canopen_core/include/canopen_core/device_container.hpp +++ b/canopen_core/include/canopen_core/device_container.hpp @@ -75,6 +75,8 @@ class DeviceContainer : public rclcpp_components::ComponentManager lifecycle_operation_ = false; } + ~DeviceContainer() override { shutdown(); } + /** * @brief Executes the initialisation * diff --git a/canopen_ros2_control/src/canopen_system.cpp b/canopen_ros2_control/src/canopen_system.cpp index 7ea588b1c..2bc27b44b 100644 --- a/canopen_ros2_control/src/canopen_system.cpp +++ b/canopen_ros2_control/src/canopen_system.cpp @@ -48,7 +48,10 @@ void CanopenSystem::clean() device_container_.reset(); executor_.reset(); - init_thread_->join(); + if (init_thread_->joinable()) + { + init_thread_->join(); + } init_thread_.reset(); executor_.reset();