AutoAPMS
Streamlining behaviors in ROS 2
Loading...
Searching...
No Matches
BehaviorResource Class Reference

Class containing behavior resource data. More...

#include <auto_apms_behavior_tree_core/behavior.hpp>

Inheritance diagram for BehaviorResource:

Public Member Functions

 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.
 
- Public Member Functions inherited from BehaviorResourceTemplate< BehaviorResourceIdentity >
 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 IdentitygetIdentity () 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 NodeManifestgetNodeManifest () const
 Get the node manifest associated with this resource.
 

Additional Inherited Members

- Static Public Member Functions inherited from BehaviorResourceTemplate< BehaviorResourceIdentity >
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.
 

Detailed Description

Class containing behavior resource data.

Behavior resources are registered by calling the CMake macro auto_apms_behavior_tree_register_behavior in the CMakeLists.txt of a package. They can be discovered once the corresponding package has been installed to the ROS 2 workspace.

The user may refer to a specific resource using an identity string that may contain the tokens <category_name>, <package_name>, and <behavior_alias>. Depending on the number of registered resources, it might be convenient to use shorter, less precise signatures. The formatting is described below:

  • <category_name>/<package_name>::<behavior_alias>

    Fully qualified identity string of a specific behavior tree.

  • <package_name>::<behavior_alias> or /<package_name>::<behavior_alias>

    The category name is always optional. If omitted, the resource is searched in all categories.

  • ::<behavior_alias> or <behavior_alias>

    Just like the category name, the package name is optional as well. If omitted, the resource is searched in all packages.

Note
The token <behavior_alias> is usually the stem of the file given to auto_apms_behavior_tree_register_behavior. However, it is also possible to provide raw strings as arguments (e.g. for referring to another resource). In this case, <behavior_alias> is determined to be the given string.

Usage

Given the user has specified a behavior using a YAML file, the CMake macro auto_apms_behavior_tree_register_behavior must be called in the CMakeLists.txt of the parent package (for example my_package) like this:

auto_apms_behavior_tree_register_behavior(
"behavior/my_behavior.yaml"
)

The macro automatically installs the given file and makes it discoverable using the above mentioned identities. In the C++ source code, one may use this resource like this after the parent package my_package has been installed:

#include "auto_apms_behavior_tree_core/behavior.hpp"
using namespace auto_apms_behavior_tree;
// For example, use the fully qualified behavior resource identity signature
const std::string identity_string = "default/my_package::my_behavior";
// You may use the proxy class for a tree resource identity
core::BehaviorResourceIdentity identity(identity_string);
core::BehaviorResource resource(identity);
// Or instantiate the resource object directly from the corresponding identity string
core::BehaviorResource resource(identity_string);
Class containing behavior resource data.
Definition behavior.hpp:277
Powerful tooling for incorporating behavior trees for task development.
Definition behavior.hpp:32
Struct that encapsulates the identity string for a registered behavior.
Definition behavior.hpp:38

Definition at line 276 of file behavior.hpp.

Member Function Documentation

◆ BehaviorResourceTemplate() [1/3]

BehaviorResourceTemplate ( const Identity & search_identity)
inline

Assemble a behavior resource using a BehaviorResourceIdentity.

Parameters
search_identityBehavior resource identity object used for searching the corresponding resource.
Exceptions
auto_apms_util::exceptions::ResourceErrorif the resource cannot be found using the given identity.

Definition at line 130 of file behavior.hpp.

◆ BehaviorResourceTemplate() [2/3]

BehaviorResourceTemplate ( const std::string & search_identity)
inline

Assemble a behavior resource identified by a string.

search_identity must be formatted like <category_name>/<package_name>::<behavior_alias>.

Parameters
search_identityBehavior resource identity string used for searching the corresponding resource.
Exceptions
auto_apms_util::exceptions::ResourceIdentityFormatErrorif the identity string has wrong format.
auto_apms_util::exceptions::ResourceErrorif the resource cannot be found using the given identity string.

Definition at line 142 of file behavior.hpp.

◆ BehaviorResourceTemplate() [3/3]

BehaviorResourceTemplate ( const char * search_identity)
inline

Assemble a behavior tree resource identified by a string.

search_identity must be formatted like <category_name>/<package_name>::<behavior_alias>.

Parameters
search_identityC-style behavior resource identity string used for searching the corresponding resource.
Exceptions
auto_apms_util::exceptions::ResourceIdentityFormatErrorif the identity string has wrong format.
auto_apms_util::exceptions::ResourceErrorif the resource cannot be found using the given identity string.

Definition at line 154 of file behavior.hpp.


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