15#include "auto_apms_behavior_tree/build_handler.hpp"
16#include "auto_apms_behavior_tree_core/exceptions.hpp"
24 TreeFromStringBuildHandler(rclcpp::Node::SharedPtr ros_node_ptr, NodeLoader::SharedPtr tree_node_loader_ptr)
26 working_doc_(TreeDocument::BTCPP_FORMAT_DEFAULT_VERSION, tree_node_loader_ptr)
31 const std::string & build_request,
const NodeManifest & node_manifest,
32 const std::string & root_tree_name)
override final
35 working_doc_.reset().mergeString(build_request,
true);
36 working_doc_.registerNodes(node_manifest,
false);
38 if (
const BT::Result res = working_doc_.verify(); !res) {
39 RCLCPP_WARN(
logger_,
"Tree verification failed: %s", res.error().c_str());
44 if (root_tree_name.empty()) {
45 if (!working_doc_.hasRootTreeName()) {
48 "Cannot determine root tree: You must either encode the root tree within the tree XML or provide a non-empty "
49 "name using the root_tree_name argument.");
54 working_doc_.setRootTreeName(root_tree_name);
55 }
catch (
const exceptions::TreeDocumentError & e) {
56 RCLCPP_WARN(
logger_,
"Cannot determine root tree: %s", e.what());
66 doc.mergeTreeDocument(working_doc_,
true);
72 return doc.getRootTree();
76 core::TreeDocument working_doc_;
Base class for plugins that implement patterns for creating behavior trees using a standardized inter...
TreeBuildHandler(const std::string &name, rclcpp::Node::SharedPtr ros_node_ptr, NodeLoader::SharedPtr tree_node_loader_ptr)
Constructor allowing to give the build handler a specific name.
const rclcpp::Logger logger_
ROS 2 logger initialized with the name of the build handler.
Handle for a single behavior tree of a TreeDocument.
#define AUTO_APMS_BEHAVIOR_TREE_DECLARE_BUILD_HANDLER(type)
Macro for registering a behavior tree build handler plugin which may be loaded at runtime to build a ...
Useful tooling for incorporating behavior trees for task development.