From 945a34d093a4319a77218aaf5d9db51edbcdacca Mon Sep 17 00:00:00 2001 From: Michele Tartari <37861893+m-tartari@users.noreply.github.com> Date: Mon, 25 Nov 2024 13:23:35 +0100 Subject: [PATCH 1/2] fix(examples): update t11_groot_howto log filename (#886) --- examples/t11_groot_howto.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/t11_groot_howto.cpp b/examples/t11_groot_howto.cpp index da974947c..14713cbac 100644 --- a/examples/t11_groot_howto.cpp +++ b/examples/t11_groot_howto.cpp @@ -120,7 +120,7 @@ int main() // Both formats are compatible with Groot2 // Logging with lightweight serialization - BT::FileLogger2 logger2(tree, "t12_logger2.btlog"); + BT::FileLogger2 logger2(tree, "t11_groot_howto.btlog"); BT::MinitraceLogger minilog(tree, "minitrace.json"); while(1) From f5e98fd751523fd2797e5353cb9f1cc765587cb4 Mon Sep 17 00:00:00 2001 From: Tony Najjar Date: Mon, 25 Nov 2024 16:20:31 +0100 Subject: [PATCH 2/2] Expose return value of wait_for (#887) --- include/behaviortree_cpp/bt_factory.h | 12 ++++++++---- src/bt_factory.cpp | 5 +++-- 2 files changed, 11 insertions(+), 6 deletions(-) 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()