AutoAPMS
Streamlining behaviors in ROS 2
Loading...
Searching...
No Matches
BehaviorResourceIdentity Struct Reference

Struct that encapsulates the identity string for a registered behavior. More...

#include <auto_apms_behavior_tree_core/behavior.hpp>

Inheritance diagram for BehaviorResourceIdentity:

Public Member Functions

 BehaviorResourceIdentity (const std::string &identity)
 Constructor of a behavior resource identity object.
 
 BehaviorResourceIdentity (const std::string &identity, const std::string &default_category)
 Constructor of a behavior resource identity object.
 
 BehaviorResourceIdentity (const char *identity)
 Constructor of a behavior resource identity object.
 
 BehaviorResourceIdentity ()=default
 Constructor of an empty behavior resource identity object.
 
std::string str () const
 Create the corresponding identity string.
 
bool empty () const
 Determine whether this behavior resource identity object is considered empty.
 

Public Attributes

std::string category_name
 Name of the category this behavior resource belongs to.
 
std::string package_name
 Name of the package that registers the behavior resource.
 
std::string behavior_alias
 Alias for a single registered behavior.
 

Detailed Description

Struct that encapsulates the identity string for a registered behavior.

A behavior resource identity string consists of three optional tokens:

  • <category_name> — The category of the behavior resource (e.g. "tree", "default").
  • <package_name> — The ROS 2 package that registered the behavior resource.
  • <behavior_alias> — The alias that uniquely identifies the behavior within its package.

Supported identity formats

Several short forms are supported to allow omitting tokens that are not needed for disambiguation. The :: separator is always used between <package_name> and <behavior_alias>, and / is used between <category_name> and the rest of the identity.

Format Description
<category_name>/<package_name>::<behavior_alias> Fully qualified: category, package, and alias.
<package_name>::<behavior_alias> Omit category — searches across all categories. Equivalent to /<package_name>::<behavior_alias>.
::<behavior_alias> Omit both category and package — searches across all packages and categories.
<behavior_alias> Same as ::<behavior_alias>, but only when the alias itself does not contain ::.
<category_name>/::<behavior_alias> With category, but without package — narrows search to a specific category across all packages.
Note
When the <behavior_alias> itself contains :: (as is the case with TreeResourceIdentity where the alias is <tree_file_stem>::<tree_name>), the bare alias form is ambiguous with the <package_name>::<behavior_alias> form. In that case, you must provide the first :: which separates the package name (which can be empty though) to avoid misinterpretation.

Parsing rules

  1. If the identity contains /, the substring before the first / is the <category_name> and everything after is processed as <package_name>::<behavior_alias>.
  2. If the remaining string contains ::, the substring before the first :: is the <package_name> and everything after is the <behavior_alias>.
  3. If no :: is found, the entire remaining string is treated as the <behavior_alias> (package is empty).
  4. A default_category may be provided to fill <category_name> when it is omitted or set to "default".

Definition at line 77 of file behavior.hpp.

Constructor & Destructor Documentation

◆ BehaviorResourceIdentity() [1/4]

BehaviorResourceIdentity ( const std::string & identity)

Constructor of a behavior resource identity object.

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

Parameters
identityIdentity string for a specific behavior resource.
Exceptions
auto_apms_util::exceptions::ResourceIdentityFormatErrorif the identity string has wrong format.

Definition at line 28 of file behavior.cpp.

◆ BehaviorResourceIdentity() [2/4]

BehaviorResourceIdentity ( const std::string & identity,
const std::string & default_category )

Constructor of a behavior resource identity object.

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

Parameters
identityIdentity string for a specific behavior resource.
default_categoryName of the default category assigned if none is provided with the identity string.
Exceptions
auto_apms_util::exceptions::ResourceIdentityFormatErrorif the identity string has wrong format.

Definition at line 65 of file behavior.cpp.

◆ BehaviorResourceIdentity() [3/4]

BehaviorResourceIdentity ( const char * identity)

Constructor of a behavior resource identity object.

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

Parameters
identityC-style identity string for a specific behavior resource.
Exceptions
auto_apms_util::exceptions::ResourceIdentityFormatErrorif the identity string has wrong format.

Definition at line 74 of file behavior.cpp.

◆ BehaviorResourceIdentity() [4/4]

Constructor of an empty behavior resource identity object.

The user must manually populate the member fields.

Member Function Documentation

◆ str()

std::string str ( ) const

Create the corresponding identity string.

Returns
Identity string for a behavior resource.

Definition at line 83 of file behavior.cpp.

◆ empty()

bool empty ( ) const

Determine whether this behavior resource identity object is considered empty.

Returns
true if none of the member fields are set, false otherwise.

Definition at line 93 of file behavior.cpp.

Member Data Documentation

◆ category_name

std::string category_name

Name of the category this behavior resource belongs to.

Definition at line 134 of file behavior.hpp.

◆ package_name

std::string package_name

Name of the package that registers the behavior resource.

Definition at line 136 of file behavior.hpp.

◆ behavior_alias

std::string behavior_alias

Alias for a single registered behavior.

Definition at line 138 of file behavior.hpp.


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