|
Fabric 0.2.0
|
The parser in Fabric is implemented as a plugin so plan interpretation can be changed without modifying the server. A parser is selected at runtime through the parsing_plugin parameter. This design allows for:
The parser's main responsibility is to convert an XML plan into a fabric::Plan object, which is the internal representation used by the Fabric execution engine.
All parser plugins inherit from the ParserBase abstract class, which defines the required interface:
initialize(const rclcpp::Node::SharedPtr&): Prepares the plugin with the ROS2 node context.load_file(const std::string&, fabric::Plan&): Loads a plan file and stores its XML text in plan.plan.check_compatibility(const fabric::Plan&): Performs a lightweight compatibility check for externally submitted plan text.parse(fabric::Plan&): Parses the XML text already stored in the fabric::Plan.This ensures that all plugins are interchangeable and can be managed uniformly by the Fabric core.
The XMLParserPlugin is the default parser for standard XML plans. Its key features include:
fabric_capabilities/FabricCompletionRunner with the generated plan_id.sequential, parallel_any, parallel_all, and recovery.fabric::Plan.parallel_all**: Represents a control structure where all child runners must complete before proceeding. The plugin inserts a system runner using capabilities2_runner/InputMultiplexRunner with input_count set to the number of branches.parallel_any**: Represents a control structure where the plan proceeds as soon as any child runner completes. The plugin inserts a system runner using capabilities2_runner/InputMultiplexRunner with input_count=1.These are implemented via the add_parallel_all and add_parallel_any methods, which:
The parser traverses the XML plan recursively:
<Control> element, it determines the type (e.g., sequential, parallel_any, parallel_all) and processes its children accordingly.<Runner> elements, it requires interface and provider attributes, then converts all other XML attributes into typed EventParameters.fabric::Plan accurately represents the intended execution flow, including complex parallel and recovery structures.To support a new XML plan version or dialect:
ParserBase.This approach allows Fabric to evolve and support new plan formats without invasive changes to the core system.
Summary:
XMLParserPlugin demonstrates how to handle control flow, parallelism, and connection extraction.