behavior_tree.h
Go to the documentation of this file.
1 /* Copyright (C) 2015-2018 Michele Colledanchise - All Rights Reserved
2  * Copyright (C) 2018 Davide Faconti - All Rights Reserved
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
6 * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
10 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
11 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12 */
13 
14 #ifndef BEHAVIOR_TREE_H
15 #define BEHAVIOR_TREE_H
16 
20 
23 
26 
31 
35 
40 
41 namespace BT
42 {
43 void applyRecursiveVisitor(const TreeNode* root_node,
44  const std::function<void(const TreeNode*)>& visitor);
45 
46 void applyRecursiveVisitor(TreeNode* root_node, const std::function<void(TreeNode*)>& visitor);
47 
51 void printTreeRecursively(const TreeNode* root_node);
52 
53 void assignBlackboardToEntireTree(TreeNode* root_node, const Blackboard::Ptr& bb);
54 
55 void haltAllActions(TreeNode* root_node);
56 
57 typedef std::vector<std::pair<uint16_t, uint8_t>> SerializedTreeStatus;
58 
67 void buildSerializedStatusSnapshot(const TreeNode* root_node,
68  SerializedTreeStatus& serialized_buffer);
69 
72 template <typename T>
73 inline NodeType getType()
74 {
75  // clang-format off
76  if( std::is_base_of<ActionNodeBase, T>::value ) return NodeType::ACTION;
77  if( std::is_base_of<ConditionNode, T>::value ) return NodeType::CONDITION;
78  if( std::is_base_of<DecoratorSubtreeNode, T>::value ) return NodeType::SUBTREE;
79  if( std::is_base_of<DecoratorNode, T>::value ) return NodeType::DECORATOR;
80  if( std::is_base_of<ControlNode, T>::value ) return NodeType::CONTROL;
81  return NodeType::UNDEFINED;
82  // clang-format on
83 }
84 }
85 
86 #endif // BEHAVIOR_TREE_H
void printTreeRecursively(const TreeNode *root_node)
std::shared_ptr< Blackboard > Ptr
Definition: blackboard.h:40
std::vector< std::pair< uint16_t, uint8_t > > SerializedTreeStatus
Definition: behavior_tree.h:57
void haltAllActions(TreeNode *root_node)
void assignBlackboardToEntireTree(TreeNode *root_node, const Blackboard::Ptr &bb)
NodeType getType()
Definition: behavior_tree.h:73
void buildSerializedStatusSnapshot(const TreeNode *root_node, SerializedTreeStatus &serialized_buffer)
buildSerializedStatusSnapshot can be used to create a serialize buffer that can be stored (or sent to...
NodeType
Definition: basic_types.h:16
void applyRecursiveVisitor(const TreeNode *root_node, const std::function< void(const TreeNode *)> &visitor)


behaviortree_cpp
Author(s): Michele Colledanchise, Davide Faconti
autogenerated on Sun Feb 3 2019 03:14:32