Skip to content

Commit d7313c0

Browse files
mini-1235ahcorde
andauthored
Document differences between rclcpp_components_register_node and rclcpp_components_register_nodes (#5984)
Signed-off-by: Maurice <[email protected]> Co-authored-by: Alejandro Hernández Cordero <[email protected]>
1 parent 8aeaf2a commit d7313c0

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

source/Concepts/Intermediate/About-Composition.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,33 @@ For an example, :doc:`check out this tutorial <../../Tutorials/Intermediate/Writ
8484

8585
In order for the component_container to be able to find desired components, it must be executed or launched from a shell that has sourced the corresponding workspace.
8686

87+
CMake Registration Macros
88+
-------------------------
89+
90+
ROS 2 provides two CMake macros for registering components, each serving a different purpose:
91+
92+
``rclcpp_components_register_node``
93+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
94+
This macro registers a component and generates a standalone executable.
95+
Use this when you want both composability and the ability to run the node as a standalone process.
96+
97+
.. code-block:: cmake
98+
99+
add_library(talker_component SHARED src/talker_component.cpp)
100+
rclcpp_components_register_node(talker_component
101+
PLUGIN "composition::Talker"
102+
EXECUTABLE talker)
103+
104+
``rclcpp_components_register_nodes``
105+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
106+
This macro registers one or more components for runtime composition **without** creating standalone executables.
107+
Use this when you want pure component libraries that will be loaded into component containers at runtime.
108+
109+
.. code-block:: cmake
110+
111+
add_library(talker_component SHARED src/talker_component.cpp)
112+
rclcpp_components_register_nodes(talker_component "composition::Talker")
113+
87114
Using Components
88115
----------------
89116

0 commit comments

Comments
 (0)