behavior_tree.h
Go to the documentation of this file.
00001 /* Copyright (C) 2015-2018 Michele Colledanchise -  All Rights Reserved
00002  * Copyright (C) 2018 Davide Faconti -  All Rights Reserved
00003 *
00004 *   Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
00005 *   to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
00006 *   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:
00007 *   The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
00008 *
00009 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00010 *   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,
00011 *   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.
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     // clang-format off
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     // clang-format on
00083 }
00084 }
00085 
00086 #endif   // BEHAVIOR_TREE_H


behaviortree_cpp
Author(s): Michele Colledanchise, Davide Faconti
autogenerated on Sat Feb 2 2019 03:50:09