16 #ifndef NAV2_BEHAVIOR_TREE__BEHAVIOR_TREE_ENGINE_HPP_
17 #define NAV2_BEHAVIOR_TREE__BEHAVIOR_TREE_ENGINE_HPP_
23 #include "behaviortree_cpp/behavior_tree.h"
24 #include "behaviortree_cpp/bt_factory.h"
25 #include "behaviortree_cpp/xml_parsing.h"
27 #include "rclcpp/rclcpp.hpp"
29 namespace nav2_behavior_tree
36 enum class BtStatus { SUCCEEDED, FAILED, CANCELED };
50 const std::vector<std::string> & plugin_libraries,
51 rclcpp::Node::SharedPtr node);
64 std::function<
void()> onLoop,
65 std::function<
bool()> cancelRequested,
66 std::chrono::milliseconds loopTimeout = std::chrono::milliseconds(10));
75 const std::string & xml_string,
76 BT::Blackboard::Ptr blackboard);
85 const std::string & file_path,
86 BT::Blackboard::Ptr blackboard);
96 BT::BehaviorTreeFactory factory_;
99 rclcpp::Clock::SharedPtr clock_;
A class to create and handle behavior trees.
BehaviorTreeEngine(const std::vector< std::string > &plugin_libraries, rclcpp::Node::SharedPtr node)
A constructor for nav2_behavior_tree::BehaviorTreeEngine.
BT::Tree createTreeFromFile(const std::string &file_path, BT::Blackboard::Ptr blackboard)
Function to create a BT from an XML file.
BT::Tree createTreeFromText(const std::string &xml_string, BT::Blackboard::Ptr blackboard)
Function to create a BT from a XML string.
void haltAllActions(BT::Tree &tree)
Function to explicitly reset all BT nodes to initial state.
BtStatus run(BT::Tree *tree, std::function< void()> onLoop, std::function< bool()> cancelRequested, std::chrono::milliseconds loopTimeout=std::chrono::milliseconds(10))
Function to execute a BT at a specific rate.