Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef BEHAVIOR_TREE_H
00015 #define BEHAVIOR_TREE_H
00016
00017 #include "behaviortree_cpp/controls/parallel_node.h"
00018 #include "behaviortree_cpp/controls/fallback_node.h"
00019 #include "behaviortree_cpp/controls/sequence_node.h"
00020
00021 #include "behaviortree_cpp/controls/sequence_star_node.h"
00022 #include "behaviortree_cpp/controls/fallback_star_node.h"
00023
00024 #include "behaviortree_cpp/action_node.h"
00025 #include "behaviortree_cpp/condition_node.h"
00026
00027 #include "behaviortree_cpp/decorators/inverter_node.h"
00028 #include "behaviortree_cpp/decorators/retry_node.h"
00029 #include "behaviortree_cpp/decorators/repeat_node.h"
00030 #include "behaviortree_cpp/decorators/subtree_node.h"
00031
00032 #include "behaviortree_cpp/actions/always_success_node.h"
00033 #include "behaviortree_cpp/actions/always_failure_node.h"
00034 #include "behaviortree_cpp/actions/set_blackboard_node.h"
00035
00036 #include "behaviortree_cpp/decorators/force_success_node.h"
00037 #include "behaviortree_cpp/decorators/force_failure_node.h"
00038 #include "behaviortree_cpp/decorators/blackboard_precondition.h"
00039 #include "behaviortree_cpp/decorators/timeout_node.h"
00040
00041 namespace BT
00042 {
00043 void applyRecursiveVisitor(const TreeNode* root_node,
00044 const std::function<void(const TreeNode*)>& visitor);
00045
00046 void applyRecursiveVisitor(TreeNode* root_node, const std::function<void(TreeNode*)>& visitor);
00047
00051 void printTreeRecursively(const TreeNode* root_node);
00052
00053 void assignBlackboardToEntireTree(TreeNode* root_node, const Blackboard::Ptr& bb);
00054
00055 void haltAllActions(TreeNode* root_node);
00056
00057 typedef std::vector<std::pair<uint16_t, uint8_t>> SerializedTreeStatus;
00058
00067 void buildSerializedStatusSnapshot(const TreeNode* root_node,
00068 SerializedTreeStatus& serialized_buffer);
00069
00072 template <typename T>
00073 inline NodeType getType()
00074 {
00075
00076 if( std::is_base_of<ActionNodeBase, T>::value ) return NodeType::ACTION;
00077 if( std::is_base_of<ConditionNode, T>::value ) return NodeType::CONDITION;
00078 if( std::is_base_of<DecoratorSubtreeNode, T>::value ) return NodeType::SUBTREE;
00079 if( std::is_base_of<DecoratorNode, T>::value ) return NodeType::DECORATOR;
00080 if( std::is_base_of<ControlNode, T>::value ) return NodeType::CONTROL;
00081 return NodeType::UNDEFINED;
00082
00083 }
00084 }
00085
00086 #endif // BEHAVIOR_TREE_H