Skip to content

Commit

Permalink
Merge branch 'BehaviorTree:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
GregoryLeMasurier authored Nov 25, 2024
2 parents 99ed2b0 + f5e98fd commit 18a1f8f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/t11_groot_howto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 8 additions & 4 deletions include/behaviortree_cpp/bt_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
5 changes: 3 additions & 2 deletions src/bt_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,9 +633,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<std::chrono::milliseconds>(timeout));
return wake_up_->waitFor(
std::chrono::duration_cast<std::chrono::milliseconds>(timeout));
}

Tree::~Tree()
Expand Down

0 comments on commit 18a1f8f

Please sign in to comment.