![]() |
AutoAPMS
Streamlining behaviors in ROS 2
|
Class containing behavior tree resource data. More...
#include <auto_apms_behavior_tree_core/tree/tree_resource.hpp>

Public Member Functions | |
| TreeResource (const TreeResourceIdentity &search_identity) | |
| Assemble a behavior tree resource using a TreeResourceIdentity. | |
| TreeResource (const std::string &search_identity) | |
| Assemble a behavior tree resource identified by a string. | |
| TreeResource (const char *search_identity) | |
| Assemble a behavior tree resource identified by a string. | |
| bool | hasRootTreeName () const |
| Determine if this behavior tree resource specifies a root tree. | |
| std::string | getRootTreeName () const |
| Get the name of the root tree of this behavior tree resource. | |
| TreeResourceIdentity | createIdentityForTree (const std::string &tree_name="") const |
| Create a valid identity string for a specific behavior tree of this resource. | |
Public Member Functions inherited from BehaviorResourceTemplate< TreeResourceIdentity > | |
| BehaviorResourceTemplate (const Identity &search_identity) | |
| Assemble a behavior resource using a BehaviorResourceIdentity. | |
| BehaviorResourceTemplate (const std::string &search_identity) | |
| Assemble a behavior resource identified by a string. | |
| BehaviorResourceTemplate (const char *search_identity) | |
| Assemble a behavior tree resource identified by a string. | |
| const Identity & | getIdentity () const |
| Get the unique identity for this resource. | |
| const std::string & | getBuildRequest () const |
| Get the behavior build request associated with this resource. | |
| const std::string & | getDefaultBuildHandlerName () const |
| Get the fully qualified class name of the default build handler associated with this behavior resource. | |
| const std::string & | getEntrypoint () const |
| Get the entrypoint of this behavior resource. | |
| const NodeManifest & | getNodeManifest () const |
| Get the node manifest associated with this resource. | |
Static Public Member Functions | |
| static TreeResource | findByTreeName (const std::string &tree_name, const std::string &package_name="") |
| Find an installed behavior tree resource using a specific behavior tree name. | |
| static TreeResource | findByFileStem (const std::string &file_stem, const std::string &package_name="") |
| Find an installed behavior tree resource using a specific behavior tree XML file stem. | |
Static Public Member Functions inherited from BehaviorResourceTemplate< TreeResourceIdentity > | |
| static BehaviorResourceTemplate | find (const std::string &behavior_alias, const std::string &package_name="", const std::string &category_name="") |
| Find an installed behavior resource using a specific behavior tree name. | |
Class containing behavior tree resource data.
Behavior tree resources are registered by calling the CMake macro auto_apms_behavior_tree_register_trees in the CMakeLists.txt of a package. They can be discovered once the corresponding package has been installed to the ROS 2 workspace.
auto_apms_behavior_tree_register_trees replaces auto_apms_behavior_tree_register_behavior when registering behavior trees and the user should only invoke the former. Registering the corresponding behavior resource information is handled fully automatically for tree resources.The user may refer to a specific resource using an identity string that may contain the tokens <package_name>, <tree_file_stem> and <tree_name> separated by :: in that order. Depending on the number of registered resources, it might be convenient to use shorter, less precise signatures. Additionally, if the delimiter :: is not present, the string is assumed to be the stem of a behavior tree file <tree_file_stem>. All possible identity strings are listed below:
<package_name>::<tree_file_stem>::<tree_name>
Fully qualified identity string of a specific behavior tree.
::<tree_file_stem>::<tree_name>
Try to find the resource by searching for a tree with name <tree_name> in a file with stem <tree_file_stem> considering all packages.
<package_name>::::<tree_name>
Try to find a tree with name <tree_name> within the resources registered by <package_name>.
::::<tree_name>
Try to find the resource by searching for a tree with name <tree_name> considering all packages.
<package_name>::<tree_file_stem>::
Try to find a file with stem <tree_file_stem> within the resources registered by <package_name>.
::<tree_file_stem>:: or <tree_file_stem>
Try to find the resource by searching for a file with stem <tree_file_stem> considering all packages. Here you may conveniently omit the :: delimiter, since this is the most common way for searching for a resource.
:: must be kept when tokens are omitted, except when searching for resources using only the file stem.Given the user has specified a behavior tree named MyBehaviorTree inside the XML file behavior/my_tree_file.xml, the CMake macro auto_apms_behavior_tree_register_trees must be called in the CMakeLists.txt of the parent package (for example my_package) like this:
The macro automatically parses the given files and detects the names of the trees inside. In the C++ source code, one may use this resource, after the parent package my_package has been installed, like this:
Definition at line 155 of file tree_resource.hpp.
| TreeResource | ( | const TreeResourceIdentity & | search_identity | ) |
Assemble a behavior tree resource using a TreeResourceIdentity.
| search_identity | Tree resource identity object used for searching the corresponding resource. |
| auto_apms_util::exceptions::ResourceError | if the resource cannot be found using the given identity. |
Definition at line 55 of file tree_resource.cpp.
| TreeResource | ( | const std::string & | search_identity | ) |
Assemble a behavior tree resource identified by a string.
search_identity must be formatted like <package_name>::<tree_file_stem>::<tree_name>.
| search_identity | Tree resource identity string used for searching the corresponding resource. |
| auto_apms_util::exceptions::ResourceIdentityFormatError | if the identity string has wrong format. |
| auto_apms_util::exceptions::ResourceError | if the resource cannot be found using the given identity string. |
Definition at line 96 of file tree_resource.cpp.
| TreeResource | ( | const char * | search_identity | ) |
Assemble a behavior tree resource identified by a string.
search_identity must be formatted like <package_name>::<tree_file_stem>::<tree_name>.
| search_identity | C-style tree resource identity string used for searching the corresponding resource. |
| auto_apms_util::exceptions::ResourceIdentityFormatError | if the identity string has wrong format. |
| auto_apms_util::exceptions::ResourceError | if the resource cannot be found using the given identity string. |
Definition at line 98 of file tree_resource.cpp.
|
static |
Find an installed behavior tree resource using a specific behavior tree name.
This factory method acts equivalently to passing an identity string formatted like <package_name>::::<tree_name> to the constructor.
| tree_name | Name of the desired behavior tree. |
| package_name | Optional package name provided to narrow down the search. If empty, search in all installed packages. |
| auto_apms_util::exceptions::ResourceError | if the corresponding behavior tree cannot be found using the given arguments. |
Definition at line 100 of file tree_resource.cpp.
|
static |
Find an installed behavior tree resource using a specific behavior tree XML file stem.
This factory method acts equivalently to passing an identity string formatted like <package_name>::<tree_file_stem>:: to the constructor.
| file_stem | Stem of the desired behavior tree file (the stem of a file is the file name without the extension). |
| package_name | Optional package name provided to narrow down the search. If empty, search in all installed packages. |
| auto_apms_util::exceptions::ResourceError | if the corresponding behavior tree cannot be found using the given arguments. |
Definition at line 107 of file tree_resource.cpp.
| bool hasRootTreeName | ( | ) | const |
Determine if this behavior tree resource specifies a root tree.
The name of the root tree is determined as follows:
<tree_name> token was present in the resource identity when this instance was created, this is considered the root tree name.true if the root tree of this resource can be determined, false otherwise. Definition at line 114 of file tree_resource.cpp.
| std::string getRootTreeName | ( | ) | const |
Get the name of the root tree of this behavior tree resource.
The name of the root tree is determined as follows:
<tree_name> token was present in the resource identity when this instance was created, this is considered the root tree name.| auto_apms_util::exceptions::ResourceError | if the name of the root tree cannot be determined. |
Definition at line 119 of file tree_resource.cpp.
| TreeResourceIdentity createIdentityForTree | ( | const std::string & | tree_name = "" | ) | const |
Create a valid identity string for a specific behavior tree of this resource.
| tree_name | Name of one of the trees inside this resource's tree document. If empty, do not refer to a specific behavior tree (identity won't be fully qualified). |
Definition at line 133 of file tree_resource.cpp.