Nav2 Navigation Stack - humble  humble
ROS 2 Navigation Stack
Public Member Functions | Protected Attributes | List of all members
nav2_behavior_tree::BehaviorTreeEngine Class Reference

A class to create and handle behavior trees. More...

#include <nav2_behavior_tree/include/nav2_behavior_tree/behavior_tree_engine.hpp>

Public Member Functions

 BehaviorTreeEngine (const std::vector< std::string > &plugin_libraries)
 A constructor for nav2_behavior_tree::BehaviorTreeEngine. More...
 
BtStatus run (BT::Tree *tree, std::function< void()> onLoop, std::function< bool()> cancelRequested, std::chrono::milliseconds loopTimeout=std::chrono::milliseconds(10))
 Function to execute a BT at a specific rate. More...
 
BT::Tree createTreeFromText (const std::string &xml_string, BT::Blackboard::Ptr blackboard)
 Function to create a BT from a XML string. More...
 
BT::Tree createTreeFromFile (const std::string &file_path, BT::Blackboard::Ptr blackboard)
 Function to create a BT from an XML file. More...
 
void haltAllActions (BT::TreeNode *root_node)
 Function to explicitly reset all BT nodes to initial state. More...
 

Protected Attributes

BT::BehaviorTreeFactory factory_
 

Detailed Description

A class to create and handle behavior trees.

Definition at line 43 of file behavior_tree_engine.hpp.

Constructor & Destructor Documentation

◆ BehaviorTreeEngine()

nav2_behavior_tree::BehaviorTreeEngine::BehaviorTreeEngine ( const std::vector< std::string > &  plugin_libraries)
explicit

A constructor for nav2_behavior_tree::BehaviorTreeEngine.

Parameters
plugin_librariesvector of BT plugin library names to load

Definition at line 28 of file behavior_tree_engine.cpp.

Member Function Documentation

◆ createTreeFromFile()

BT::Tree nav2_behavior_tree::BehaviorTreeEngine::createTreeFromFile ( const std::string &  file_path,
BT::Blackboard::Ptr  blackboard 
)

Function to create a BT from an XML file.

Parameters
file_pathPath to BT XML file
blackboardBlackboard for BT
Returns
BT::Tree Created behavior tree

Definition at line 85 of file behavior_tree_engine.cpp.

◆ createTreeFromText()

BT::Tree nav2_behavior_tree::BehaviorTreeEngine::createTreeFromText ( const std::string &  xml_string,
BT::Blackboard::Ptr  blackboard 
)

Function to create a BT from a XML string.

Parameters
xml_stringXML string representing BT
blackboardBlackboard for BT
Returns
BT::Tree Created behavior tree

Definition at line 77 of file behavior_tree_engine.cpp.

◆ haltAllActions()

void nav2_behavior_tree::BehaviorTreeEngine::haltAllActions ( BT::TreeNode *  root_node)

Function to explicitly reset all BT nodes to initial state.

Parameters
root_nodePointer to BT root node

Definition at line 94 of file behavior_tree_engine.cpp.

◆ run()

BtStatus nav2_behavior_tree::BehaviorTreeEngine::run ( BT::Tree *  tree,
std::function< void()>  onLoop,
std::function< bool()>  cancelRequested,
std::chrono::milliseconds  loopTimeout = std::chrono::milliseconds(10) 
)

Function to execute a BT at a specific rate.

Parameters
treeBT to execute
onLoopFunction to execute on each iteration of BT execution
cancelRequestedFunction to check if cancel was requested during BT execution
loopTimeoutTime period for each iteration of BT execution
Returns
nav2_behavior_tree::BtStatus Status of BT execution

Definition at line 38 of file behavior_tree_engine.cpp.


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