AutoAPMS
Resilient Robot Mission Management
Loading...
Searching...
No Matches
node_model_type.cpp
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#include "auto_apms_behavior_tree_core/node/node_model_type.hpp"
16
17#include "auto_apms_behavior_tree_core/builder.hpp"
18#include "auto_apms_behavior_tree_core/exceptions.hpp"
19#include "behaviortree_cpp/tree_node.h"
20
22{
23namespace core
24{
25
26TreeDocument::NodeElement NodeModelType::toNodeElement() { return NodeElement(*this); }
27
28} // namespace core
29
30namespace model
31{
32
33BT::NodeType SubTree::type() { return BT::NodeType::SUBTREE; }
34
35std::string SubTree::name() { return core::TreeDocument::SUBTREE_ELEMENT_NAME; }
36
37std::string SubTree::getRegistrationName() const { return name(); }
38
39SubTree & SubTree::setBlackboardRemapping(const PortValues & remapping)
40{
41 for (const auto & [key, val] : remapping) {
42 if (!BT::TreeNode::isBlackboardPointer(val)) {
43 throw exceptions::TreeDocumentError(
44 "When setting the blackboard remapping for a subtree, you must refer to the parent blackboard's entry to remap "
45 "to using curly brackets (Got: '" +
46 val + "').");
47 }
48 ele_ptr_->SetAttribute(key.c_str(), val.c_str());
49 }
50 return *this;
51}
52
53SubTree & SubTree::set_auto_remap(bool val) { return setPorts({{"_autoremap", BT::toStr(val)}}); }
54
55bool SubTree::get_auto_remap() const { return BT::convertFromString<bool>(getPorts().at("_autoremap")); }
56
57} // namespace model
58} // namespace auto_apms_behavior_tree
Handle for a single node of a TreeDocument.
Subtree behavior tree node model.
SubTree & setBlackboardRemapping(const PortValues &remapping)
Configure which blackboard entries of the subtree node's parent tree should be also available for the...
static BT::NodeType type()
Type of the behavior tree node.
bool get_auto_remap() const
Get automatic blackboard remapping.
std::string getRegistrationName() const override final
Get the type specific name under which all subtree nodes are registered with the behavior tree factor...
SubTree & set_auto_remap(bool val=false)
Set automatic blackboard remapping.
static std::string name()
Static method that provides the hard coded registration name of subtree nodes.
Core API for AutoAPMS's behavior tree implementation.
Definition builder.hpp:30
Models for all available behavior tree nodes.
Useful tooling for incorporating behavior trees for task development.
Definition builder.hpp:30