AutoAPMS
Resilient Robot Mission Management
|
#include <auto_apms_behavior_tree/builder/tree_builder.hpp>
Public Member Functions | |
TreeBuilder (std::shared_ptr< BT::BehaviorTreeFactory > factory_ptr=std::make_shared< BT::BehaviorTreeFactory >()) | |
TreeBuilder & | registerNodePlugins (rclcpp::Node::SharedPtr node_ptr, const NodeManifest &node_manifest, NodePluginClassLoader &tree_node_loader, bool override=false) |
TreeBuilder & | registerNodePlugins (rclcpp::Node::SharedPtr node_ptr, const NodeManifest &node_manifest, bool override=false) |
TreeBuilder & | addTreeFromXMLDocument (const tinyxml2::XMLDocument &doc) |
TreeBuilder & | addTreeFromString (const std::string &tree_str) |
TreeBuilder & | addTreeFromFile (const std::string &tree_file_path) |
TreeBuilder & | addTreeFromResource (const TreeResource &resource, rclcpp::Node::SharedPtr node_ptr) |
std::string | getMainTreeName () const |
TreeBuilder & | setMainTreeName (const std::string &main_tree_name) |
std::string | writeTreeXMLToString () const |
std::unordered_map< std::string, BT::NodeType > | getRegisteredNodes () |
Tree | buildTree (const std::string main_tree_name, TreeBlackboardSharedPtr root_bb_ptr=TreeBlackboard::create()) |
Tree | buildTree (TreeBlackboardSharedPtr root_bb_ptr=TreeBlackboard::create()) |
Static Public Member Functions | |
static std::set< std::string > | getTreeNames (const tinyxml2::XMLDocument &doc) |
static std::string | writeXMLDocumentToString (const tinyxml2::XMLDocument &doc) |
Class for creating behavior trees according to the builder design pattern.
This class extends the functionality provided by BT::BehaviorTreeFactory of BehaviorTree.CPP and offers a user-friendly API for configuring behavior trees. In contrast to the original package, the user doesn't need to manually register behavior tree node entities with the factory in order to create an instance of BT::Tree. Instead, this class conveniently automates this process for you by querying the available ament_index
plugin resources implemented and registered by the developer. Additionally, this class allows for building custom XML definitions of trees programmatically.
Definition at line 40 of file tree_builder.hpp.
TreeBuilder | ( | std::shared_ptr< BT::BehaviorTreeFactory > | factory_ptr = std::make_shared<BT::BehaviorTreeFactory>() | ) |
Definition at line 24 of file tree_builder.cpp.
TreeBuilder & registerNodePlugins | ( | rclcpp::Node::SharedPtr | node_ptr, |
const NodeManifest & | node_manifest, | ||
NodePluginClassLoader & | tree_node_loader, | ||
bool | override = false ) |
Load behavior tree node plugins and register with behavior tree factory.
[in] | node_ptr | ROS2 node to pass to RosNodeContext. |
[in] | node_manifest | Parameters for locating and configuring the behavior tree node plugins. |
[in] | tree_node_loader | Reference to loader for behavior tree node plugin classes. |
[in] | override | If node_manifest specifies nodes that have already been registered, unregister the existing plugin and use the new one instead. |
exceptions::TreeBuildError | if registration fails. |
Definition at line 29 of file tree_builder.cpp.
TreeBuilder & registerNodePlugins | ( | rclcpp::Node::SharedPtr | node_ptr, |
const NodeManifest & | node_manifest, | ||
bool | override = false ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Creates a default behavior tree node plugin class loader.
Definition at line 100 of file tree_builder.cpp.
TreeBuilder & addTreeFromXMLDocument | ( | const tinyxml2::XMLDocument & | doc | ) |
Definition at line 107 of file tree_builder.cpp.
TreeBuilder & addTreeFromString | ( | const std::string & | tree_str | ) |
Definition at line 155 of file tree_builder.cpp.
TreeBuilder & addTreeFromFile | ( | const std::string & | tree_file_path | ) |
Definition at line 165 of file tree_builder.cpp.
TreeBuilder & addTreeFromResource | ( | const TreeResource & | resource, |
rclcpp::Node::SharedPtr | node_ptr ) |
Definition at line 175 of file tree_builder.cpp.
std::string getMainTreeName | ( | ) | const |
Definition at line 181 of file tree_builder.cpp.
TreeBuilder & setMainTreeName | ( | const std::string & | main_tree_name | ) |
Definition at line 188 of file tree_builder.cpp.
std::string writeTreeXMLToString | ( | ) | const |
Definition at line 195 of file tree_builder.cpp.
std::unordered_map< std::string, BT::NodeType > getRegisteredNodes | ( | ) |
Definition at line 200 of file tree_builder.cpp.
Tree buildTree | ( | const std::string | main_tree_name, |
TreeBlackboardSharedPtr | root_bb_ptr = TreeBlackboard::create() ) |
Definition at line 208 of file tree_builder.cpp.
Tree buildTree | ( | TreeBlackboardSharedPtr | root_bb_ptr = TreeBlackboard::create() | ) |
Definition at line 225 of file tree_builder.cpp.
|
static |
Definition at line 230 of file tree_builder.cpp.
|
static |
Definition at line 255 of file tree_builder.cpp.