Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New code generation documentation #2

Open
wants to merge 2 commits into
base: code_generation_documentation
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ pip install -r requirements.txt -c constraints.txt

### Pinned versions

For development we currently use Jammy as our build platform.
And all python versions are pinned in the constraints file to make sure that things are reproducible.
To upgrade the system validate that things are working and then use `pip freeze > constraints.txt` to lock in the versions to upgrade.
For development we currently use Jammy as our build platform. ANd all python versions are pinned in the constraints file to make sure that things are reproducible. To upgrade the system validate that things are working and then use `pip freeze > constraints.txt` to lock in the versions to upgrade.

## Building HTML

Expand Down
42 changes: 29 additions & 13 deletions source/Concepts/Advanced/About-Internal-Interfaces.rst
Original file line number Diff line number Diff line change
Expand Up @@ -201,16 +201,20 @@ of CMake and Ament. To simplify the explanation of this mechanism let's separate
- ``Generator`` projects, which are the ones that have the templates and logic to generate code.
- ``Interface`` projects, which are the ones that need code to be generated, they have the parameters to generate code.

For instance, typesupport packages that generate code for a particular dds implementation are *Generator* packages, same case that rosidl which
For instance, typesupport packages that generate code for a particular dds implementation are ``Generator`` packages, same case that rosidl which
generates code from ros idl (.msg, .action, etc) files.

*Interface* projects are typically projects that define messages, actions and services. Which have .msg files with rosidl defined on them which are
used by *Generator* projects to create code. A package that calls rosidl_generate_interfaces CMake macro is a *Interface* project.
``Interface`` projects are typically projects that define messages, actions and services. Which have .msg files with rosidl defined on them which are
used by ``Interface`` projects to crete code. A package that calls rosidl_generate_interfaces CMake macro is a ``Interface`` project.

Code generation workflow
------------------------
-------------------------

On workspace build, the ``generator`` packages, registers portions of CMake code as an ament_extension under different keys:

On workspace build, the *generator* packages, registers a portion of CMake code as an ament_extension under 'rosidl_generate_idl_interfaces' key.
- ``rosidl_create_type_descriptions_extensions`` : Calls type support description extensions(generate hashes for typessupports)
- ``rosidl_write_generator_arguments_extensions``: Generate the arguments files.
- ``rosidl_generate_idl_interfaces``: After files are generated, create artifacts, export dependencies.

Hook registration on CodeGenerator project build

Expand All @@ -221,28 +225,40 @@ Hook registration on CodeGenerator project build
participant ament_package
participant ament_register_extension
CodeGenerator_cmake->>ament_package: CONFIG_EXTRAS
ament_package->>ament_register_extension: rosidl_create_type_descriptions_extensions, cmake_code_hook
ament_package->>ament_register_extension: rosidl_write_generator_arguments_extensions, cmake_code_hook
ament_package->>ament_register_extension: rosidl_generate_idl_interfaces, cmake_code_hook
Note right of ament_package: Execute a cmake.in template with variables and a cmake code hook.


When the *interface* package, during its build process, calls the 'rosidl_generate_interfaces' macro, the extensions that were registered for each of the
*generator* packages, get called. Said extensions have the code to generate sources for each of the IDL interfaces. Then, code is added to an artifact
(a library) and dependiences are exported for code to be build and installed.
When the ``interface`` package, during its build process, calls the 'rosidl_generate_interfaces' macro, the extensions that were registered for each of the
``generator`` packages, get called. On 'rosidl_write_generator_arguments_extensions' arguments files are generated with all parameters required to call the templates engine.
After collecting all the arguments files, the extension calls the template engine for all the arguments files at once. Once code is generated,
the 'rosidl_generate_idl_interfaces' extensiones are called to get code added to an artifact (a library) and export dependiences.

.. mermaid::

sequenceDiagram
participant project_with_rosidl_files
participant rosidl_generate_interfaces
participant rosidl_create_type_descriptions_extensions_HOOK
participant rosidl_generate_idl_interfaces_HOOK
participant rosidl_write_generator_arguments_extensions_HOOK
participant generate_arguments_file
participant rosidl_generator
project_with_rosidl_files->>rosidl_generate_interfaces: path_to_idl_files
loop ForEach Hook
rosidl_generate_interfaces->>rosidl_generate_idl_interfaces_HOOK: path_to_idl_files, parameters
rosidl_generate_idl_interfaces_HOOK->>generate_arguments_file: template_parameters
loop ForEach rosidl_create_type_descriptions_extensions Hook
rosidl_generate_interfaces->>rosidl_create_type_descriptions_extensions_HOOK: path_to_idl_files, parameters
end
loop ForEach rosidl_write_generator_arguments_extensions Hook
rosidl_generate_interfaces->>rosidl_write_generator_arguments_extensions_HOOK: path_to_idl_files, parameters
activate generate_arguments_file
generate_arguments_file->>rosidl_generate_idl_interfaces_HOOK: arguments_file
rosidl_write_generator_arguments_extensions_HOOK->>generate_arguments_file: path_to_idl_files, parameters
generate_arguments_file->>rosidl_write_generator_arguments_extensions_HOOK: arguments_file
deactivate generate_arguments_file
rosidl_generate_idl_interfaces_HOOK->>rosidl_generator: arguments_file
rosidl_write_generator_arguments_extensions_HOOK->>rosidl_generate_interfaces: arguments_file
end
rosidl_generate_interfaces->>rosidl_generator: [arguments_files]
loop ForEach rosidl_generate_idl_interfaces Hook
rosidl_generate_interfaces->>rosidl_generate_idl_interfaces_HOOK: generated_files
end
Loading