Skip to content

Commit

Permalink
add explanation about component containers.
Browse files Browse the repository at this point in the history
Signed-off-by: Tomoya.Fujita <Tomoya.Fujita@sony.com>
  • Loading branch information
fujitatomoya committed Dec 13, 2024
1 parent 3d4b2ef commit 94bf175
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
21 changes: 21 additions & 0 deletions source/Concepts/Intermediate/About-Composition.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,27 @@ By making the process layout a deploy-time decision the user can choose between:

Additionally ``ros2 launch`` can be used to automate these actions through specialized launch actions.

Component container
-------------------

Component container is a host process that allows you to load and manage multiple components at runtime within the same process space.
This enables better performance and memory efficiency because it avoids inter-process communication overhead when nodes interact.

As of now, these are generic component container types available.

* `component_container <https://github.com/ros2/rclcpp/blob/{REPOS_FILE_BRANCH}/rclcpp_components/src/component_container.cpp>`__
* The most generic component container that uses a single ``SingleThreadedExecutor`` to execute all components including component container itself.

* `component_container_mt <https://github.com/ros2/rclcpp/blob/{REPOS_FILE_BRANCH}/rclcpp_components/src/component_container_mt.cpp>`__
* Component container that uses a single ``MultiThreadedExecutor`` to execute the components including component container itself.
* ``thread_num`` parameter option is available to specify the number of threads in ``MultiThreadedExecutor``.

* `component_container_isolated <https://github.com/ros2/rclcpp/blob/{REPOS_FILE_BRANCH}/rclcpp_components/src/component_container_isolated.cpp>`__
* Component container with dedicated either ``SingleThreadedExecutor`` (default) or ``MultiThreadedExecutor`` executors for each component. (Component container is executed by ``SingleThreadedExecutor``)
* ``--use_multi_threaded_executor`` argument specifies executor type used for each component to ``MultiThreadedExecutor``.

See more details for :doc:`Types of Executors <../Concepts/About-Executors#types-of-executors>`.

Writing a Component
-------------------

Expand Down
23 changes: 23 additions & 0 deletions source/Tutorials/Intermediate/Composition.rst
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,29 @@ Advanced Topics

Now that we have seen the basic operation of components, we can discuss a few more advanced topics.

Component container types
^^^^^^^^^^^^^^^^^^^^^^^^^

As introduced in :doc:`Component container <../../Concepts/About-Composition#component-container>`, there is a few component container types with options.
You can choose the most appropriate component container type for your requirement.

* ``component_container`` (No options / parameters available)

.. code-block:: bash
ros2 run rclcpp_components component_container
* ``component_container_mt`` with ``MultiThreadedExecutor`` composed of 4 threads.

.. code-block:: bash
ros2 run rclcpp_components component_container_mt --ros-args -p thread_num:=4
* ``component_container_isolated`` with ``MultiThreadedExecutor`` for each component.

.. code-block:: bash
ros2 run rclcpp_components component_container_isolated --use_multi_threaded_executor
Unloading components
^^^^^^^^^^^^^^^^^^^^
Expand Down

0 comments on commit 94bf175

Please sign in to comment.