diff --git a/include/behaviortree_cpp/bt_factory.h b/include/behaviortree_cpp/bt_factory.h index 020c9ea1d..c9d53c123 100644 --- a/include/behaviortree_cpp/bt_factory.h +++ b/include/behaviortree_cpp/bt_factory.h @@ -119,7 +119,8 @@ class Tree [[nodiscard]] TreeNode* rootNode() const; /** - * @brief 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 methods + * TreeNode::emitWakeUpSignal() or Tree::emitWakeUpSignal() * * @param timeout duration of the sleep * @return true if the timeout was NOT reached and the signal was received. @@ -127,6 +128,11 @@ class Tree * */ bool sleep(std::chrono::system_clock::duration timeout); + /** + * @brief Wake up the tree. This will interrupt the sleep() method. + */ + void emitWakeUpSignal(); + ~Tree(); /// Tick the root of the tree once, even if a node invoked diff --git a/src/bt_factory.cpp b/src/bt_factory.cpp index 01e01301a..d7dd1dbb0 100644 --- a/src/bt_factory.cpp +++ b/src/bt_factory.cpp @@ -519,6 +519,11 @@ bool Tree::sleep(std::chrono::system_clock::duration timeout) std::chrono::duration_cast(timeout)); } +void Tree::emitWakeUpSignal() +{ + wake_up_->emitSignal(); +} + Tree::~Tree() { haltTree();