BehaviorTree
Core Library to create and execute Behavior Trees
Loading...
Searching...
No Matches
BT::Tree Class Reference

Struct used to store a tree. If this object goes out of scope, the tree is destroyed. More...

#include <bt_factory.h>

Collaboration diagram for BT::Tree:

Classes

struct  Subtree
 

Public Member Functions

 Tree (const Tree &)=delete
 
Treeoperator= (const Tree &)=delete
 
 Tree (Tree &&other)=default
 
Treeoperator= (Tree &&other)=default
 
void initialize ()
 
void haltTree ()
 
TreeNoderootNode () const
 
bool sleep (std::chrono::system_clock::duration timeout)
 Sleep for a certain amount of time. This sleep could be interrupted by the methods TreeNode::emitWakeUpSignal() or Tree::emitWakeUpSignal()
 
void emitWakeUpSignal ()
 Wake up the tree. This will interrupt the sleep() method.
 
NodeStatus tickExactlyOnce ()
 
NodeStatus tickOnce ()
 by default, tickOnce() sends a single tick, BUT as long as there is at least one node of the tree invoking TreeNode::emitWakeUpSignal(), it will be ticked again.
 
NodeStatus tickWhileRunning (std::chrono::milliseconds sleep_time=std::chrono::milliseconds(10))
 
Blackboard::Ptr rootBlackboard ()
 
void applyVisitor (const std::function< void(const TreeNode *)> &visitor) const
 
void applyVisitor (const std::function< void(TreeNode *)> &visitor)
 
uint16_t getUID ()
 
template<typename NodeType = BT::TreeNode>
std::vector< const TreeNode * > getNodesByPath (StringView wildcard_filter) const
 

Public Attributes

std::vector< Subtree::Ptr > subtrees
 
std::unordered_map< std::string, TreeNodeManifestmanifests
 

Friends

class BehaviorTreeFactory
 

Detailed Description

Struct used to store a tree. If this object goes out of scope, the tree is destroyed.

Member Function Documentation

◆ getNodesByPath()

template<typename NodeType = BT::TreeNode>
std::vector< const TreeNode * > BT::Tree::getNodesByPath ( StringView  wildcard_filter) const
inline

Get a list of nodes which fullPath() match a wildcard filter and a given path. Example:

move_nodes = tree.getNodesByPath<MoveBaseNode>("move_*");

◆ sleep()

bool BT::Tree::sleep ( std::chrono::system_clock::duration  timeout)

Sleep for a certain amount of time. This sleep could be interrupted by the methods TreeNode::emitWakeUpSignal() or Tree::emitWakeUpSignal()

Parameters
timeoutduration of the sleep
Returns
true if the timeout was NOT reached and the signal was received.

◆ tickExactlyOnce()

NodeStatus BT::Tree::tickExactlyOnce ( )

Tick the root of the tree once, even if a node invoked emitWakeUpSignal()

◆ tickWhileRunning()

NodeStatus BT::Tree::tickWhileRunning ( std::chrono::milliseconds  sleep_time = std::chrono::milliseconds(10))

Call tickOnce until the status is different from RUNNING. Note that between one tick and the following one, a Tree::sleep() is used


The documentation for this class was generated from the following file: