![]() |
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. | |
| 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 an installed resource. | |
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 96 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 98 of file node_manifest.cpp.
|
static |
Create a node manifest from an installed resource.
| 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 111 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 116 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 127 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 129 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 137 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 144 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 158 of file node_manifest.cpp.
| NodeManifest & merge | ( | const NodeManifest & | other, |
| bool | replace = false ) |
Merges another NodeManifest with this one.
| 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 other shares entries and replace is false. |
Definition at line 168 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 185 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 193 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 195 of file node_manifest.cpp.
| const NodeManifest::Map & map | ( | ) | const |
Get a view of the internal map.
Definition at line 197 of file node_manifest.cpp.