AutoAPMS
Resilient Robot Mission Management
Loading...
Searching...
No Matches
builder.hpp
1// Copyright 2024 Robin Müller
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <memory>
18
19#include "auto_apms_behavior_tree_core/definitions.hpp"
20#include "auto_apms_behavior_tree_core/node/node_manifest.hpp"
21#include "auto_apms_behavior_tree_core/node/node_registration_loader.hpp"
22#include "auto_apms_behavior_tree_core/tree/tree_document.hpp"
23#include "auto_apms_behavior_tree_core/tree/tree_resource.hpp"
24#include "rclcpp/rclcpp.hpp"
25
30{
31
55{
56 inline static const std::string LOGGER_NAME = "tree_builder";
57
58public:
59 RCLCPP_SMART_PTR_DEFINITIONS(TreeBuilder)
60
61
75 explicit TreeBuilder(
76 rclcpp::Node::SharedPtr ros_node, rclcpp::CallbackGroup::SharedPtr tree_node_waitables_callback_group,
77 rclcpp::executors::SingleThreadedExecutor::SharedPtr tree_node_waitables_executor,
78 NodeRegistrationLoader::SharedPtr tree_node_loader = NodeRegistrationLoader::make_shared());
79
88 explicit TreeBuilder(NodeRegistrationLoader::SharedPtr tree_node_loader = NodeRegistrationLoader::make_shared());
89
90 virtual ~TreeBuilder() override = default;
91
93 TreeBuilder & registerNodes(const NodeManifest & tree_node_manifest, bool override = false) override;
94
101 TreeBuilder & setScriptingEnum(const std::string & enum_name, int val);
102
114 template <typename EnumT>
116
128 Tree instantiate(const std::string & root_tree_name, TreeBlackboardSharedPtr bb_ptr = TreeBlackboard::create());
129
141 Tree instantiate(TreeBlackboardSharedPtr bb_ptr = TreeBlackboard::create());
142};
143
144// #####################################################################################################################
145// ################################ DEFINITIONS ##############################################
146// #####################################################################################################################
147
148template <typename EnumT>
150{
151 factory_.registerScriptingEnums<EnumT>();
152 return *this;
153}
154
155} // namespace auto_apms_behavior_tree::core
Data structure for information about which behavior tree node plugin to load and how to configure the...
TreeBuilder(rclcpp::Node::SharedPtr ros_node, rclcpp::CallbackGroup::SharedPtr tree_node_waitables_callback_group, rclcpp::executors::SingleThreadedExecutor::SharedPtr tree_node_waitables_executor, NodeRegistrationLoader::SharedPtr tree_node_loader=NodeRegistrationLoader::make_shared())
Constructor.
Definition builder.cpp:25
TreeBuilder & setScriptingEnum(const std::string &enum_name, int val)
Define enums that may be used by any scripts inside the behavior tree.
Definition builder.cpp:64
Tree instantiate(const std::string &root_tree_name, TreeBlackboardSharedPtr bb_ptr=TreeBlackboard::create())
Create the behavior tree.
Definition builder.cpp:70
TreeBuilder & setScriptingEnumsFromType()
Define enums that may be used by any scripts inside the behavior tree.
Definition builder.hpp:149
TreeBuilder & registerNodes(const NodeManifest &tree_node_manifest, bool override=false) override
Load behavior tree node plugins and register them with the internal behavior tree factory.
Definition builder.cpp:46
TreeDocument(const std::string &format_version=BTCPP_FORMAT_DEFAULT_VERSION, NodeRegistrationLoader::SharedPtr tree_node_loader=NodeRegistrationLoader::make_shared())
Create a an empty tree document.
Core API for AutoAPMS's behavior tree implementation.
Definition builder.hpp:30