From 57c7bfecb29b6dc9e8fcdfdafcd7a2365aee4361 Mon Sep 17 00:00:00 2001 From: Tony Najjar Date: Mon, 25 Nov 2024 12:53:03 +0100 Subject: [PATCH 1/3] Expose return value of wait_for Signed-off-by: Tony Najjar --- include/behaviortree_cpp/bt_factory.h | 2 +- src/bt_factory.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/behaviortree_cpp/bt_factory.h b/include/behaviortree_cpp/bt_factory.h index 99b27d4ba..62c2471f3 100644 --- a/include/behaviortree_cpp/bt_factory.h +++ b/include/behaviortree_cpp/bt_factory.h @@ -121,7 +121,7 @@ class Tree /// 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); + bool sleep(std::chrono::system_clock::duration timeout); ~Tree(); diff --git a/src/bt_factory.cpp b/src/bt_factory.cpp index 30fa25e2b..98f01181c 100644 --- a/src/bt_factory.cpp +++ b/src/bt_factory.cpp @@ -586,9 +586,9 @@ 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() From 7410ba2f5e3dcb1c93ce593f3cb9c6f2e338b101 Mon Sep 17 00:00:00 2001 From: Tony Najjar Date: Mon, 25 Nov 2024 14:12:28 +0100 Subject: [PATCH 2/3] update docs Signed-off-by: Tony Najjar --- include/behaviortree_cpp/bt_factory.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/include/behaviortree_cpp/bt_factory.h b/include/behaviortree_cpp/bt_factory.h index 62c2471f3..f7d7a8b1c 100644 --- a/include/behaviortree_cpp/bt_factory.h +++ b/include/behaviortree_cpp/bt_factory.h @@ -118,9 +118,13 @@ class Tree [[nodiscard]] TreeNode* rootNode() const; - /// Sleep for a certain amount of time. - /// This sleep could be interrupted by the method - /// TreeNode::emitWakeUpSignal() + /** + * @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(); From 61c2ca83e3364d1a3ce2d150c90cc9367625bb8b Mon Sep 17 00:00:00 2001 From: Tony Najjar Date: Mon, 25 Nov 2024 14:14:03 +0100 Subject: [PATCH 3/3] Fix pre-commit Signed-off-by: Tony Najjar --- src/bt_factory.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bt_factory.cpp b/src/bt_factory.cpp index 98f01181c..acf39492c 100644 --- a/src/bt_factory.cpp +++ b/src/bt_factory.cpp @@ -588,7 +588,8 @@ TreeNode* Tree::rootNode() const bool Tree::sleep(std::chrono::system_clock::duration timeout) { - return wake_up_->waitFor(std::chrono::duration_cast(timeout)); + return wake_up_->waitFor( + std::chrono::duration_cast(timeout)); } Tree::~Tree()