AutoAPMS
Resilient Robot Mission Management
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Modules Pages
SubTree Class Reference

Subtree behavior tree node model. More...

#include <auto_apms_behavior_tree_core/node/node_model_type.hpp>

Inheritance diagram for SubTree:

Public Member Functions

std::string getRegistrationName () const override final
 Get the type specific name under which all subtree nodes are registered with the behavior tree factory.
 
SubTreesetBlackboardRemapping (const PortValues &remapping)
 Configure which blackboard entries of the subtree node's parent tree should be also available for the children of the tree this subtree node is pointing to.
 
SubTreeset_auto_remap (bool val=false)
 Set automatic blackboard remapping.
 
bool get_auto_remap () const
 Get automatic blackboard remapping.
 
- Public Member Functions inherited from NodeModelType
NodeElement toNodeElement ()
 Convert to a lower level NodeElement object.
 
- Public Member Functions inherited from TreeDocument::NodeElement
 NodeElement (const NodeElement &ele)=default
 Copy constructor for a node element.
 
NodeElementoperator= (const NodeElement &other)
 Replace this node with another.
 
bool operator== (const NodeElement &other) const
 Determine if two node elements refer to the same node.
 
NodeElement insertNode (const std::string &name, const NodeElement *before_this=nullptr)
 Add a new node to the children of this node.
 
NodeElement insertNode (const std::string &name, const NodeRegistrationOptions &registration_options, const NodeElement *before_this=nullptr)
 Register a new node and add it to the children of this node.
 
template<class T>
std::enable_if_t< std::is_base_of_v< NodeModelType, T > &&!std::is_same_v< model::SubTree, T >, T > insertNode (const NodeElement *before_this=nullptr)
 Register a new node and add it to the children of this node.
 
template<class SubTreeT>
std::enable_if_t< std::is_same_v< model::SubTree, SubTreeT >, model::SubTreeinsertNode (const std::string &tree_name, const NodeElement *before_this=nullptr)
 Add a subtree node for a specific tree element to the children of this node.
 
template<class SubTreeT>
std::enable_if_t< std::is_same_v< model::SubTree, SubTreeT >, model::SubTreeinsertNode (const TreeElement &tree, const NodeElement *before_this=nullptr)
 Add a subtree node for a specific tree element to the children of this node.
 
model::SubTree insertSubTreeNode (const std::string &tree_name, const NodeElement *before_this=nullptr)
 Add a subtree node for a specific tree element to the children of this node.
 
model::SubTree insertSubTreeNode (const TreeElement &tree, const NodeElement *before_this=nullptr)
 Add a subtree node for a specific tree element to the children of this node.
 
NodeElement insertTree (const TreeElement &tree, const NodeElement *before_this=nullptr)
 Concatenate a tree and add its first child node to the children of this node.
 
NodeElement insertTreeFromDocument (const TreeDocument &doc, const std::string &tree_name, const NodeElement *before_this=nullptr)
 Concatenate a tree from a document and add its first child node to the children of this node.
 
NodeElement insertTreeFromDocument (const TreeDocument &doc, const NodeElement *before_this=nullptr)
 Concatenate the root tree of a document and add its first child node to the children of this node.
 
NodeElement insertTreeFromString (const std::string &tree_str, const std::string &tree_name, const NodeElement *before_this=nullptr)
 Concatenate a tree from a document created from a string and add its first child node to the children of this node.
 
NodeElement insertTreeFromString (const std::string &tree_str, const NodeElement *before_this=nullptr)
 Concatenate the root tree of a document created from a string and add its first child node to the children of this node.
 
NodeElement insertTreeFromFile (const std::string &path, const std::string &tree_name, const NodeElement *before_this=nullptr)
 Concatenate a tree from a document created from a file and add its first child node to the children of this node.
 
NodeElement insertTreeFromFile (const std::string &path, const NodeElement *before_this=nullptr)
 Concatenate the root tree of a document created from a file and add its first child node to the children of this node.
 
NodeElement insertTreeFromResource (const TreeResource &resource, const std::string &tree_name, const NodeElement *before_this=nullptr)
 Concatenate a tree from one of the installed package's behavior tree resources and add its first child node to the children of this node.
 
NodeElement insertTreeFromResource (const TreeResource &resource, const NodeElement *before_this=nullptr)
 Concatenate the root tree of one of the installed package's behavior tree resources and add its first child node to the children of this node.
 
bool hasChildren () const
 Determine whether any children have been given to this node.
 
NodeElement getFirstNode (const std::string &registration_name="", const std::string &instance_name="") const
 Recursively visit this node's children in execution order and get the first node with a particular registration and instance name.
 
