|
AutoAPMS
Streamlining behaviors in ROS 2
|
Data structure for information about which behavior tree node plugin to load and how to configure them. More...
#include <auto_apms_behavior_tree_core/node/node_manifest.hpp>
Public Types | |
| using | Map = std::map<std::string, NodeRegistrationOptions> |
| Mapping of a node's name and its registration parameters. | |
Public Member Functions | |
| NodeManifest (const Map &map={}) | |
| Constructor of a NodeManifest data structure. | |
| void | toFile (const std::string &file_path) const |
| Write the node manifest to a file. | |
| bool | contains (const std::string &node_name) const |
| Determine if a behavior tree node has been added to the manifest. | |
| RegistrationOptions & | operator[] (const std::string &node_name) |
| Access the node manifest and retrieve registration options for a specific behavior tree node. | |
| const RegistrationOptions & | operator[] (const std::string &node_name) const |
| Access the node manifest and retrieve registration options for a specific behavior tree node. | |
| NodeManifest & | add (const std::string &node_name, const RegistrationOptions &opt) |
| Add registration options for a behavior tree node to the manifest. | |
| NodeManifest & | remove (const std::string &node_name) |
| Remove registration options for a behavior tree node. | |
| NodeManifest & | merge (const NodeManifest &other, bool replace=false) |
| Merges another NodeManifest with this one. | |
| NodeManifest & | mergeWithNamespace (const NodeManifest &other, const std::string &with_namespace, const std::string &sep=_AUTO_APMS_BEHAVIOR_TREE_CORE__NODE_NAMESPACE_DEFAULT_SEP) |
| Merges another NodeManifest with this one using a namespace for the registration names. | |
| NodeManifest & | applyNodeNamespace (const std::string &ns, const std::string &sep=_AUTO_APMS_BEHAVIOR_TREE_CORE__NODE_NAMESPACE_DEFAULT_SEP) |
| Apply a namespace prefix to all node names in this manifest. | |
| std::vector< std::string > | getNodeNames () |
| Get all names of the behavior tree nodes specified by the manifest. | |
| size_t | size () const |
| Get the number of behavior tree nodes this manifest holds registration options for. | |
| bool | empty () const |
| Determine whether any node registration options have been added to the manifest. | |
| const Map & | map () const |
| Get a view of the internal map. | |
Static Public Member Functions | |
| static NodeManifest | fromFiles (const std::vector< std::string > &paths) |
| Create a node plugin manifest from multiple files. They are loaded in the given order. | |
| static NodeManifest | fromResource (const NodeManifestResourceIdentity &search_identity) |
| Create a node manifest from a resource insinde the process-local lookup table or the ament index. | |
| static void | registerLocalManifest (const NodeManifestResourceIdentity &id, const NodeManifest &manifest, bool allow_override=false) |
| Register a manifest in the process-local lookup table. | |
Data structure for information about which behavior tree node plugin to load and how to configure them.
The concept of a node manifest is introduced to enable TreeDocument to dynamically load and register an arbitrary amount of behavior tree node plugins implemented by ROS 2 packages. The node manifest contains information about the individual registration options required at construction time and the names that must be used inside the behavior tree to refer to respective node implementations.
Usually, the user doesn't need to worry about creating instances of this class manually, since a node manifest is automatically assembled when creating a behavior tree using a behavior tree resource. These resources are generated by the CMake macro auto_apms_behavior_tree_register_trees inside a CMakeLists.txt of a package. It's also possible to create node manifest resources using the CMake macro auto_apms_behavior_tree_register_nodes. Both macros may take an argument named NODE_MANIFEST that accepts multiple paths to YAML files specifying the corresponding node manifest. The content of the files will be concatenated to a single node manifest.
The YAML format for a node manifest file is defined here
Definition at line 132 of file node_manifest.hpp.
| using Map = std::map<std::string, NodeRegistrationOptions> |
Mapping of a node's name and its registration parameters.
Definition at line 138 of file node_manifest.hpp.
| NodeManifest | ( | const Map & | map = {} | ) |
Constructor of a NodeManifest data structure.
The manifest is empty initially, but you may provide a map to initialize it.
| map | Initial manifest data. |
Definition at line 99 of file node_manifest.cpp.
|
static |
Create a node plugin manifest from multiple files. They are loaded in the given order.
| paths | Paths to the manifest files. |
| auto_apms_behavior_tree::exceptions::NodeManifestError | if NodeManifest::merge fails for any file. |
Definition at line 101 of file node_manifest.cpp.
|
static |
Create a node manifest from a resource insinde the process-local lookup table or the ament index.
| search_identity | Node manifest resource identity used for searching the corresponding resource. |
| auto_apms_util::exceptions::ResourceIdentityFormatError | if identity has wrong format. |
| auto_apms_util::exceptions::ResourceError | if resource cannot be determined using identity. |
Definition at line 138 of file node_manifest.cpp.
|
static |
Register a manifest in the process-local lookup table.
NodeManifest::fromResource checks this table before querying the ament index, which allows developers to also register manifests without relying on the ament index.
| id | Identity under which the manifest is registered. |
| manifest | Manifest to store. |
| allow_override | If false (default), throws when id is already present in the ament index. Set to true to allow the local entry to shadow an installed resource. |
| exceptions::NodeManifestError | if id is already registered locally, or if id resolves to an existing ament index resource and allow_override is false. |
Definition at line 119 of file node_manifest.cpp.
| void toFile | ( | const std::string & | file_path | ) | const |
Write the node manifest to a file.
| file_path | Path to the target file. |
| auto_apms_behavior_tree::exceptions::NodeManifestError | if file cannot be opened. |
Definition at line 147 of file node_manifest.cpp.
| bool contains | ( | const std::string & | node_name | ) | const |
Determine if a behavior tree node has been added to the manifest.
| node_name | Name of the behavior tree node. |
true if name is existing, false otherwise. Definition at line 158 of file node_manifest.cpp.
| NodeManifest::RegistrationOptions & operator[] | ( | const std::string & | node_name | ) |
Access the node manifest and retrieve registration options for a specific behavior tree node.
| node_name | Name of the behavior tree node. |
node_name. | std::out_of_range | if node_name doesn't exist. |
Definition at line 160 of file node_manifest.cpp.
| const NodeManifest::RegistrationOptions & operator[] | ( | const std::string & | node_name | ) | const |
Access the node manifest and retrieve registration options for a specific behavior tree node.
| node_name | Name of the behavior tree node. |
node_name. | std::out_of_range | if node_name doesn't exist. |
Definition at line 168 of file node_manifest.cpp.
| NodeManifest & add | ( | const std::string & | node_name, |
| const RegistrationOptions & | opt ) |
Add registration options for a behavior tree node to the manifest.
| node_name | Name of the behavior tree node. |
| opt | Registration options to be used when loading the behavior tree node. |
| auto_apms_behavior_tree::exceptions::NodeManifestError | if the registration options are invalid or node_name already exists. |
Definition at line 175 of file node_manifest.cpp.
| NodeManifest & remove | ( | const std::string & | node_name | ) |
Remove registration options for a behavior tree node.
| node_name | Name of the behavior tree node. |
| std::out_of_range | if node_name doesn't exist. |
Definition at line 190 of file node_manifest.cpp.
| NodeManifest & merge | ( | const NodeManifest & | other, |
| bool | replace = false ) |
Merges another NodeManifest with this one.
Since the functional characteristics of a node with the same name but different registration options can be fundamentally different, this method will throw if it comes across a registration name in other that already exists in this node manifest unless replace is true.
| other | Other node manifest. |
| replace | true for automatically replacing entries with the same key (same registration name). Throws an error if false and other contains any keys that already exist in this manifest. |
| auto_apms_behavior_tree::exceptions::NodeManifestError | if any node name from other already exists in this node manifest and replace is false. |
Definition at line 200 of file node_manifest.cpp.
| NodeManifest & mergeWithNamespace | ( | const NodeManifest & | other, |
| const std::string & | with_namespace, | ||
| const std::string & | sep = _AUTO_APMS_BEHAVIOR_TREE_CORE__NODE_NAMESPACE_DEFAULT_SEP ) |
Merges another NodeManifest with this one using a namespace for the registration names.
Since the functional characteristics of a node with the same name but different registration options can be fundamentally different, this method will add a namespace as a prefix to all registration names from other.
| other | Other node manifest. |
| with_namespace | Prefix to add to all node names from other. |
| sep | Separator string to use between the namespace and the node name. |
| auto_apms_behavior_tree::exceptions::NodeManifestError | if any node name from other already exists in this manifest (after applying the namespace prefix). |
Definition at line 217 of file node_manifest.cpp.
| NodeManifest & applyNodeNamespace | ( | const std::string & | ns, |
| const std::string & | sep = _AUTO_APMS_BEHAVIOR_TREE_CORE__NODE_NAMESPACE_DEFAULT_SEP ) |
Apply a namespace prefix to all node names in this manifest.
| ns | Namespace prefix to apply. |
| sep | Separator string to use between the namespace and the node name. |
Definition at line 232 of file node_manifest.cpp.
| std::vector< std::string > getNodeNames | ( | ) |
Get all names of the behavior tree nodes specified by the manifest.
Definition at line 243 of file node_manifest.cpp.
| size_t size | ( | ) | const |
Get the number of behavior tree nodes this manifest holds registration options for.
Definition at line 251 of file node_manifest.cpp.
| bool empty | ( | ) | const |
Determine whether any node registration options have been added to the manifest.
true if the node manifest is empty, false otherwise. Definition at line 253 of file node_manifest.cpp.
| const NodeManifest::Map & map | ( | ) | const |
Get a view of the internal map.
Definition at line 255 of file node_manifest.cpp.