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/loggers/groot2_publisher.h"
26 #include "behaviortree_cpp/xml_parsing.h"
28 #include "nav2_ros_common/lifecycle_node.hpp"
30 namespace nav2_behavior_tree
37 enum class BtStatus { SUCCEEDED, FAILED, CANCELED };
51 const std::vector<std::string> & plugin_libraries,
52 nav2::LifecycleNode::SharedPtr node);
65 std::function<
void()> onLoop,
66 std::function<
bool()> cancelRequested,
67 std::chrono::milliseconds loopTimeout = std::chrono::milliseconds(10));
76 const std::string & xml_string,
77 BT::Blackboard::Ptr blackboard);
86 const std::string & file_path,
87 BT::Blackboard::Ptr blackboard);
109 BT::BehaviorTreeFactory factory_;
112 rclcpp::Clock::SharedPtr clock_;
115 std::unique_ptr<BT::Groot2Publisher> groot_monitor_;
A class to create and handle behavior trees.
BehaviorTreeEngine(const std::vector< std::string > &plugin_libraries, nav2::LifecycleNode::SharedPtr node)
A constructor for nav2_behavior_tree::BehaviorTreeEngine.
void addGrootMonitoring(BT::Tree *tree, uint16_t server_port)
Add Groot2 monitor to publish BT status changes.
void resetGrootMonitor()
Reset groot monitor.
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.