template<class T>
std::enable_if_t< std::is_base_of_v< NodeModelType, T >, T > getFirstNode (const std::string &instance_name="") const
 Recursively visit this node's children in execution order and get the first node with a particular instance name.
 
NodeElementremoveFirstChild (const std::string &registration_name="", const std::string &instance_name="")
 Recursively visit this node's children in execution order and remove the first node with a particular registration and instance name.
 
template<class T>
std::enable_if_t< std::is_base_of_v< NodeModelType, T >, NodeElement & > removeFirstChild (const std::string &instance_name="")
 Recursively visit this node's children in execution order and remove the first node with a particular instance name.
 
NodeElementremoveChildren ()
 Recursively remove all children of this node element.
 
const std::vector< std::string > & getPortNames () const
 Get the names of the data ports implemented by the node represented by this element.
 
PortValues getPorts () const
 Assemble the values given to each data port implemented by this node.
 
NodeElementsetPorts (const PortValues &port_values)
 Populate the the node's data ports.
 
NodeElementresetPorts ()
 Delete all currently specified port values and reset with the defaults.
 
NodeElementsetConditionalScript (BT::PreCond type, const Script &script)
 Specify a script that is evaluated before this node is ticked.
 
NodeElementsetConditionalScript (BT::PostCond type, const Script &script)
 Specify a script that is evaluated after the tree is done executing this node.
 
virtual NodeElementsetName (const std::string &instance_name)
 Assign a name for this specific node instance.
 
virtual std::string getName () const
 Get the name of this node given to this specific instance by the developer.
 
std::string getFullyQualifiedName () const
 Create a string that uniquely identifies this node considering its registration and its instance name.
 
const TreeDocumentgetParentDocument () const
 Get a const view of this node's parent tree document.
 
const std::vector< NodeElementdeepApplyConst (ConstDeepApplyCallback apply_callback) const
 Recursively apply a callback to this node's children.
 
std::vector< NodeElementdeepApply (DeepApplyCallback apply_callback)
 Recursively apply a callback to this node's children.
 

Static Public Member Functions

static std::string name ()
 Static method that provides the hard coded registration name of subtree nodes.
 
static BT::NodeType type ()
 Type of the behavior tree node.
 

Additional Inherited Members

- Public Types inherited from TreeDocument::NodeElement
using PortValues = std::map<std::string, std::string>
 Mapping of port names and its respective value encoded as string.
 
using DeepApplyCallback = std::function<bool(NodeElement &)>
 Callback invoked for every node found under another node. It may modify the current node.
 
using ConstDeepApplyCallback = std::function<bool(const NodeElement &)>
 Callback invoked for every node found under another node. It cannot modify the current node.
 
- Protected Member Functions inherited from TreeDocument::NodeElement
 NodeElement (TreeDocument *doc_ptr, XMLElement *ele_ptr)
 Protected constructor intended for internal use only.
 
- Protected Attributes inherited from TreeDocument::NodeElement
TreeDocumentdoc_ptr_
 Pointer to the tree document that created the tree this node belongs to.
 
tinyxml2::XMLElement * ele_ptr_
 Pointer to the corresponding XMLElement of the base document.
 

Detailed Description

Subtree behavior tree node model.

This model implements extra methods specific to the subtree concept.

Definition at line 161 of file node_model_type.hpp.

Member Function Documentation

◆ name()

std::string name ( )
static

Static method that provides the hard coded registration name of subtree nodes.

Definition at line 35 of file node_model_type.cpp.

◆ type()

BT::NodeType type ( )
static

Type of the behavior tree node.

Definition at line 33 of file node_model_type.cpp.

◆ getRegistrationName()

std::string getRegistrationName ( ) const
finaloverridevirtual

Get the type specific name under which all subtree nodes are registered with the behavior tree factory.

Returns
Registration name of a subtree node.

Implements NodeModelType.

Definition at line 37 of file node_model_type.cpp.

◆ setBlackboardRemapping()

SubTree & setBlackboardRemapping ( const PortValues & remapping)

Configure which blackboard entries of the subtree node's parent tree should be also available for the children of the tree this subtree node is pointing to.

Parameters
remappingMapping of blackboard entry names in the format {subtree_entry_name: original_tree_entry_name}
Returns
Modified subtree model.

Definition at line 39 of file node_model_type.cpp.

◆ set_auto_remap()

SubTree & set_auto_remap ( bool val = false)

Set automatic blackboard remapping.

Parameters
valtrue to enable and false to disable.
Returns
Modified subtree model.

Definition at line 53 of file node_model_type.cpp.

◆ get_auto_remap()

bool get_auto_remap ( ) const

Get automatic blackboard remapping.

Returns
Boolean flag for the currently configured option.

Definition at line 55 of file node_model_type.cpp.


The documentation for this class was generated from the following files: