The BehaviorTreeFactory is used to create instances of a TreeNode at run-time. More...
#include <bt_factory.h>
Public Member Functions | |
BehaviorTreeFactory () | |
const std::unordered_map< std::string, NodeBuilder > & | builders () const |
All the builders. Made available mostly for debug purposes. More... | |
const std::set< std::string > & | builtinNodes () const |
List of builtin IDs. More... | |
Tree | createTreeFromFile (const std::string &file_path, Blackboard::Ptr blackboard=Blackboard::create()) |
Tree | createTreeFromText (const std::string &text, Blackboard::Ptr blackboard=Blackboard::create()) |
std::unique_ptr< TreeNode > | instantiateTreeNode (const std::string &name, const std::string &ID, const NodeConfiguration &config) const |
instantiateTreeNode creates an instance of a previously registered TreeNode. More... | |
const std::unordered_map< std::string, TreeNodeManifest > & | manifests () const |
Manifests of all the registered TreeNodes. More... | |
void | registerBuilder (const TreeNodeManifest &manifest, const NodeBuilder &builder) |
The most generic way to register your own builder. More... | |
template<typename T > | |
void | registerBuilder (const std::string &ID, const NodeBuilder &builder) |
void | registerFromPlugin (const std::string &file_path) |
registerFromPlugin load a shared library and execute the function BT_REGISTER_NODES (see macro). More... | |
void | registerFromROSPlugins () |
registerFromROSPlugins finds all shared libraries that export ROS plugins for behaviortree_cpp, and calls registerFromPlugin for each library. More... | |
template<typename T > | |
void | registerNodeType (const std::string &ID) |
template<typename T > | |
void | registerNodeType (const std::string &ID, PortsList ports) |
void | registerSimpleAction (const std::string &ID, const SimpleActionNode::TickFunctor &tick_functor, PortsList ports={}) |
registerSimpleAction help you register nodes of type SimpleActionNode. More... | |
void | registerSimpleCondition (const std::string &ID, const SimpleConditionNode::TickFunctor &tick_functor, PortsList ports={}) |
registerSimpleCondition help you register nodes of type SimpleConditionNode. More... | |
void | registerSimpleDecorator (const std::string &ID, const SimpleDecoratorNode::TickFunctor &tick_functor, PortsList ports={}) |
registerSimpleDecorator help you register nodes of type SimpleDecoratorNode. More... | |
bool | unregisterBuilder (const std::string &ID) |
Remove a registered ID. More... | |
Private Attributes | |
std::unordered_map< std::string, NodeBuilder > | builders_ |
std::set< std::string > | builtin_IDs_ |
std::unordered_map< std::string, TreeNodeManifest > | manifests_ |
The BehaviorTreeFactory is used to create instances of a TreeNode at run-time.
Some node types are "builtin", whilst other are used defined and need to be registered using a unique ID.
Definition at line 207 of file bt_factory.h.
BT::BehaviorTreeFactory::BehaviorTreeFactory | ( | ) |
Definition at line 24 of file bt_factory.cpp.
const std::unordered_map< std::string, NodeBuilder > & BT::BehaviorTreeFactory::builders | ( | ) | const |
All the builders. Made available mostly for debug purposes.
Definition at line 234 of file bt_factory.cpp.
const std::set< std::string > & BT::BehaviorTreeFactory::builtinNodes | ( | ) | const |
List of builtin IDs.
Definition at line 244 of file bt_factory.cpp.
Tree BT::BehaviorTreeFactory::createTreeFromFile | ( | const std::string & | file_path, |
Blackboard::Ptr | blackboard = Blackboard::create() |
||
) |
Definition at line 259 of file bt_factory.cpp.
Tree BT::BehaviorTreeFactory::createTreeFromText | ( | const std::string & | text, |
Blackboard::Ptr | blackboard = Blackboard::create() |
||
) |
Definition at line 249 of file bt_factory.cpp.
std::unique_ptr< TreeNode > BT::BehaviorTreeFactory::instantiateTreeNode | ( | const std::string & | name, |
const std::string & | ID, | ||
const NodeConfiguration & | config | ||
) | const |
instantiateTreeNode creates an instance of a previously registered TreeNode.
name | name of this particular instance |
ID | ID used when it was registered |
config | configuration that is passed to the constructor of the TreeNode. |
Definition at line 213 of file bt_factory.cpp.
const std::unordered_map< std::string, TreeNodeManifest > & BT::BehaviorTreeFactory::manifests | ( | ) | const |
Manifests of all the registered TreeNodes.
Definition at line 239 of file bt_factory.cpp.
void BT::BehaviorTreeFactory::registerBuilder | ( | const TreeNodeManifest & | manifest, |
const NodeBuilder & | builder | ||
) |
The most generic way to register your own builder.
Definition at line 87 of file bt_factory.cpp.
|
inline |
Definition at line 219 of file bt_factory.h.
void BT::BehaviorTreeFactory::registerFromPlugin | ( | const std::string & | file_path | ) |
registerFromPlugin load a shared library and execute the function BT_REGISTER_NODES (see macro).
file_path | path of the file |
Definition at line 135 of file bt_factory.cpp.
void BT::BehaviorTreeFactory::registerFromROSPlugins | ( | ) |
registerFromROSPlugins finds all shared libraries that export ROS plugins for behaviortree_cpp, and calls registerFromPlugin for each library.
If | not compiled with ROS support or if the library cannot load for any reason |
Definition at line 206 of file bt_factory.cpp.
|
inline |
registerNodeType is the method to use to register your custom TreeNode.
It accepts only classed derived from either ActionNodeBase, DecoratorNode, ControlNode or ConditionNode.
Definition at line 290 of file bt_factory.h.
|
inline |
Definition at line 327 of file bt_factory.h.
void BT::BehaviorTreeFactory::registerSimpleAction | ( | const std::string & | ID, |
const SimpleActionNode::TickFunctor & | tick_functor, | ||
PortsList | ports = {} |
||
) |
registerSimpleAction help you register nodes of type SimpleActionNode.
ID | registration ID |
tick_functor | the callback to be invoked in the tick() method. |
ports | if your SimpleNode requires ports, provide the list here. |
Definition at line 111 of file bt_factory.cpp.
void BT::BehaviorTreeFactory::registerSimpleCondition | ( | const std::string & | ID, |
const SimpleConditionNode::TickFunctor & | tick_functor, | ||
PortsList | ports = {} |
||
) |
registerSimpleCondition help you register nodes of type SimpleConditionNode.
ID | registration ID |
tick_functor | the callback to be invoked in the tick() method. |
ports | if your SimpleNode requires ports, provide the list here. |
Definition at line 99 of file bt_factory.cpp.
void BT::BehaviorTreeFactory::registerSimpleDecorator | ( | const std::string & | ID, |
const SimpleDecoratorNode::TickFunctor & | tick_functor, | ||
PortsList | ports = {} |
||
) |
registerSimpleDecorator help you register nodes of type SimpleDecoratorNode.
ID | registration ID |
tick_functor | the callback to be invoked in the tick() method. |
ports | if your SimpleNode requires ports, provide the list here. |
Definition at line 123 of file bt_factory.cpp.
bool BT::BehaviorTreeFactory::unregisterBuilder | ( | const std::string & | ID | ) |
Remove a registered ID.
Definition at line 71 of file bt_factory.cpp.
|
private |
Definition at line 378 of file bt_factory.h.
|
private |
Definition at line 380 of file bt_factory.h.
|
private |
Definition at line 379 of file bt_factory.h.