diff --git a/controller_interface/include/controller_interface/async_function_handler.hpp b/controller_interface/include/controller_interface/async_function_handler.hpp index 21c3186e93..46bd83f24c 100644 --- a/controller_interface/include/controller_interface/async_function_handler.hpp +++ b/controller_interface/include/controller_interface/async_function_handler.hpp @@ -126,7 +126,7 @@ class AsyncFunctionHandler if (is_running()) { std::unique_lock lock(async_mtx_); - async_update_condition_.wait(lock, [this] { return !trigger_in_progress_; }); + cycle_end_condition_.wait(lock, [this] { return !trigger_in_progress_; }); } } @@ -218,13 +218,14 @@ class AsyncFunctionHandler lock, [this] { return trigger_in_progress_ || async_update_stop_; }); if (async_update_stop_) { - async_update_condition_.notify_one(); + trigger_in_progress_ = false; + cycle_end_condition_.notify_one(); break; } async_update_return_ = async_function_(current_update_time_, current_update_period_); trigger_in_progress_ = false; } - async_update_condition_.notify_one(); + cycle_end_condition_.notify_one(); } }); } @@ -242,6 +243,7 @@ class AsyncFunctionHandler std::atomic_bool trigger_in_progress_{false}; std::atomic async_update_return_; std::condition_variable async_update_condition_; + std::condition_variable cycle_end_condition_; std::mutex async_mtx_; }; } // namespace ros2_control