MoveIt Pro API
Core Behaviors for MoveIt Pro
Loading...
Searching...
No Matches
moveit_pro::behavior::ParameterOverrideRegistry Class Reference

Thread-safe registry mapping a port C++ type to a parser that turns a YAML string into a typed BehaviorTree.CPP blackboard entry. More...

#include <parameter_override_registry.hpp>

Public Types

using ParseFn = std::function< tl::expected< BT::Any, std::string >(std::string_view)>
 Callback that parses a YAML string into a typed BT::Any value.
 

Public Member Functions

void registerParser (std::type_index type_index, ParseFn parser)
 Register a parser for the type identified by type_index.
 
ParseFn findParser (std::type_index type_index) const
 Look up the parser for type_index. Returns an empty ParseFn if no parser is registered.
 
ParseFn findParserByName (std::string_view declared_type_name) const
 Look up the parser for the C++ type whose spelling is declared_type_name.
 

Static Public Member Functions

static ParameterOverrideRegistryget ()
 Access the process-global registry.
 

Detailed Description

Thread-safe registry mapping a port C++ type to a parser that turns a YAML string into a typed BehaviorTree.CPP blackboard entry.

Used by the objective server to apply parameter_overrides from DoObjectiveSequence goals onto the tree's blackboards as typed values, so behaviors do not need a BT::convertFromString<T> specialization visible in every .cpp that calls getInput<T>(). Built-in ROS message types are seeded once at startup via seedBuiltinParameterOverrideParsers(). Customers register custom types by calling registerParameterType<T>() once per type from their behavior loader plugin's registerBehaviors().

Member Typedef Documentation

◆ ParseFn

using moveit_pro::behavior::ParameterOverrideRegistry::ParseFn = std::function<tl::expected<BT::Any, std::string>(std::string_view)>

Callback that parses a YAML string into a typed BT::Any value.

Returns
tl::expected wrapping the parsed value on success, or a human-readable error string on YAML parse failure. The parser does not touch any blackboard — that is the caller's responsibility so the apply step can be made transactional.

Member Function Documentation

◆ findParser()

ParameterOverrideRegistry::ParseFn moveit_pro::behavior::ParameterOverrideRegistry::findParser ( std::type_index  type_index) const

Look up the parser for type_index. Returns an empty ParseFn if no parser is registered.

Returns by value (a copy of the std::function) so concurrent registerParser calls cannot dangle the pointer to a rehashed unordered_map entry between lookup and invocation.

◆ findParserByName()

ParameterOverrideRegistry::ParseFn moveit_pro::behavior::ParameterOverrideRegistry::findParserByName ( std::string_view  declared_type_name) const

Look up the parser for the C++ type whose spelling is declared_type_name.

Used to resolve an override against an Objective's declared <input_port type="..."> when the consuming port is type-erased (e.g. a ForEach whose port is std::vector<BT::Any>), so port-based type_index resolution yields no usable parser. The query is normalized via normalizeTypeName to match the registered key, so the user-written spelling (std::vector<geometry_msgs::msg::PoseStamped>) resolves to the parser registered for the demangled spelling (which carries std::allocator<...> template args). Returns an empty ParseFn if none matches.

◆ get()

ParameterOverrideRegistry & moveit_pro::behavior::ParameterOverrideRegistry::get ( )
static

Access the process-global registry.

◆ registerParser()

void moveit_pro::behavior::ParameterOverrideRegistry::registerParser ( std::type_index  type_index,
ParseFn  parser 
)

Register a parser for the type identified by type_index.

Overwrites any prior registration for the same type. Also indexes the parser by the normalized demangled spelling of type_index so it can be resolved by name (see findParserByName). Thread-safe.


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