How ika-rwth-aachen/ros2-pkg-create works
Project Type and Purpose
• This project is an interactive Command Line Interface (CLI) tool that generates ROS 2 packages using customizable templates. It essentially replaces the native “ros2 pkg create” command with additional capabilities and interactive features.
• The tool supports different kinds of ROS 2 packages – C++ packages, Python packages, and interface packages – and tailors the generated code according to user-provided options (like including lifecycle nodes, launch files, and CI integration).
Main Components
• CLI Interface:
– Entry point script (located in ros2-pkg-create/src/ros2_pkg_create/__main__.py) that parses command-line options and triggers the package generation process.
– Argument parsing and interactive questionnaire logic.
• Template Manager:
– Responsible for handling the various templates stored in the “templates” directory. There are three major sub-categories for C++, Python, and Interfaces, where Jinja templates with conditional blocks are used.
– Uses tools like copier (as indicated by the presence of copier.yml) to render the templates.
• Package Generator:
– Converts user input into a complete ROS 2 package structure.
– Manages file creation, populates files with processed templates, and organizes the package structure (as seen in the “samples” directory for examples of generated packages).
• Configuration & Metadata Manager:
– Reads and uses configuration files such as the pyproject.toml and copier.yml at top-level and within subdirectories to determine project-specific settings.
• CI/CD Integration:
– Contains workflows under the “.github/workflows” directory, which clearly shows that automated testing, publishing, and checks are part of the design.
– May also support generating packages with Docker-ROS CI integration (as seen by options like “--has-docker-ros”).
Relationships and Data Flow
• The user interacts with the CLI which:
– Collects parameters (like package name, node options, feature toggles).
– These parameters are then fed to the Template Manager.
• Template Manager takes the selected template components (located in templates/ros2_cpp_pkg, templates/ros2_python_pkg, and templates/ros2_interfaces_pkg) and applies user inputs (using Jinja for conditional rendering).
• The Package Generator creates a structured directory with configuration files, source folders, and sample launch files – similar to the examples inside the “samples” directory.
Architectural Patterns and Technologies
• The design revolves around separation of concerns:
– CLI interface for input and command processing.
– Template processing engine for dynamic file generation.
– File system I/O for generating the final package structure.
• The project uses Jinja-style templating (note the .jinja suffixes) and copier configuration for dynamic content.
• GitHub Actions are used for automation, evidenced by the YAML files in the .github/workflows.
• The overall structure is modular – the tool supports multiple package templates and allows plugging in additional features (like Docker integration, advanced ROS node types such as lifecycle nodes, etc.).