21 registerNodeType<FallbackNode>(
"Fallback");
22 registerNodeType<SequenceNode>(
"Sequence");
23 registerNodeType<SequenceStarNode>(
"SequenceStar");
24 registerNodeType<ParallelNode>(
"Parallel");
25 registerNodeType<ReactiveSequence>(
"ReactiveSequence");
26 registerNodeType<ReactiveFallback>(
"ReactiveFallback");
28 registerNodeType<InverterNode>(
"Inverter");
29 registerNodeType<RetryNode>(
"RetryUntilSuccesful");
30 registerNodeType<RepeatNode>(
"Repeat");
31 registerNodeType<TimeoutNode>(
"Timeout");
33 registerNodeType<ForceSuccessNode>(
"ForceSuccess");
34 registerNodeType<ForceFailureNode>(
"ForceFailure");
36 registerNodeType<AlwaysSuccessNode>(
"AlwaysSuccess");
37 registerNodeType<AlwaysFailureNode>(
"AlwaysFailure");
38 registerNodeType<SetBlackboard>(
"SetBlackboard");
40 registerNodeType<DecoratorSubtreeNode>(
"SubTree");
42 registerNodeType<BlackboardPreconditionNode<int>>(
"BlackboardCheckInt");
43 registerNodeType<BlackboardPreconditionNode<double>>(
"BlackboardCheckDouble");
44 registerNodeType<BlackboardPreconditionNode<std::string>>(
"BlackboardCheckString");
56 throw LogicError(
"You can not remove the builtin registration ID [", ID,
"]");
85 return std::make_unique<SimpleConditionNode>(name, tick_functor, config);
97 return std::make_unique<SimpleActionNode>(name, tick_functor, config);
109 return std::make_unique<SimpleDecoratorNode>(name, tick_functor, config);
119 loader.
load(file_path);
129 std::cout <<
"ERROR loading library [" << file_path <<
"]: can't find symbol [" 135 const std::string& name,
136 const std::string& ID,
142 std::cerr << ID <<
" not included in this list:" << std::endl;
145 std::cerr << builder_it.first << std::endl;
147 throw RuntimeError(
"BehaviorTreeFactory: ID [", ID,
"] not registered");
150 std::unique_ptr<TreeNode> node = it->second(name, config);
151 node->setRegistrationID( ID );
199 if( blackboard_stack.size() > 0)
201 return blackboard_stack.front();
constexpr const char * PLUGIN_SYMBOL
std::function< NodeStatus(NodeStatus, TreeNode &)> TickFunctor
std::function< std::unique_ptr< TreeNode >const std::string &, const NodeConfiguration &)> NodeBuilder
The term "Builder" refers to the Builder Pattern (https://en.wikipedia.org/wiki/Builder_pattern) ...
std::unordered_map< std::string, NodeBuilder > builders_
std::set< std::string > builtin_IDs_
std::shared_ptr< Blackboard > Ptr
const std::set< std::string > & builtinNodes() const
List of builtin IDs.
This information is used mostly by the XMLParser.
const std::unordered_map< std::string, NodeBuilder > & builders() const
All the builders. Made available mostly for debug purposes.
std::unordered_map< std::string, TreeNodeManifest > manifests_
bool hasSymbol(const std::string &name)
Returns true iff a library has been loaded.
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.
void haltAllActions(TreeNode *root_node)
The BehaviorTreeFactory is used to create instances of a TreeNode at run-time.
void * getSymbol(const std::string &name)
std::string registration_ID
Tree createTreeFromText(const std::string &text, Blackboard::Ptr blackboard=Blackboard::create())
void registerFromPlugin(const std::string &file_path)
registerFromPlugin load a shared library and execute the function BT_REGISTER_NODES (see macro)...
Tree instantiateTree(const Blackboard::Ptr &root_blackboard) override
void registerSimpleAction(const std::string &ID, const SimpleActionNode::TickFunctor &tick_functor, PortsList ports={})
registerSimpleAction help you register nodes of type SimpleActionNode.
std::function< NodeStatus(TreeNode &)> TickFunctor
void load(const std::string &path, int flags=0)
std::unordered_map< std::string, PortInfo > PortsList
static volatile int count
const std::unordered_map< std::string, TreeNodeManifest > & manifests() const
Manifests of all the registered TreeNodes.
The XMLParser is a class used to read the model of a BehaviorTree from file or text and instantiate t...
void loadFromText(const std::string &xml_text) override
void registerBuilder(const TreeNodeManifest &manifest, const NodeBuilder &builder)
The most generic way to register your own builder.
Struct used to store a tree. If this object goes out of scope, the tree is destroyed.
std::unordered_map< std::string, TreeNodeManifest > manifests
bool unregisterBuilder(const std::string &ID)
Remove a registered ID.
void loadFromFile(const std::string &filename) override
Tree createTreeFromFile(const std::string &file_path, Blackboard::Ptr blackboard=Blackboard::create())
void registerSimpleDecorator(const std::string &ID, const SimpleDecoratorNode::TickFunctor &tick_functor, PortsList ports={})
registerSimpleDecorator help you register nodes of type SimpleDecoratorNode.
void registerSimpleCondition(const std::string &ID, const SimpleConditionNode::TickFunctor &tick_functor, PortsList ports={})
registerSimpleCondition help you register nodes of type SimpleConditionNode.
std::function< NodeStatus(TreeNode &)> TickFunctor
Blackboard::Ptr rootBlackboard()