Skip to content

Commit 08605d1

Browse files
Merge pull request #1030 from pleemann/tree_wake_up
Event-based tree ticking
2 parents b451618 + b8a62dd commit 08605d1

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

include/behaviortree_cpp/bt_factory.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,20 @@ class Tree
119119
[[nodiscard]] TreeNode* rootNode() const;
120120

121121
/**
122-
* @brief Sleep for a certain amount of time. This sleep could be interrupted by the method TreeNode::emitWakeUpSignal()
122+
* @brief Sleep for a certain amount of time. This sleep could be interrupted by the methods
123+
* TreeNode::emitWakeUpSignal() or Tree::emitWakeUpSignal()
123124
*
124125
* @param timeout duration of the sleep
125126
* @return true if the timeout was NOT reached and the signal was received.
126127
*
127128
* */
128129
bool sleep(std::chrono::system_clock::duration timeout);
129130

131+
/**
132+
* @brief Wake up the tree. This will interrupt the sleep() method.
133+
*/
134+
void emitWakeUpSignal();
135+
130136
~Tree();
131137

132138
/// Tick the root of the tree once, even if a node invoked

src/bt_factory.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,11 @@ bool Tree::sleep(std::chrono::system_clock::duration timeout)
519519
std::chrono::duration_cast<std::chrono::milliseconds>(timeout));
520520
}
521521

522+
void Tree::emitWakeUpSignal()
523+
{
524+
wake_up_->emitSignal();
525+
}
526+
522527
Tree::~Tree()
523528
{
524529
haltTree();

0 commit comments

Comments
 (0)