diff --git a/include/behaviortree_cpp/bt_factory.h b/include/behaviortree_cpp/bt_factory.h index 99b27d4ba..f7d7a8b1c 100644 --- a/include/behaviortree_cpp/bt_factory.h +++ b/include/behaviortree_cpp/bt_factory.h @@ -118,10 +118,14 @@ class Tree [[nodiscard]] TreeNode* rootNode() const; - /// Sleep for a certain amount of time. - /// This sleep could be interrupted by the method - /// TreeNode::emitWakeUpSignal() - void sleep(std::chrono::system_clock::duration timeout); + /** + * @brief Sleep for a certain amount of time. This sleep could be interrupted by the method TreeNode::emitWakeUpSignal() + * + * @param timeout duration of the sleep + * @return true if the timeout was NOT reached and the signal was received. + * + * */ + bool sleep(std::chrono::system_clock::duration timeout); ~Tree(); diff --git a/src/bt_factory.cpp b/src/bt_factory.cpp index 30fa25e2b..acf39492c 100644 --- a/src/bt_factory.cpp +++ b/src/bt_factory.cpp @@ -586,9 +586,10 @@ TreeNode* Tree::rootNode() const return subtree_nodes.empty() ? nullptr : subtree_nodes.front().get(); } -void Tree::sleep(std::chrono::system_clock::duration timeout) +bool Tree::sleep(std::chrono::system_clock::duration timeout) { - wake_up_->waitFor(std::chrono::duration_cast(timeout)); + return wake_up_->waitFor( + std::chrono::duration_cast(timeout)); } Tree::~Tree()