Package Summary

Tags No category tags.
Version 0.20.5
License Apache License 2.0
Build type AMENT_CMAKE
Use RECOMMENDED

Repository Summary

Description
Checkout URI https://github.com/ros2/demos.git
VCS Type git
VCS Version humble
Last Updated 2025-05-08
Dev Status DEVELOPED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

Examples for composing multiple nodes in a single process.

Additional Links

No additional links.

Maintainers

  • Audrow Nash
  • Michael Jeronimo

Authors

  • Dirk Thomas
  • Mabel Zhang

What Is This?

This demo provides examples of three different ways to use the rclcpp_components API to compose multiple nodes in a single process.

This ROS 2 package consists of the following demo applications:

  1. dlopen_composition
  2. linktime_composition
  3. manual_composition

Build

Run the commands below to build the ROS 2 package:

colcon build --packages-up-to composition

Run

Manual Composition

Running manual_composition compiles an executable that runs the following 4 components:

  • Talker: A ROS 2 component that publishes a string
  • Listener: A ROS 2 component that prints the received string from Talker
  • Server: A ROS 2 component that adds two integers and outputs its result to Client
  • Client: A ROS 2 component that sends two integers to Server and prints the received result from Server
ros2 run composition manual_composition

DlOpen Composition

This runs dlopen_composition which is an alternative to run-time composition by creating a generic container process and explicitly passing the libraries to load without using ROS interfaces.

The process will open each library and create one instance of each “rclcpp::Node” class in the library.

ros2 run composition dlopen_composition `ros2 pkg prefix composition`/lib/libtalker_component.so `ros2 pkg prefix composition`/lib/liblistener_component.so

Linktime Composition

Similar to previous, this runs linktime_composition which links all classes from libraries that are registered under the library_path with the linker.

ros2 run composition linktime_composition

Composition Using Launch Actions

Rather than using the command line tool to run each composition, we can automate this action with ros2 launch functionality:

ros2 launch composition composition_demo.launch.py

Verify

Manual Composition

When executed correctly, strings should be printed to terminal similar to what is shown below:

[INFO] [1674528188.026468320] [talker]: Publishing: 'Hello World: 1'
[INFO] [1674528188.027043857] [listener]: I heard: [Hello World: 1]
[INFO] [1674528189.026414368] [talker]: Publishing: 'Hello World: 2'
[INFO] [1674528189.026742015] [listener]: I heard: [Hello World: 2]
[INFO] [1674528189.032512995] [Server]: Incoming request: [a: 2, b: 3]
[INFO] [1674528189.032815843] [Client]: Got result: [5]
[INFO] [1674528190.026455807] [talker]: Publishing: 'Hello World: 3'
[INFO] [1674528190.026795770] [listener]: I heard: [Hello World: 3]
[INFO] [1674528191.026457639] [talker]: Publishing: 'Hello World: 4'
[INFO] [1674528191.026801926] [listener]: I heard: [Hello World: 4]
[INFO] [1674528191.032377264] [Server]: Incoming request: [a: 2, b: 3]
[INFO] [1674528191.032604427] [Client]: Got result: [5]
[INFO] [1674528192.026428269] [talker]: Publishing: 'Hello World: 5'
[INFO] [1674528192.026537974] [listener]: I heard: [Hello World: 5]
[INFO] [1674528193.026437034] [talker]: Publishing: 'Hello World: 6'
[INFO] [1674528193.026767708] [listener]: I heard: [Hello World: 6]
[INFO] [1674528193.032377748] [Server]: Incoming request: [a: 2, b: 3]
[INFO] [1674528193.032603036] [Client]: Got result: [5]
#...

:warning:

Note that manually-composed components will not be reflected in the ros2 component list command line tool output.

DlOpen Composition

When executed correctly, strings should be printed to terminal similar to what is shown below:

INFO] [1674529118.496557668] [dlopen_composition]: Load library /opt/ros/humble/lib/libtalker_component.so
[INFO] [1674529118.496774575] [dlopen_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate<composition::Talker>
[INFO] [1674529118.503388909] [dlopen_composition]: Load library /opt/ros/humble/lib/liblistener_component.so
[INFO] [1674529118.503739855] [dlopen_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate<composition::Listener>
[INFO] [1674529119.503505873] [talker]: Publishing: 'Hello World: 1'
[INFO] [1674529119.503770137] [listener]: I heard: [Hello World: 1]
[INFO] [1674529120.503572362] [talker]: Publishing: 'Hello World: 2'
[INFO] [1674529120.503888374] [listener]: I heard: [Hello World: 2]
[INFO] [1674529121.503503459] [talker]: Publishing: 'Hello World: 3'
[INFO] [1674529121.503628269] [listener]: I heard: [Hello World: 3]
[INFO] [1674529122.503557862] [talker]: Publishing: 'Hello World: 4'
[INFO] [1674529122.503894772] [listener]: I heard: [Hello World: 4]
[INFO] [1674529123.503574524] [talker]: Publishing: 'Hello World: 5'
[INFO] [1674529123.503884894] [listener]: I heard: [Hello World: 5]
#...

:warning:

Note that dlopen-composed components will not be reflected in the ros2 component list command line tool output.

Linktime Composition

When executed correctly, strings should be printed to terminal similar to what is shown below:

[INFO] [1674528568.091949637] [linktime_composition]: Load library
[INFO] [1674528568.091995119] [linktime_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate<composition::Client>
[INFO] [1674528568.098833910] [linktime_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate<composition::Listener>
[INFO] [1674528568.100669644] [linktime_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate<composition::Server>
[INFO] [1674528568.102665704] [linktime_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate<composition::Talker>
[INFO] [1674528569.104717098] [talker]: Publishing: 'Hello World: 1'
[INFO] [1674528569.105206993] [listener]: I heard: [Hello World: 1]
[INFO] [1674528570.099206827] [Server]: Incoming request: [a: 2, b: 3]
[INFO] [1674528570.099376432] [Client]: Got result: [5]
[INFO] [1674528570.104656875] [talker]: Publishing: 'Hello World: 2'
[INFO] [1674528570.105069514] [listener]: I heard: [Hello World: 2]
[INFO] [1674528571.104710545] [talker]: Publishing: 'Hello World: 3'
[INFO] [1674528571.105150094] [listener]: I heard: [Hello World: 3]
[INFO] [1674528572.099350955] [Server]: Incoming request: [a: 2, b: 3]
[INFO] [1674528572.099628903] [Client]: Got result: [5]
[INFO] [1674528572.104631322] [talker]: Publishing: 'Hello World: 4'
[INFO] [1674528572.104911174] [listener]: I heard: [Hello World: 4]
[INFO] [1674528573.104596009] [talker]: Publishing: 'Hello World: 5'
[INFO] [1674528573.104751214] [listener]: I heard: [Hello World: 5]
#...

:warning:

Note that linktime-composed components will not be reflected in the ros2 component list command line tool output.

Composition Using Launch Actions

When executed correctly, strings should be printed to terminal similar to what is shown below:

[INFO] [launch]: All log files can be found below /root/.ros/log/2024-05-04-23-37-06-363020-d8ff93e471d7-9387
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [component_container-1]: process started with pid [9402]
[component_container-1] [INFO] [1714865826.695090046] [my_container]: Load Library: /opt/ros/jazzy/lib/libtalker_component.so
[component_container-1] [INFO] [1714865826.696388047] [my_container]: Found class: rclcpp_components::NodeFactoryTemplate<composition::Talker>
[component_container-1] [INFO] [1714865826.696435882] [my_container]: Instantiate class: rclcpp_components::NodeFactoryTemplate<composition::Talker>
[INFO] [launch_ros.actions.load_composable_nodes]: Loaded node '/talker' in container '/my_container'
[component_container-1] [INFO] [1714865826.702958710] [my_container]: Load Library: /opt/ros/jazzy/lib/liblistener_component.so
[component_container-1] [INFO] [1714865826.703401061] [my_container]: Found class: rclcpp_components::NodeFactoryTemplate<composition::Listener>
[component_container-1] [INFO] [1714865826.703414344] [my_container]: Instantiate class: rclcpp_components::NodeFactoryTemplate<composition::Listener>
[INFO] [launch_ros.actions.load_composable_nodes]: Loaded node '/listener' in container '/my_container'
[component_container-1] [INFO] [1714865827.701941449] [talker]: Publishing: 'Hello World: 1'
[component_container-1] [INFO] [1714865827.702047599] [listener]: I heard: [Hello World: 1]
[component_container-1] [INFO] [1714865828.701984118] [talker]: Publishing: 'Hello World: 2'
[component_container-1] [INFO] [1714865828.702154523] [listener]: I heard: [Hello World: 2]
[component_container-1] [INFO] [1714865829.702004471] [talker]: Publishing: 'Hello World: 3'
[component_container-1] [INFO] [1714865829.702176059] [listener]: I heard: [Hello World: 3]
[component_container-1] [INFO] [1714865830.701876733] [talker]: Publishing: 'Hello World: 4'
[component_container-1] [INFO] [1714865830.701965546] [listener]: I heard: [Hello World: 4]
[component_container-1] [INFO] [1714865831.701885355] [talker]: Publishing: 'Hello World: 5'
[component_container-1] [INFO] [1714865831.701984823] [listener]: I heard: [Hello World: 5]

FAQ

Q: Why use node composition?

A: Node composition avoids the overhead of marshalling and unmarshaling messages by allowing nodes to be instantiated within the same process.

References

  1. Composing multiple nodes in a single process
  2. About Composition
CHANGELOG

Changelog for package composition

0.20.5 (2024-07-26)

0.20.4 (2024-05-15)

  • [composition] add launch action console output in the verify section (#677) (#682)
  • Contributors: mergify[bot]

0.20.3 (2023-01-10)

0.20.2 (2022-05-10)

0.20.1 (2022-04-08)

0.20.0 (2022-03-01)

0.19.0 (2022-01-14)

0.18.0 (2021-12-17)

  • Update maintainers to Audrow Nash and Michael Jeronimo (#543)
  • Additional fixes for documentation in demos. (#538)
  • Contributors: Audrow Nash, Chris Lalancette

0.17.0 (2021-10-18)

  • Fixing deprecated subscriber callback warnings (#532)
  • Contributors: Abrar Rahman Protyasha

0.16.0 (2021-08-11)

0.15.0 (2021-05-14)

0.14.2 (2021-04-26)

0.14.1 (2021-04-19)

0.14.0 (2021-04-06)

0.13.0 (2021-03-25)

0.12.1 (2021-03-18)

0.12.0 (2021-01-25)

  • Fix leak(#480) (#481)
  • Contributors: y-okumura-isp

0.11.0 (2020-12-10)

  • Update the package.xml files with the latest Open Robotics maintainers (#466)
  • Contributors: Michael Jeronimo

0.10.1 (2020-09-21)

0.10.0 (2020-06-17)

0.9.3 (2020-06-01)

0.9.2 (2020-05-26)

0.9.1 (2020-05-12)

0.9.0 (2020-04-30)

  • Replace deprecated launch_ros usage (#437)
  • Update launch_ros action usage (#431)
  • code style only: wrap after open parenthesis if not in one line (#429)
  • Contributors: Dirk Thomas, Jacob Perron

0.8.4 (2019-11-19)

0.8.3 (2019-11-11)

0.8.2 (2019-11-08)

0.8.1 (2019-10-23)

  • Replace ready_fn with ReadyToTest action (#404)
  • Contributors: Peter Baughman

0.8.0 (2019-09-26)

  • Add an demo component not inherited from rclcpp::Node (#393)
  • Contributors: Michael Carroll

0.7.6 (2019-05-30)

0.7.5 (2019-05-29)

0.7.4 (2019-05-20)

0.7.3 (2019-05-10)

0.7.2 (2019-05-08)

  • changes to avoid deprecated API's (#332)
  • Corrected publish calls with shared_ptr signature (#327)
  • Migrate launch tests to new launch_testing features & API (#318)
  • Contributors: Michel Hidalgo, William Woodall, ivanpauno

0.7.1 (2019-04-26)

  • Renamed launch file, updated to avoid redundant default actions, and set output to screen. (#326)
  • Updated constructor to const ref to NodeOptions. (#323)
  • Added basic composition launch demo. (#324)
  • Contributors: Michael Carroll, William Woodall

0.7.0 (2019-04-14)

  • Updated for new rclcpp_components package. (#319)
  • Added launch along with launch_testing as test dependencies. (#313)
  • Dropped legacy launch API usage. (#311)
  • Contributors: Michael Carroll, Michel Hidalgo

0.6.2 (2019-01-15)

0.6.1 (2018-12-13)

0.6.0 (2018-12-07)

  • Added semicolons to all RCLCPP and RCUTILS macros. (#278)
  • Contributors: Chris Lalancette

0.5.1 (2018-06-28)

0.5.0 (2018-06-27)

  • Updated launch files to account for the "old launch" getting renamespaced as launch -> launch.legacy. (#239)
  • Updated to avoid newly deprecated class loader headers. (#229)
  • Added a periodic log message while waiting for a service response.
  • Contributors: Dirk Thomas, Michael Carroll, Mikael Arguedas, William Woodall

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged composition at Robotics Stack Exchange

Package Summary

Tags No category tags.
Version 0.33.5
License Apache License 2.0
Build type AMENT_CMAKE
Use RECOMMENDED

Repository Summary

Description
Checkout URI https://github.com/ros2/demos.git
VCS Type git
VCS Version jazzy
Last Updated 2025-05-08
Dev Status DEVELOPED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

Examples for composing multiple nodes in a single process.

Additional Links

No additional links.

Maintainers

  • Aditya Pande
  • Audrow Nash

Authors

  • Dirk Thomas
  • Mabel Zhang

What Is This?

This demo provides examples of three different ways to use the rclcpp_components API to compose multiple nodes in a single process.

This ROS 2 package consists of the following demo applications:

  1. dlopen_composition
  2. linktime_composition
  3. manual_composition

Build

Run the commands below to build the ROS 2 package:

colcon build --packages-up-to composition

Run

Manual Composition

Running manual_composition compiles an executable that runs the following 4 components:

  • Talker: A ROS 2 component that publishes a string
  • Listener: A ROS 2 component that prints the received string from Talker
  • Server: A ROS 2 component that adds two integers and outputs its result to Client
  • Client: A ROS 2 component that sends two integers to Server and prints the received result from Server
ros2 run composition manual_composition

DlOpen Composition

This runs dlopen_composition which is an alternative to run-time composition by creating a generic container process and explicitly passing the libraries to load without using ROS interfaces.

The process will open each library and create one instance of each “rclcpp::Node” class in the library.

ros2 run composition dlopen_composition `ros2 pkg prefix composition`/lib/libtalker_component.so `ros2 pkg prefix composition`/lib/liblistener_component.so

Linktime Composition

Similar to previous, this runs linktime_composition which links all classes from libraries that are registered under the library_path with the linker.

ros2 run composition linktime_composition

Composition Using Launch Actions

Rather than using the command line tool to run each composition, we can automate this action with ros2 launch functionality:

ros2 launch composition composition_demo_launch.py

Verify

Manual Composition

When executed correctly, strings should be printed to terminal similar to what is shown below:

[INFO] [1674528188.026468320] [talker]: Publishing: 'Hello World: 1'
[INFO] [1674528188.027043857] [listener]: I heard: [Hello World: 1]
[INFO] [1674528189.026414368] [talker]: Publishing: 'Hello World: 2'
[INFO] [1674528189.026742015] [listener]: I heard: [Hello World: 2]
[INFO] [1674528189.032512995] [Server]: Incoming request: [a: 2, b: 3]
[INFO] [1674528189.032815843] [Client]: Got result: [5]
[INFO] [1674528190.026455807] [talker]: Publishing: 'Hello World: 3'
[INFO] [1674528190.026795770] [listener]: I heard: [Hello World: 3]
[INFO] [1674528191.026457639] [talker]: Publishing: 'Hello World: 4'
[INFO] [1674528191.026801926] [listener]: I heard: [Hello World: 4]
[INFO] [1674528191.032377264] [Server]: Incoming request: [a: 2, b: 3]
[INFO] [1674528191.032604427] [Client]: Got result: [5]
[INFO] [1674528192.026428269] [talker]: Publishing: 'Hello World: 5'
[INFO] [1674528192.026537974] [listener]: I heard: [Hello World: 5]
[INFO] [1674528193.026437034] [talker]: Publishing: 'Hello World: 6'
[INFO] [1674528193.026767708] [listener]: I heard: [Hello World: 6]
[INFO] [1674528193.032377748] [Server]: Incoming request: [a: 2, b: 3]
[INFO] [1674528193.032603036] [Client]: Got result: [5]
#...

:warning:

Note that manually-composed components will not be reflected in the ros2 component list command line tool output.

DlOpen Composition

When executed correctly, strings should be printed to terminal similar to what is shown below:

INFO] [1674529118.496557668] [dlopen_composition]: Load library /opt/ros/rolling/lib/libtalker_component.so
[INFO] [1674529118.496774575] [dlopen_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate<composition::Talker>
[INFO] [1674529118.503388909] [dlopen_composition]: Load library /opt/ros/rolling/lib/liblistener_component.so
[INFO] [1674529118.503739855] [dlopen_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate<composition::Listener>
[INFO] [1674529119.503505873] [talker]: Publishing: 'Hello World: 1'
[INFO] [1674529119.503770137] [listener]: I heard: [Hello World: 1]
[INFO] [1674529120.503572362] [talker]: Publishing: 'Hello World: 2'
[INFO] [1674529120.503888374] [listener]: I heard: [Hello World: 2]
[INFO] [1674529121.503503459] [talker]: Publishing: 'Hello World: 3'
[INFO] [1674529121.503628269] [listener]: I heard: [Hello World: 3]
[INFO] [1674529122.503557862] [talker]: Publishing: 'Hello World: 4'
[INFO] [1674529122.503894772] [listener]: I heard: [Hello World: 4]
[INFO] [1674529123.503574524] [talker]: Publishing: 'Hello World: 5'
[INFO] [1674529123.503884894] [listener]: I heard: [Hello World: 5]
#...

:warning:

Note that dlopen-composed components will not be reflected in the ros2 component list command line tool output.

Linktime Composition

When executed correctly, strings should be printed to terminal similar to what is shown below:

[INFO] [1674528568.091949637] [linktime_composition]: Load library
[INFO] [1674528568.091995119] [linktime_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate<composition::Client>
[INFO] [1674528568.098833910] [linktime_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate<composition::Listener>
[INFO] [1674528568.100669644] [linktime_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate<composition::Server>
[INFO] [1674528568.102665704] [linktime_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate<composition::Talker>
[INFO] [1674528569.104717098] [talker]: Publishing: 'Hello World: 1'
[INFO] [1674528569.105206993] [listener]: I heard: [Hello World: 1]
[INFO] [1674528570.099206827] [Server]: Incoming request: [a: 2, b: 3]
[INFO] [1674528570.099376432] [Client]: Got result: [5]
[INFO] [1674528570.104656875] [talker]: Publishing: 'Hello World: 2'
[INFO] [1674528570.105069514] [listener]: I heard: [Hello World: 2]
[INFO] [1674528571.104710545] [talker]: Publishing: 'Hello World: 3'
[INFO] [1674528571.105150094] [listener]: I heard: [Hello World: 3]
[INFO] [1674528572.099350955] [Server]: Incoming request: [a: 2, b: 3]
[INFO] [1674528572.099628903] [Client]: Got result: [5]
[INFO] [1674528572.104631322] [talker]: Publishing: 'Hello World: 4'
[INFO] [1674528572.104911174] [listener]: I heard: [Hello World: 4]
[INFO] [1674528573.104596009] [talker]: Publishing: 'Hello World: 5'
[INFO] [1674528573.104751214] [listener]: I heard: [Hello World: 5]
#...

:warning:

Note that linktime-composed components will not be reflected in the ros2 component list command line tool output.

Composition Using Launch Actions

When executed correctly, strings should be printed to terminal similar to what is shown below:

[INFO] [launch]: All log files can be found below /root/.ros/log/2024-05-04-23-37-06-363020-d8ff93e471d7-9387
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [component_container-1]: process started with pid [9402]
[component_container-1] [INFO] [1714865826.695090046] [my_container]: Load Library: /opt/ros/jazzy/lib/libtalker_component.so
[component_container-1] [INFO] [1714865826.696388047] [my_container]: Found class: rclcpp_components::NodeFactoryTemplate<composition::Talker>
[component_container-1] [INFO] [1714865826.696435882] [my_container]: Instantiate class: rclcpp_components::NodeFactoryTemplate<composition::Talker>
[INFO] [launch_ros.actions.load_composable_nodes]: Loaded node '/talker' in container '/my_container'
[component_container-1] [INFO] [1714865826.702958710] [my_container]: Load Library: /opt/ros/jazzy/lib/liblistener_component.so
[component_container-1] [INFO] [1714865826.703401061] [my_container]: Found class: rclcpp_components::NodeFactoryTemplate<composition::Listener>
[component_container-1] [INFO] [1714865826.703414344] [my_container]: Instantiate class: rclcpp_components::NodeFactoryTemplate<composition::Listener>
[INFO] [launch_ros.actions.load_composable_nodes]: Loaded node '/listener' in container '/my_container'
[component_container-1] [INFO] [1714865827.701941449] [talker]: Publishing: 'Hello World: 1'
[component_container-1] [INFO] [1714865827.702047599] [listener]: I heard: [Hello World: 1]
[component_container-1] [INFO] [1714865828.701984118] [talker]: Publishing: 'Hello World: 2'
[component_container-1] [INFO] [1714865828.702154523] [listener]: I heard: [Hello World: 2]
[component_container-1] [INFO] [1714865829.702004471] [talker]: Publishing: 'Hello World: 3'
[component_container-1] [INFO] [1714865829.702176059] [listener]: I heard: [Hello World: 3]
[component_container-1] [INFO] [1714865830.701876733] [talker]: Publishing: 'Hello World: 4'
[component_container-1] [INFO] [1714865830.701965546] [listener]: I heard: [Hello World: 4]
[component_container-1] [INFO] [1714865831.701885355] [talker]: Publishing: 'Hello World: 5'
[component_container-1] [INFO] [1714865831.701984823] [listener]: I heard: [Hello World: 5]

FAQ

Q: Why use node composition?

A: Node composition avoids the overhead of marshalling and unmarshaling messages by allowing nodes to be instantiated within the same process.

References

  1. Composing multiple nodes in a single process
  2. About Composition
CHANGELOG

Changelog for package composition

0.33.5 (2024-09-06)

0.33.4 (2024-06-27)

0.33.3 (2024-05-13)

  • [composition] add launch action console output in the verify section (#677) (#681) (cherry picked from commit 34d29db73e78a84a174ad8699a2d646b0eeb1cdf) Co-authored-by: Mikael Arguedas <<mikael.arguedas@gmail.com>>
  • Contributors: mergify[bot]

0.33.2 (2024-03-28)

  • Update maintainer list in package.xml files (#665)
  • Contributors: Michael Jeronimo

0.33.1 (2024-02-07)

0.33.0 (2024-01-24)

  • Migrate std::bind calls to lambda expressions (#659)
  • Contributors: Felipe Gomes de Melo

0.32.1 (2023-12-26)

0.32.0 (2023-11-06)

0.31.1 (2023-09-07)

0.31.0 (2023-08-21)

0.30.1 (2023-07-11)

0.30.0 (2023-06-12)

0.29.0 (2023-06-07)

0.28.1 (2023-05-11)

0.28.0 (2023-04-27)

0.27.0 (2023-04-13)

  • Change all ROS2 -> ROS 2. (#610)
  • Contributors: Chris Lalancette

0.26.0 (2023-04-11)

  • update launch file name format to match documentation (#588)
  • Contributors: Patrick Wspanialy

0.25.0 (2023-03-01)

0.24.1 (2023-02-24)

0.24.0 (2023-02-14)

  • Added README.md for composition (#598)
  • Update the demos to C++17. (#594)
  • [rolling] Update maintainers - 2022-11-07 (#589)
  • Contributors: Audrow Nash, Chris Lalancette, Gary Bey

0.23.0 (2022-11-02)

  • fix memory leak (#585)
  • Contributors: Chen Lihui

0.22.0 (2022-09-13)

0.21.0 (2022-04-29)

0.20.1 (2022-04-08)

0.20.0 (2022-03-01)

0.19.0 (2022-01-14)

0.18.0 (2021-12-17)

  • Update maintainers to Audrow Nash and Michael Jeronimo (#543)
  • Additional fixes for documentation in demos. (#538)
  • Contributors: Audrow Nash, Chris Lalancette

0.17.0 (2021-10-18)

  • Fixing deprecated subscriber callback warnings (#532)
  • Contributors: Abrar Rahman Protyasha

0.16.0 (2021-08-11)

0.15.0 (2021-05-14)

0.14.2 (2021-04-26)

0.14.1 (2021-04-19)

0.14.0 (2021-04-06)

0.13.0 (2021-03-25)

0.12.1 (2021-03-18)

0.12.0 (2021-01-25)

  • Fix leak(#480) (#481)
  • Contributors: y-okumura-isp

0.11.0 (2020-12-10)

  • Update the package.xml files with the latest Open Robotics maintainers (#466)
  • Contributors: Michael Jeronimo

0.10.1 (2020-09-21)

0.10.0 (2020-06-17)

0.9.3 (2020-06-01)

0.9.2 (2020-05-26)

0.9.1 (2020-05-12)

0.9.0 (2020-04-30)

  • Replace deprecated launch_ros usage (#437)
  • Update launch_ros action usage (#431)
  • code style only: wrap after open parenthesis if not in one line (#429)
  • Contributors: Dirk Thomas, Jacob Perron

0.8.4 (2019-11-19)

0.8.3 (2019-11-11)

0.8.2 (2019-11-08)

0.8.1 (2019-10-23)

  • Replace ready_fn with ReadyToTest action (#404)
  • Contributors: Peter Baughman

0.8.0 (2019-09-26)

  • Add an demo component not inherited from rclcpp::Node (#393)
  • Contributors: Michael Carroll

0.7.6 (2019-05-30)

0.7.5 (2019-05-29)

0.7.4 (2019-05-20)

0.7.3 (2019-05-10)

0.7.2 (2019-05-08)

  • changes to avoid deprecated API's (#332)
  • Corrected publish calls with shared_ptr signature (#327)
  • Migrate launch tests to new launch_testing features & API (#318)
  • Contributors: Michel Hidalgo, William Woodall, ivanpauno

0.7.1 (2019-04-26)

  • Renamed launch file, updated to avoid redundant default actions, and set output to screen. (#326)
  • Updated constructor to const ref to NodeOptions. (#323)
  • Added basic composition launch demo. (#324)
  • Contributors: Michael Carroll, William Woodall

0.7.0 (2019-04-14)

  • Updated for new rclcpp_components package. (#319)
  • Added launch along with launch_testing as test dependencies. (#313)
  • Dropped legacy launch API usage. (#311)
  • Contributors: Michael Carroll, Michel Hidalgo

0.6.2 (2019-01-15)

0.6.1 (2018-12-13)

0.6.0 (2018-12-07)

  • Added semicolons to all RCLCPP and RCUTILS macros. (#278)
  • Contributors: Chris Lalancette

0.5.1 (2018-06-28)

0.5.0 (2018-06-27)

  • Updated launch files to account for the "old launch" getting renamespaced as launch -> launch.legacy. (#239)
  • Updated to avoid newly deprecated class loader headers. (#229)
  • Added a periodic log message while waiting for a service response.
  • Contributors: Dirk Thomas, Michael Carroll, Mikael Arguedas, William Woodall

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged composition at Robotics Stack Exchange

Package Summary

Tags No category tags.
Version 0.36.0
License Apache License 2.0
Build type AMENT_CMAKE
Use RECOMMENDED

Repository Summary

Description
Checkout URI https://github.com/ros2/demos.git
VCS Type git
VCS Version kilted
Last Updated 2025-05-30
Dev Status DEVELOPED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

Examples for composing multiple nodes in a single process.

Additional Links

No additional links.

Maintainers

  • Aditya Pande
  • Audrow Nash

Authors

  • Dirk Thomas
  • Mabel Zhang

What Is This?

This demo provides examples of three different ways to use the rclcpp_components API to compose multiple nodes in a single process.

This ROS 2 package consists of the following demo applications:

  1. dlopen_composition
  2. linktime_composition
  3. manual_composition

Build

Run the commands below to build the ROS 2 package:

colcon build --packages-up-to composition

Run

Manual Composition

Running manual_composition compiles an executable that runs the following 4 components:

  • Talker: A ROS 2 component that publishes a string
  • Listener: A ROS 2 component that prints the received string from Talker
  • Server: A ROS 2 component that adds two integers and outputs its result to Client
  • Client: A ROS 2 component that sends two integers to Server and prints the received result from Server
ros2 run composition manual_composition

DlOpen Composition

This runs dlopen_composition which is an alternative to run-time composition by creating a generic container process and explicitly passing the libraries to load without using ROS interfaces.

First run the command to find the libraries prefix path.

ros2 pkg prefix composition

Then you can find the prefix path of the required shared libraries to load.

The process will open each library and create one instance of each “rclcpp::Node” class in the library.

ros2 run composition dlopen_composition <path_to_talker_component_shared_library> <path_to_listener_component_shared_library>

Linux

The libraries will be present in <prefix_path>/lib/ as lib*.so files.

Run the following command to load the libraries.

ros2 run composition dlopen_composition `ros2 pkg prefix composition`/lib/libtalker_component.so `ros2 pkg prefix composition`/lib/liblistener_component.so

Windows

On Windows, we will need the *.dll files. Since command substitution will not work on Windows, you have to give the absolute path of the libraries.

The libraries will be in <path_to_your_ros2_installation>\bin\, so we have to run.

ros2 run composition dlopen_composition <prefix_path>\bin\talker_component.dll <prefix_path>\bin\listener_component.dll

To get the prefix_path run

ros2 pkg prefix composition

For example if our prefix_path comes out to be C:\pixi_ws\ros2-windows\ we will run

ros2 run composition dlopen_composition C:\pixi_ws\ros2-windows\bin\talker_component.dll C:\pixi_ws\ros2-windows\bin\listener_component.dll

Linktime Composition

Similar to previous, this runs linktime_composition which links all classes from libraries that are registered under the library_path with the linker.

ros2 run composition linktime_composition

Composition Using Launch Actions

Rather than using the command line tool to run each composition, we can automate this action with ros2 launch functionality:

ros2 launch composition composition_demo_launch.py

Verify

Manual Composition

When executed correctly, strings should be printed to terminal similar to what is shown below:

[INFO] [1674528188.026468320] [talker]: Publishing: 'Hello World: 1'
[INFO] [1674528188.027043857] [listener]: I heard: [Hello World: 1]
[INFO] [1674528189.026414368] [talker]: Publishing: 'Hello World: 2'
[INFO] [1674528189.026742015] [listener]: I heard: [Hello World: 2]
[INFO] [1674528189.032512995] [Server]: Incoming request: [a: 2, b: 3]
[INFO] [1674528189.032815843] [Client]: Got result: [5]
[INFO] [1674528190.026455807] [talker]: Publishing: 'Hello World: 3'
[INFO] [1674528190.026795770] [listener]: I heard: [Hello World: 3]
[INFO] [1674528191.026457639] [talker]: Publishing: 'Hello World: 4'
[INFO] [1674528191.026801926] [listener]: I heard: [Hello World: 4]
[INFO] [1674528191.032377264] [Server]: Incoming request: [a: 2, b: 3]
[INFO] [1674528191.032604427] [Client]: Got result: [5]
[INFO] [1674528192.026428269] [talker]: Publishing: 'Hello World: 5'
[INFO] [1674528192.026537974] [listener]: I heard: [Hello World: 5]
[INFO] [1674528193.026437034] [talker]: Publishing: 'Hello World: 6'
[INFO] [1674528193.026767708] [listener]: I heard: [Hello World: 6]
[INFO] [1674528193.032377748] [Server]: Incoming request: [a: 2, b: 3]
[INFO] [1674528193.032603036] [Client]: Got result: [5]
#...

:warning:

Note that manually-composed components will not be reflected in the ros2 component list command line tool output.

DlOpen Composition

When executed correctly, strings should be printed to terminal similar to what is shown below:

INFO] [1674529118.496557668] [dlopen_composition]: Load library /opt/ros/rolling/lib/libtalker_component.so
[INFO] [1674529118.496774575] [dlopen_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate<composition::Talker>
[INFO] [1674529118.503388909] [dlopen_composition]: Load library /opt/ros/rolling/lib/liblistener_component.so
[INFO] [1674529118.503739855] [dlopen_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate<composition::Listener>
[INFO] [1674529119.503505873] [talker]: Publishing: 'Hello World: 1'
[INFO] [1674529119.503770137] [listener]: I heard: [Hello World: 1]
[INFO] [1674529120.503572362] [talker]: Publishing: 'Hello World: 2'
[INFO] [1674529120.503888374] [listener]: I heard: [Hello World: 2]
[INFO] [1674529121.503503459] [talker]: Publishing: 'Hello World: 3'
[INFO] [1674529121.503628269] [listener]: I heard: [Hello World: 3]
[INFO] [1674529122.503557862] [talker]: Publishing: 'Hello World: 4'
[INFO] [1674529122.503894772] [listener]: I heard: [Hello World: 4]
[INFO] [1674529123.503574524] [talker]: Publishing: 'Hello World: 5'
[INFO] [1674529123.503884894] [listener]: I heard: [Hello World: 5]
#...

:warning:

Note that dlopen-composed components will not be reflected in the ros2 component list command line tool output.

Linktime Composition

When executed correctly, strings should be printed to terminal similar to what is shown below:

[INFO] [1674528568.091949637] [linktime_composition]: Load library
[INFO] [1674528568.091995119] [linktime_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate<composition::Client>
[INFO] [1674528568.098833910] [linktime_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate<composition::Listener>
[INFO] [1674528568.100669644] [linktime_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate<composition::Server>
[INFO] [1674528568.102665704] [linktime_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate<composition::Talker>
[INFO] [1674528569.104717098] [talker]: Publishing: 'Hello World: 1'
[INFO] [1674528569.105206993] [listener]: I heard: [Hello World: 1]
[INFO] [1674528570.099206827] [Server]: Incoming request: [a: 2, b: 3]
[INFO] [1674528570.099376432] [Client]: Got result: [5]
[INFO] [1674528570.104656875] [talker]: Publishing: 'Hello World: 2'
[INFO] [1674528570.105069514] [listener]: I heard: [Hello World: 2]
[INFO] [1674528571.104710545] [talker]: Publishing: 'Hello World: 3'
[INFO] [1674528571.105150094] [listener]: I heard: [Hello World: 3]
[INFO] [1674528572.099350955] [Server]: Incoming request: [a: 2, b: 3]
[INFO] [1674528572.099628903] [Client]: Got result: [5]
[INFO] [1674528572.104631322] [talker]: Publishing: 'Hello World: 4'
[INFO] [1674528572.104911174] [listener]: I heard: [Hello World: 4]
[INFO] [1674528573.104596009] [talker]: Publishing: 'Hello World: 5'
[INFO] [1674528573.104751214] [listener]: I heard: [Hello World: 5]
#...

:warning:

Note that linktime-composed components will not be reflected in the ros2 component list command line tool output.

Composition Using Launch Actions

When executed correctly, strings should be printed to terminal similar to what is shown below:

[INFO] [launch]: All log files can be found below /root/.ros/log/2024-05-04-23-37-06-363020-d8ff93e471d7-9387
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [component_container-1]: process started with pid [9402]
[component_container-1] [INFO] [1714865826.695090046] [my_container]: Load Library: /opt/ros/rolling/lib/libtalker_component.so
[component_container-1] [INFO] [1714865826.696388047] [my_container]: Found class: rclcpp_components::NodeFactoryTemplate<composition::Talker>
[component_container-1] [INFO] [1714865826.696435882] [my_container]: Instantiate class: rclcpp_components::NodeFactoryTemplate<composition::Talker>
[INFO] [launch_ros.actions.load_composable_nodes]: Loaded node '/talker' in container '/my_container'
[component_container-1] [INFO] [1714865826.702958710] [my_container]: Load Library: /opt/ros/rolling/lib/liblistener_component.so
[component_container-1] [INFO] [1714865826.703401061] [my_container]: Found class: rclcpp_components::NodeFactoryTemplate<composition::Listener>
[component_container-1] [INFO] [1714865826.703414344] [my_container]: Instantiate class: rclcpp_components::NodeFactoryTemplate<composition::Listener>
[INFO] [launch_ros.actions.load_composable_nodes]: Loaded node '/listener' in container '/my_container'
[component_container-1] [INFO] [1714865827.701941449] [talker]: Publishing: 'Hello World: 1'
[component_container-1] [INFO] [1714865827.702047599] [listener]: I heard: [Hello World: 1]
[component_container-1] [INFO] [1714865828.701984118] [talker]: Publishing: 'Hello World: 2'
[component_container-1] [INFO] [1714865828.702154523] [listener]: I heard: [Hello World: 2]
[component_container-1] [INFO] [1714865829.702004471] [talker]: Publishing: 'Hello World: 3'
[component_container-1] [INFO] [1714865829.702176059] [listener]: I heard: [Hello World: 3]
[component_container-1] [INFO] [1714865830.701876733] [talker]: Publishing: 'Hello World: 4'
[component_container-1] [INFO] [1714865830.701965546] [listener]: I heard: [Hello World: 4]
[component_container-1] [INFO] [1714865831.701885355] [talker]: Publishing: 'Hello World: 5'
[component_container-1] [INFO] [1714865831.701984823] [listener]: I heard: [Hello World: 5]

FAQ

Q: Why use node composition?

A: Node composition avoids the overhead of marshalling and unmarshaling messages by allowing nodes to be instantiated within the same process.

References

  1. Composing multiple nodes in a single process
  2. About Composition
CHANGELOG

Changelog for package composition

0.36.0 (2025-04-25)

  • Uniform CMAKE min VERSION (#714)
  • Set envars to run tests with rmw_zenoh_cpp with multicast discovery (#711)
  • Use target_link_libraries instead of ament_target_dependencies (#707)
  • Contributors: Alejandro Hernández Cordero, Shane Loretz, mosfet80

0.35.1 (2024-11-20)

0.35.0 (2024-10-03)

  • Fix typo in composition comment (#703)
  • Contributors: Christophe Bedard

0.34.2 (2024-07-29)

0.34.1 (2024-06-17)

  • Change references from "jazzy" to "rolling" on the rolling branch. (#687)
  • [composition] add launch action console output in the verify section (#677)
  • Contributors: Chris Lalancette, Mikael Arguedas

0.34.0 (2024-04-26)

0.33.2 (2024-03-28)

  • Update maintainer list in package.xml files (#665)
  • Contributors: Michael Jeronimo

0.33.1 (2024-02-07)

0.33.0 (2024-01-24)

  • Migrate std::bind calls to lambda expressions (#659)
  • Contributors: Felipe Gomes de Melo

0.32.1 (2023-12-26)

0.32.0 (2023-11-06)

0.31.1 (2023-09-07)

0.31.0 (2023-08-21)

0.30.1 (2023-07-11)

0.30.0 (2023-06-12)

0.29.0 (2023-06-07)

0.28.1 (2023-05-11)

0.28.0 (2023-04-27)

0.27.0 (2023-04-13)

  • Change all ROS2 -> ROS 2. (#610)
  • Contributors: Chris Lalancette

0.26.0 (2023-04-11)

  • update launch file name format to match documentation (#588)
  • Contributors: Patrick Wspanialy

0.25.0 (2023-03-01)

0.24.1 (2023-02-24)

0.24.0 (2023-02-14)

  • Added README.md for composition (#598)
  • Update the demos to C++17. (#594)
  • [rolling] Update maintainers - 2022-11-07 (#589)
  • Contributors: Audrow Nash, Chris Lalancette, Gary Bey

0.23.0 (2022-11-02)

  • fix memory leak (#585)
  • Contributors: Chen Lihui

0.22.0 (2022-09-13)

0.21.0 (2022-04-29)

0.20.1 (2022-04-08)

0.20.0 (2022-03-01)

0.19.0 (2022-01-14)

0.18.0 (2021-12-17)

  • Update maintainers to Audrow Nash and Michael Jeronimo (#543)
  • Additional fixes for documentation in demos. (#538)
  • Contributors: Audrow Nash, Chris Lalancette

0.17.0 (2021-10-18)

  • Fixing deprecated subscriber callback warnings (#532)
  • Contributors: Abrar Rahman Protyasha

0.16.0 (2021-08-11)

0.15.0 (2021-05-14)

0.14.2 (2021-04-26)

0.14.1 (2021-04-19)

0.14.0 (2021-04-06)

0.13.0 (2021-03-25)

0.12.1 (2021-03-18)

0.12.0 (2021-01-25)

  • Fix leak(#480) (#481)
  • Contributors: y-okumura-isp

0.11.0 (2020-12-10)

  • Update the package.xml files with the latest Open Robotics maintainers (#466)
  • Contributors: Michael Jeronimo

0.10.1 (2020-09-21)

0.10.0 (2020-06-17)

0.9.3 (2020-06-01)

0.9.2 (2020-05-26)

0.9.1 (2020-05-12)

0.9.0 (2020-04-30)

  • Replace deprecated launch_ros usage (#437)
  • Update launch_ros action usage (#431)
  • code style only: wrap after open parenthesis if not in one line (#429)
  • Contributors: Dirk Thomas, Jacob Perron

0.8.4 (2019-11-19)

0.8.3 (2019-11-11)

0.8.2 (2019-11-08)

0.8.1 (2019-10-23)

  • Replace ready_fn with ReadyToTest action (#404)
  • Contributors: Peter Baughman

0.8.0 (2019-09-26)

  • Add an demo component not inherited from rclcpp::Node (#393)
  • Contributors: Michael Carroll

0.7.6 (2019-05-30)

0.7.5 (2019-05-29)

0.7.4 (2019-05-20)

0.7.3 (2019-05-10)

0.7.2 (2019-05-08)

  • changes to avoid deprecated API's (#332)
  • Corrected publish calls with shared_ptr signature (#327)
  • Migrate launch tests to new launch_testing features & API (#318)
  • Contributors: Michel Hidalgo, William Woodall, ivanpauno

0.7.1 (2019-04-26)

  • Renamed launch file, updated to avoid redundant default actions, and set output to screen. (#326)
  • Updated constructor to const ref to NodeOptions. (#323)
  • Added basic composition launch demo. (#324)
  • Contributors: Michael Carroll, William Woodall

0.7.0 (2019-04-14)

  • Updated for new rclcpp_components package. (#319)
  • Added launch along with launch_testing as test dependencies. (#313)
  • Dropped legacy launch API usage. (#311)
  • Contributors: Michael Carroll, Michel Hidalgo

0.6.2 (2019-01-15)

0.6.1 (2018-12-13)

0.6.0 (2018-12-07)

  • Added semicolons to all RCLCPP and RCUTILS macros. (#278)
  • Contributors: Chris Lalancette

0.5.1 (2018-06-28)

0.5.0 (2018-06-27)

  • Updated launch files to account for the "old launch" getting renamespaced as launch -> launch.legacy. (#239)
  • Updated to avoid newly deprecated class loader headers. (#229)
  • Added a periodic log message while waiting for a service response.
  • Contributors: Dirk Thomas, Michael Carroll, Mikael Arguedas, William Woodall

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged composition at Robotics Stack Exchange

Package Summary

Tags No category tags.
Version 0.37.0
License Apache License 2.0
Build type AMENT_CMAKE
Use RECOMMENDED

Repository Summary

Description
Checkout URI https://github.com/ros2/demos.git
VCS Type git
VCS Version rolling
Last Updated 2025-05-29
Dev Status DEVELOPED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

Examples for composing multiple nodes in a single process.

Additional Links

No additional links.

Maintainers

  • Aditya Pande
  • Audrow Nash

Authors

  • Dirk Thomas
  • Mabel Zhang

What Is This?

This demo provides examples of three different ways to use the rclcpp_components API to compose multiple nodes in a single process.

This ROS 2 package consists of the following demo applications:

  1. dlopen_composition
  2. linktime_composition
  3. manual_composition

Build

Run the commands below to build the ROS 2 package:

colcon build --packages-up-to composition

Run

Manual Composition

Running manual_composition compiles an executable that runs the following 4 components:

  • Talker: A ROS 2 component that publishes a string
  • Listener: A ROS 2 component that prints the received string from Talker
  • Server: A ROS 2 component that adds two integers and outputs its result to Client
  • Client: A ROS 2 component that sends two integers to Server and prints the received result from Server
ros2 run composition manual_composition

DlOpen Composition

This runs dlopen_composition which is an alternative to run-time composition by creating a generic container process and explicitly passing the libraries to load without using ROS interfaces.

First run the command to find the libraries prefix path.

ros2 pkg prefix composition

Then you can find the prefix path of the required shared libraries to load.

The process will open each library and create one instance of each “rclcpp::Node” class in the library.

ros2 run composition dlopen_composition <path_to_talker_component_shared_library> <path_to_listener_component_shared_library>

Linux

The libraries will be present in <prefix_path>/lib/ as lib*.so files.

Run the following command to load the libraries.

ros2 run composition dlopen_composition `ros2 pkg prefix composition`/lib/libtalker_component.so `ros2 pkg prefix composition`/lib/liblistener_component.so

Windows

On Windows, we will need the *.dll files. Since command substitution will not work on Windows, you have to give the absolute path of the libraries.

The libraries will be in <path_to_your_ros2_installation>\bin\, so we have to run.

ros2 run composition dlopen_composition <prefix_path>\bin\talker_component.dll <prefix_path>\bin\listener_component.dll

To get the prefix_path run

ros2 pkg prefix composition

For example if our prefix_path comes out to be C:\pixi_ws\ros2-windows\ we will run

ros2 run composition dlopen_composition C:\pixi_ws\ros2-windows\bin\talker_component.dll C:\pixi_ws\ros2-windows\bin\listener_component.dll

Linktime Composition

Similar to previous, this runs linktime_composition which links all classes from libraries that are registered under the library_path with the linker.

ros2 run composition linktime_composition

Composition Using Launch Actions

Rather than using the command line tool to run each composition, we can automate this action with ros2 launch functionality:

ros2 launch composition composition_demo_launch.py

Verify

Manual Composition

When executed correctly, strings should be printed to terminal similar to what is shown below:

[INFO] [1674528188.026468320] [talker]: Publishing: 'Hello World: 1'
[INFO] [1674528188.027043857] [listener]: I heard: [Hello World: 1]
[INFO] [1674528189.026414368] [talker]: Publishing: 'Hello World: 2'
[INFO] [1674528189.026742015] [listener]: I heard: [Hello World: 2]
[INFO] [1674528189.032512995] [Server]: Incoming request: [a: 2, b: 3]
[INFO] [1674528189.032815843] [Client]: Got result: [5]
[INFO] [1674528190.026455807] [talker]: Publishing: 'Hello World: 3'
[INFO] [1674528190.026795770] [listener]: I heard: [Hello World: 3]
[INFO] [1674528191.026457639] [talker]: Publishing: 'Hello World: 4'
[INFO] [1674528191.026801926] [listener]: I heard: [Hello World: 4]
[INFO] [1674528191.032377264] [Server]: Incoming request: [a: 2, b: 3]
[INFO] [1674528191.032604427] [Client]: Got result: [5]
[INFO] [1674528192.026428269] [talker]: Publishing: 'Hello World: 5'
[INFO] [1674528192.026537974] [listener]: I heard: [Hello World: 5]
[INFO] [1674528193.026437034] [talker]: Publishing: 'Hello World: 6'
[INFO] [1674528193.026767708] [listener]: I heard: [Hello World: 6]
[INFO] [1674528193.032377748] [Server]: Incoming request: [a: 2, b: 3]
[INFO] [1674528193.032603036] [Client]: Got result: [5]
#...

:warning:

Note that manually-composed components will not be reflected in the ros2 component list command line tool output.

DlOpen Composition

When executed correctly, strings should be printed to terminal similar to what is shown below:

INFO] [1674529118.496557668] [dlopen_composition]: Load library /opt/ros/rolling/lib/libtalker_component.so
[INFO] [1674529118.496774575] [dlopen_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate<composition::Talker>
[INFO] [1674529118.503388909] [dlopen_composition]: Load library /opt/ros/rolling/lib/liblistener_component.so
[INFO] [1674529118.503739855] [dlopen_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate<composition::Listener>
[INFO] [1674529119.503505873] [talker]: Publishing: 'Hello World: 1'
[INFO] [1674529119.503770137] [listener]: I heard: [Hello World: 1]
[INFO] [1674529120.503572362] [talker]: Publishing: 'Hello World: 2'
[INFO] [1674529120.503888374] [listener]: I heard: [Hello World: 2]
[INFO] [1674529121.503503459] [talker]: Publishing: 'Hello World: 3'
[INFO] [1674529121.503628269] [listener]: I heard: [Hello World: 3]
[INFO] [1674529122.503557862] [talker]: Publishing: 'Hello World: 4'
[INFO] [1674529122.503894772] [listener]: I heard: [Hello World: 4]
[INFO] [1674529123.503574524] [talker]: Publishing: 'Hello World: 5'
[INFO] [1674529123.503884894] [listener]: I heard: [Hello World: 5]
#...

:warning:

Note that dlopen-composed components will not be reflected in the ros2 component list command line tool output.

Linktime Composition

When executed correctly, strings should be printed to terminal similar to what is shown below:

[INFO] [1674528568.091949637] [linktime_composition]: Load library
[INFO] [1674528568.091995119] [linktime_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate<composition::Client>
[INFO] [1674528568.098833910] [linktime_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate<composition::Listener>
[INFO] [1674528568.100669644] [linktime_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate<composition::Server>
[INFO] [1674528568.102665704] [linktime_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate<composition::Talker>
[INFO] [1674528569.104717098] [talker]: Publishing: 'Hello World: 1'
[INFO] [1674528569.105206993] [listener]: I heard: [Hello World: 1]
[INFO] [1674528570.099206827] [Server]: Incoming request: [a: 2, b: 3]
[INFO] [1674528570.099376432] [Client]: Got result: [5]
[INFO] [1674528570.104656875] [talker]: Publishing: 'Hello World: 2'
[INFO] [1674528570.105069514] [listener]: I heard: [Hello World: 2]
[INFO] [1674528571.104710545] [talker]: Publishing: 'Hello World: 3'
[INFO] [1674528571.105150094] [listener]: I heard: [Hello World: 3]
[INFO] [1674528572.099350955] [Server]: Incoming request: [a: 2, b: 3]
[INFO] [1674528572.099628903] [Client]: Got result: [5]
[INFO] [1674528572.104631322] [talker]: Publishing: 'Hello World: 4'
[INFO] [1674528572.104911174] [listener]: I heard: [Hello World: 4]
[INFO] [1674528573.104596009] [talker]: Publishing: 'Hello World: 5'
[INFO] [1674528573.104751214] [listener]: I heard: [Hello World: 5]
#...

:warning:

Note that linktime-composed components will not be reflected in the ros2 component list command line tool output.

Composition Using Launch Actions

When executed correctly, strings should be printed to terminal similar to what is shown below:

[INFO] [launch]: All log files can be found below /root/.ros/log/2024-05-04-23-37-06-363020-d8ff93e471d7-9387
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [component_container-1]: process started with pid [9402]
[component_container-1] [INFO] [1714865826.695090046] [my_container]: Load Library: /opt/ros/rolling/lib/libtalker_component.so
[component_container-1] [INFO] [1714865826.696388047] [my_container]: Found class: rclcpp_components::NodeFactoryTemplate<composition::Talker>
[component_container-1] [INFO] [1714865826.696435882] [my_container]: Instantiate class: rclcpp_components::NodeFactoryTemplate<composition::Talker>
[INFO] [launch_ros.actions.load_composable_nodes]: Loaded node '/talker' in container '/my_container'
[component_container-1] [INFO] [1714865826.702958710] [my_container]: Load Library: /opt/ros/rolling/lib/liblistener_component.so
[component_container-1] [INFO] [1714865826.703401061] [my_container]: Found class: rclcpp_components::NodeFactoryTemplate<composition::Listener>
[component_container-1] [INFO] [1714865826.703414344] [my_container]: Instantiate class: rclcpp_components::NodeFactoryTemplate<composition::Listener>
[INFO] [launch_ros.actions.load_composable_nodes]: Loaded node '/listener' in container '/my_container'
[component_container-1] [INFO] [1714865827.701941449] [talker]: Publishing: 'Hello World: 1'
[component_container-1] [INFO] [1714865827.702047599] [listener]: I heard: [Hello World: 1]
[component_container-1] [INFO] [1714865828.701984118] [talker]: Publishing: 'Hello World: 2'
[component_container-1] [INFO] [1714865828.702154523] [listener]: I heard: [Hello World: 2]
[component_container-1] [INFO] [1714865829.702004471] [talker]: Publishing: 'Hello World: 3'
[component_container-1] [INFO] [1714865829.702176059] [listener]: I heard: [Hello World: 3]
[component_container-1] [INFO] [1714865830.701876733] [talker]: Publishing: 'Hello World: 4'
[component_container-1] [INFO] [1714865830.701965546] [listener]: I heard: [Hello World: 4]
[component_container-1] [INFO] [1714865831.701885355] [talker]: Publishing: 'Hello World: 5'
[component_container-1] [INFO] [1714865831.701984823] [listener]: I heard: [Hello World: 5]

FAQ

Q: Why use node composition?

A: Node composition avoids the overhead of marshalling and unmarshaling messages by allowing nodes to be instantiated within the same process.

References

  1. Composing multiple nodes in a single process
  2. About Composition
CHANGELOG

Changelog for package composition

0.37.0 (2025-04-25)

0.36.0 (2025-04-25)

  • Uniform CMAKE min VERSION (#714)
  • Set envars to run tests with rmw_zenoh_cpp with multicast discovery (#711)
  • Use target_link_libraries instead of ament_target_dependencies (#707)
  • Contributors: Alejandro Hernández Cordero, Shane Loretz, mosfet80

0.35.1 (2024-11-20)

0.35.0 (2024-10-03)

  • Fix typo in composition comment (#703)
  • Contributors: Christophe Bedard

0.34.2 (2024-07-29)

0.34.1 (2024-06-17)

  • Change references from "jazzy" to "rolling" on the rolling branch. (#687)
  • [composition] add launch action console output in the verify section (#677)
  • Contributors: Chris Lalancette, Mikael Arguedas

0.34.0 (2024-04-26)

0.33.2 (2024-03-28)

  • Update maintainer list in package.xml files (#665)
  • Contributors: Michael Jeronimo

0.33.1 (2024-02-07)

0.33.0 (2024-01-24)

  • Migrate std::bind calls to lambda expressions (#659)
  • Contributors: Felipe Gomes de Melo

0.32.1 (2023-12-26)

0.32.0 (2023-11-06)

0.31.1 (2023-09-07)

0.31.0 (2023-08-21)

0.30.1 (2023-07-11)

0.30.0 (2023-06-12)

0.29.0 (2023-06-07)

0.28.1 (2023-05-11)

0.28.0 (2023-04-27)

0.27.0 (2023-04-13)

  • Change all ROS2 -> ROS 2. (#610)
  • Contributors: Chris Lalancette

0.26.0 (2023-04-11)

  • update launch file name format to match documentation (#588)
  • Contributors: Patrick Wspanialy

0.25.0 (2023-03-01)

0.24.1 (2023-02-24)

0.24.0 (2023-02-14)

  • Added README.md for composition (#598)
  • Update the demos to C++17. (#594)
  • [rolling] Update maintainers - 2022-11-07 (#589)
  • Contributors: Audrow Nash, Chris Lalancette, Gary Bey

0.23.0 (2022-11-02)

  • fix memory leak (#585)
  • Contributors: Chen Lihui

0.22.0 (2022-09-13)

0.21.0 (2022-04-29)

0.20.1 (2022-04-08)

0.20.0 (2022-03-01)

0.19.0 (2022-01-14)

0.18.0 (2021-12-17)

  • Update maintainers to Audrow Nash and Michael Jeronimo (#543)
  • Additional fixes for documentation in demos. (#538)
  • Contributors: Audrow Nash, Chris Lalancette

0.17.0 (2021-10-18)

  • Fixing deprecated subscriber callback warnings (#532)
  • Contributors: Abrar Rahman Protyasha

0.16.0 (2021-08-11)

0.15.0 (2021-05-14)

0.14.2 (2021-04-26)

0.14.1 (2021-04-19)

0.14.0 (2021-04-06)

0.13.0 (2021-03-25)

0.12.1 (2021-03-18)

0.12.0 (2021-01-25)

  • Fix leak(#480) (#481)
  • Contributors: y-okumura-isp

0.11.0 (2020-12-10)

  • Update the package.xml files with the latest Open Robotics maintainers (#466)
  • Contributors: Michael Jeronimo

0.10.1 (2020-09-21)

0.10.0 (2020-06-17)

0.9.3 (2020-06-01)

0.9.2 (2020-05-26)

0.9.1 (2020-05-12)

0.9.0 (2020-04-30)

  • Replace deprecated launch_ros usage (#437)
  • Update launch_ros action usage (#431)
  • code style only: wrap after open parenthesis if not in one line (#429)
  • Contributors: Dirk Thomas, Jacob Perron

0.8.4 (2019-11-19)

0.8.3 (2019-11-11)

0.8.2 (2019-11-08)

0.8.1 (2019-10-23)

  • Replace ready_fn with ReadyToTest action (#404)
  • Contributors: Peter Baughman

0.8.0 (2019-09-26)

  • Add an demo component not inherited from rclcpp::Node (#393)
  • Contributors: Michael Carroll

0.7.6 (2019-05-30)

0.7.5 (2019-05-29)

0.7.4 (2019-05-20)

0.7.3 (2019-05-10)

0.7.2 (2019-05-08)

  • changes to avoid deprecated API's (#332)
  • Corrected publish calls with shared_ptr signature (#327)
  • Migrate launch tests to new launch_testing features & API (#318)
  • Contributors: Michel Hidalgo, William Woodall, ivanpauno

0.7.1 (2019-04-26)

  • Renamed launch file, updated to avoid redundant default actions, and set output to screen. (#326)
  • Updated constructor to const ref to NodeOptions. (#323)
  • Added basic composition launch demo. (#324)
  • Contributors: Michael Carroll, William Woodall

0.7.0 (2019-04-14)

  • Updated for new rclcpp_components package. (#319)
  • Added launch along with launch_testing as test dependencies. (#313)
  • Dropped legacy launch API usage. (#311)
  • Contributors: Michael Carroll, Michel Hidalgo

0.6.2 (2019-01-15)

0.6.1 (2018-12-13)

0.6.0 (2018-12-07)

  • Added semicolons to all RCLCPP and RCUTILS macros. (#278)
  • Contributors: Chris Lalancette

0.5.1 (2018-06-28)

0.5.0 (2018-06-27)

  • Updated launch files to account for the "old launch" getting renamespaced as launch -> launch.legacy. (#239)
  • Updated to avoid newly deprecated class loader headers. (#229)
  • Added a periodic log message while waiting for a service response.
  • Contributors: Dirk Thomas, Michael Carroll, Mikael Arguedas, William Woodall

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged composition at Robotics Stack Exchange

composition package from openrobotics repo

ros2_ballbot ros2_cartpole ros2_double_integrator ros2_quadrotor ros2_robot_vacuum ros2_vacuum_gazebo ros2_vacuum_slam action common_utils composition executors gazebo_camera gazebo_spawner lifecycle params pointcloud_subsriber rviz service system_monitor tf2_demos timer topic tutorials_msgs urdf decomp_ros decomp_ros_msgs decomp_ros_utils decomp_test_node ros2_math casadi_cpp casadi_python casadi_tutorials nav2_linear_quadratic_regulator_controller motion_model mpc_controller pid_controller robotic_assets ros2_controller ros2_controller_msgs waypoint_generator behavior_tree bspline carlike_simulator fast_methods forest_map_generator gridmap_ros map_generator nav2_demos a_star_planner breadth_first_search_planner bug_planner cubic_spline_planner d_star_lite_planner d_star_planner depth_first_planner dijkstra_planner dubins_path_planner eta3_spline_planner flow_filed_planner frenet_optimal_trajectory_planner greedy_best_first_search_planner hybrid_a_star_planner informed_rrt_star_planner nav2_straightline_planner path_planning potential_field_planner quintic_polynomials_planner rrt_dubins_planner rrt_planner rrt_star_planner state_lattice_planner voronoi_planner wave_front_planner cgmres_nmpc_tracking lqr_speed_steer_control_tracking model_predictive_speed_steer_control_tracking path_tracking pure_pursuit_tracking rear_wheel_feedback_tracking stanley_controller_tracking ros2_navigation ros2_system_test sdf_tools trajectory local_sensing multi_map_server odom_visualization pose_utils quadrotor_msgs so3_disturbance_generator so3_quadrotor_simulator uav_utils visualization_tools voronoi_layer quad_behavior_tree quad_bringup quad_bt_navigator quad_common quad_controller quad_core quad_costmap quad_global_planner quad_local_planner quad_logger quad_map_server quad_msgs quad_nmpc_controller quad_planner quad_robot_driver quad_rviz_plugins a1_description a1_simulation quad_gazebo spirit_description spirit_gazebo spirit_simulation quad_system_tests quad_teleop quad_utils ros2_quadruped gazebo_examples sam_bot_description velodyne_description velodyne_gazebo_plugins velodyne_simulator

Package Summary

Tags No category tags.
Version 0.0.0
License TODO: License declaration
Build type AMENT_CMAKE
Use RECOMMENDED

Repository Summary

Description ROS2 navigaiton tutorials and do quadruped robot
Checkout URI https://github.com/duyongquan/openrobotics.git
VCS Type git
VCS Version main
Last Updated 2024-01-16
Dev Status UNKNOWN
CI status No Continuous Integration
Released UNRELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

TODO: Package description

Additional Links

No additional links.

Maintainers

  • quan

Authors

No additional authors.
README
No README found. See repository README.
CHANGELOG
No CHANGELOG found.

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Package Dependencies

System Dependencies

No direct system dependencies.

Dependant Packages

No known dependants.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged composition at Robotics Stack Exchange

No version for distro noetic. Known supported distros are highlighted in the buttons above.

Package Summary

Tags No category tags.
Version 0.14.4
License Apache License 2.0
Build type AMENT_CMAKE
Use RECOMMENDED

Repository Summary

Description
Checkout URI https://github.com/ros2/demos.git
VCS Type git
VCS Version galactic
Last Updated 2022-12-07
Dev Status DEVELOPED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

Examples for composing multiple nodes in a single process.

Additional Links

No additional links.

Maintainers

  • Mabel Zhang
  • Michael Jeronimo

Authors

  • Dirk Thomas
README
No README found. No README in repository either.
CHANGELOG

Changelog for package composition

0.14.4 (2022-12-06)

0.14.3 (2021-05-10)

0.14.2 (2021-04-26)

0.14.1 (2021-04-19)

0.14.0 (2021-04-06)

0.13.0 (2021-03-25)

0.12.1 (2021-03-18)

0.12.0 (2021-01-25)

  • Fix leak(#480) (#481)
  • Contributors: y-okumura-isp

0.11.0 (2020-12-10)

  • Update the package.xml files with the latest Open Robotics maintainers (#466)
  • Contributors: Michael Jeronimo

0.10.1 (2020-09-21)

0.10.0 (2020-06-17)

0.9.3 (2020-06-01)

0.9.2 (2020-05-26)

0.9.1 (2020-05-12)

0.9.0 (2020-04-30)

  • Replace deprecated launch_ros usage (#437)
  • Update launch_ros action usage (#431)
  • code style only: wrap after open parenthesis if not in one line (#429)
  • Contributors: Dirk Thomas, Jacob Perron

0.8.4 (2019-11-19)

0.8.3 (2019-11-11)

0.8.2 (2019-11-08)

0.8.1 (2019-10-23)

  • Replace ready_fn with ReadyToTest action (#404)
  • Contributors: Peter Baughman

0.8.0 (2019-09-26)

  • Add an demo component not inherited from rclcpp::Node (#393)
  • Contributors: Michael Carroll

0.7.6 (2019-05-30)

0.7.5 (2019-05-29)

0.7.4 (2019-05-20)

0.7.3 (2019-05-10)

0.7.2 (2019-05-08)

  • changes to avoid deprecated API's (#332)
  • Corrected publish calls with shared_ptr signature (#327)
  • Migrate launch tests to new launch_testing features & API (#318)
  • Contributors: Michel Hidalgo, William Woodall, ivanpauno

0.7.1 (2019-04-26)

  • Renamed launch file, updated to avoid redundant default actions, and set output to screen. (#326)
  • Updated constructor to const ref to NodeOptions. (#323)
  • Added basic composition launch demo. (#324)
  • Contributors: Michael Carroll, William Woodall

0.7.0 (2019-04-14)

  • Updated for new rclcpp_components package. (#319)
  • Added launch along with launch_testing as test dependencies. (#313)
  • Dropped legacy launch API usage. (#311)
  • Contributors: Michael Carroll, Michel Hidalgo

0.6.2 (2019-01-15)

0.6.1 (2018-12-13)

0.6.0 (2018-12-07)

  • Added semicolons to all RCLCPP and RCUTILS macros. (#278)
  • Contributors: Chris Lalancette

0.5.1 (2018-06-28)

0.5.0 (2018-06-27)

  • Updated launch files to account for the "old launch" getting renamespaced as launch -> launch.legacy. (#239)
  • Updated to avoid newly deprecated class loader headers. (#229)
  • Added a periodic log message while waiting for a service response.
  • Contributors: Dirk Thomas, Michael Carroll, Mikael Arguedas, William Woodall

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged composition at Robotics Stack Exchange

Package Summary

Tags No category tags.
Version 0.27.2
License Apache License 2.0
Build type AMENT_CMAKE
Use RECOMMENDED

Repository Summary

Description
Checkout URI https://github.com/ros2/demos.git
VCS Type git
VCS Version iron
Last Updated 2024-07-11
Dev Status DEVELOPED
CI status No Continuous Integration
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

Examples for composing multiple nodes in a single process.

Additional Links

No additional links.

Maintainers

  • Aditya Pande
  • Audrow Nash
  • Michael Jeronimo

Authors

  • Dirk Thomas
  • Mabel Zhang

What Is This?

This demo provides examples of three different ways to use the rclcpp_components API to compose multiple nodes in a single process.

This ROS 2 package consists of the following demo applications:

  1. dlopen_composition
  2. linktime_composition
  3. manual_composition

Build

Run the commands below to build the ROS 2 package:

colcon build --packages-up-to composition

Run

Manual Composition

Running manual_composition compiles an executable that runs the following 4 components:

  • Talker: A ROS 2 component that publishes a string
  • Listener: A ROS 2 component that prints the received string from Talker
  • Server: A ROS 2 component that adds two integers and outputs its result to Client
  • Client: A ROS 2 component that sends two integers to Server and prints the received result from Server
ros2 run composition manual_composition

DlOpen Composition

This runs dlopen_composition which is an alternative to run-time composition by creating a generic container process and explicitly passing the libraries to load without using ROS interfaces.

The process will open each library and create one instance of each “rclcpp::Node” class in the library.

ros2 run composition dlopen_composition `ros2 pkg prefix composition`/lib/libtalker_component.so `ros2 pkg prefix composition`/lib/liblistener_component.so

Linktime Composition

Similar to previous, this runs linktime_composition which links all classes from libraries that are registered under the library_path with the linker.

ros2 run composition linktime_composition

Composition Using Launch Actions

Rather than using the command line tool to run each composition, we can automate this action with ros2 launch functionality:

ros2 launch composition composition_demo_launch.py

Verify

Manual Composition

When executed correctly, strings should be printed to terminal similar to what is shown below:

[INFO] [1674528188.026468320] [talker]: Publishing: 'Hello World: 1'
[INFO] [1674528188.027043857] [listener]: I heard: [Hello World: 1]
[INFO] [1674528189.026414368] [talker]: Publishing: 'Hello World: 2'
[INFO] [1674528189.026742015] [listener]: I heard: [Hello World: 2]
[INFO] [1674528189.032512995] [Server]: Incoming request: [a: 2, b: 3]
[INFO] [1674528189.032815843] [Client]: Got result: [5]
[INFO] [1674528190.026455807] [talker]: Publishing: 'Hello World: 3'
[INFO] [1674528190.026795770] [listener]: I heard: [Hello World: 3]
[INFO] [1674528191.026457639] [talker]: Publishing: 'Hello World: 4'
[INFO] [1674528191.026801926] [listener]: I heard: [Hello World: 4]
[INFO] [1674528191.032377264] [Server]: Incoming request: [a: 2, b: 3]
[INFO] [1674528191.032604427] [Client]: Got result: [5]
[INFO] [1674528192.026428269] [talker]: Publishing: 'Hello World: 5'
[INFO] [1674528192.026537974] [listener]: I heard: [Hello World: 5]
[INFO] [1674528193.026437034] [talker]: Publishing: 'Hello World: 6'
[INFO] [1674528193.026767708] [listener]: I heard: [Hello World: 6]
[INFO] [1674528193.032377748] [Server]: Incoming request: [a: 2, b: 3]
[INFO] [1674528193.032603036] [Client]: Got result: [5]
#...

:warning:

Note that manually-composed components will not be reflected in the ros2 component list command line tool output.

DlOpen Composition

When executed correctly, strings should be printed to terminal similar to what is shown below:

INFO] [1674529118.496557668] [dlopen_composition]: Load library /opt/ros/rolling/lib/libtalker_component.so
[INFO] [1674529118.496774575] [dlopen_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate<composition::Talker>
[INFO] [1674529118.503388909] [dlopen_composition]: Load library /opt/ros/rolling/lib/liblistener_component.so
[INFO] [1674529118.503739855] [dlopen_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate<composition::Listener>
[INFO] [1674529119.503505873] [talker]: Publishing: 'Hello World: 1'
[INFO] [1674529119.503770137] [listener]: I heard: [Hello World: 1]
[INFO] [1674529120.503572362] [talker]: Publishing: 'Hello World: 2'
[INFO] [1674529120.503888374] [listener]: I heard: [Hello World: 2]
[INFO] [1674529121.503503459] [talker]: Publishing: 'Hello World: 3'
[INFO] [1674529121.503628269] [listener]: I heard: [Hello World: 3]
[INFO] [1674529122.503557862] [talker]: Publishing: 'Hello World: 4'
[INFO] [1674529122.503894772] [listener]: I heard: [Hello World: 4]
[INFO] [1674529123.503574524] [talker]: Publishing: 'Hello World: 5'
[INFO] [1674529123.503884894] [listener]: I heard: [Hello World: 5]
#...

:warning:

Note that dlopen-composed components will not be reflected in the ros2 component list command line tool output.

Linktime Composition

When executed correctly, strings should be printed to terminal similar to what is shown below:

[INFO] [1674528568.091949637] [linktime_composition]: Load library
[INFO] [1674528568.091995119] [linktime_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate<composition::Client>
[INFO] [1674528568.098833910] [linktime_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate<composition::Listener>
[INFO] [1674528568.100669644] [linktime_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate<composition::Server>
[INFO] [1674528568.102665704] [linktime_composition]: Instantiate class rclcpp_components::NodeFactoryTemplate<composition::Talker>
[INFO] [1674528569.104717098] [talker]: Publishing: 'Hello World: 1'
[INFO] [1674528569.105206993] [listener]: I heard: [Hello World: 1]
[INFO] [1674528570.099206827] [Server]: Incoming request: [a: 2, b: 3]
[INFO] [1674528570.099376432] [Client]: Got result: [5]
[INFO] [1674528570.104656875] [talker]: Publishing: 'Hello World: 2'
[INFO] [1674528570.105069514] [listener]: I heard: [Hello World: 2]
[INFO] [1674528571.104710545] [talker]: Publishing: 'Hello World: 3'
[INFO] [1674528571.105150094] [listener]: I heard: [Hello World: 3]
[INFO] [1674528572.099350955] [Server]: Incoming request: [a: 2, b: 3]
[INFO] [1674528572.099628903] [Client]: Got result: [5]
[INFO] [1674528572.104631322] [talker]: Publishing: 'Hello World: 4'
[INFO] [1674528572.104911174] [listener]: I heard: [Hello World: 4]
[INFO] [1674528573.104596009] [talker]: Publishing: 'Hello World: 5'
[INFO] [1674528573.104751214] [listener]: I heard: [Hello World: 5]
#...

:warning:

Note that linktime-composed components will not be reflected in the ros2 component list command line tool output.

Composition Using Launch Actions

When executed correctly, strings should be printed to terminal similar to what is shown below:

[INFO] [launch]: All log files can be found below /root/.ros/log/2024-05-04-23-37-06-363020-d8ff93e471d7-9387
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [component_container-1]: process started with pid [9402]
[component_container-1] [INFO] [1714865826.695090046] [my_container]: Load Library: /opt/ros/iron/lib/libtalker_component.so
[component_container-1] [INFO] [1714865826.696388047] [my_container]: Found class: rclcpp_components::NodeFactoryTemplate<composition::Talker>
[component_container-1] [INFO] [1714865826.696435882] [my_container]: Instantiate class: rclcpp_components::NodeFactoryTemplate<composition::Talker>
[INFO] [launch_ros.actions.load_composable_nodes]: Loaded node '/talker' in container '/my_container'
[component_container-1] [INFO] [1714865826.702958710] [my_container]: Load Library: /opt/ros/iron/lib/liblistener_component.so
[component_container-1] [INFO] [1714865826.703401061] [my_container]: Found class: rclcpp_components::NodeFactoryTemplate<composition::Listener>
[component_container-1] [INFO] [1714865826.703414344] [my_container]: Instantiate class: rclcpp_components::NodeFactoryTemplate<composition::Listener>
[INFO] [launch_ros.actions.load_composable_nodes]: Loaded node '/listener' in container '/my_container'
[component_container-1] [INFO] [1714865827.701941449] [talker]: Publishing: 'Hello World: 1'
[component_container-1] [INFO] [1714865827.702047599] [listener]: I heard: [Hello World: 1]
[component_container-1] [INFO] [1714865828.701984118] [talker]: Publishing: 'Hello World: 2'
[component_container-1] [INFO] [1714865828.702154523] [listener]: I heard: [Hello World: 2]
[component_container-1] [INFO] [1714865829.702004471] [talker]: Publishing: 'Hello World: 3'
[component_container-1] [INFO] [1714865829.702176059] [listener]: I heard: [Hello World: 3]
[component_container-1] [INFO] [1714865830.701876733] [talker]: Publishing: 'Hello World: 4'
[component_container-1] [INFO] [1714865830.701965546] [listener]: I heard: [Hello World: 4]
[component_container-1] [INFO] [1714865831.701885355] [talker]: Publishing: 'Hello World: 5'
[component_container-1] [INFO] [1714865831.701984823] [listener]: I heard: [Hello World: 5]

FAQ

Q: Why use node composition?

A: Node composition avoids the overhead of marshalling and unmarshaling messages by allowing nodes to be instantiated within the same process.

References

  1. Composing multiple nodes in a single process
  2. About Composition
CHANGELOG

Changelog for package composition

0.27.2 (2024-07-10)

  • Add launch action console output in the verify section (#683)
  • Contributors: Mikael Arguedas

0.27.1 (2023-05-11)

0.27.0 (2023-04-13)

  • Change all ROS2 -> ROS 2. (#610)
  • Contributors: Chris Lalancette

0.26.0 (2023-04-11)

  • update launch file name format to match documentation (#588)
  • Contributors: Patrick Wspanialy

0.25.0 (2023-03-01)

0.24.1 (2023-02-24)

0.24.0 (2023-02-14)

  • Added README.md for composition (#598)
  • Update the demos to C++17. (#594)
  • [rolling] Update maintainers - 2022-11-07 (#589)
  • Contributors: Audrow Nash, Chris Lalancette, Gary Bey

0.23.0 (2022-11-02)

  • fix memory leak (#585)
  • Contributors: Chen Lihui

0.22.0 (2022-09-13)

0.21.0 (2022-04-29)

0.20.1 (2022-04-08)

0.20.0 (2022-03-01)

0.19.0 (2022-01-14)

0.18.0 (2021-12-17)

  • Update maintainers to Audrow Nash and Michael Jeronimo (#543)
  • Additional fixes for documentation in demos. (#538)
  • Contributors: Audrow Nash, Chris Lalancette

0.17.0 (2021-10-18)

  • Fixing deprecated subscriber callback warnings (#532)
  • Contributors: Abrar Rahman Protyasha

0.16.0 (2021-08-11)

0.15.0 (2021-05-14)

0.14.2 (2021-04-26)

0.14.1 (2021-04-19)

0.14.0 (2021-04-06)

0.13.0 (2021-03-25)

0.12.1 (2021-03-18)

0.12.0 (2021-01-25)

  • Fix leak(#480) (#481)
  • Contributors: y-okumura-isp

0.11.0 (2020-12-10)

  • Update the package.xml files with the latest Open Robotics maintainers (#466)
  • Contributors: Michael Jeronimo

0.10.1 (2020-09-21)

0.10.0 (2020-06-17)

0.9.3 (2020-06-01)

0.9.2 (2020-05-26)

0.9.1 (2020-05-12)

0.9.0 (2020-04-30)

  • Replace deprecated launch_ros usage (#437)
  • Update launch_ros action usage (#431)
  • code style only: wrap after open parenthesis if not in one line (#429)
  • Contributors: Dirk Thomas, Jacob Perron

0.8.4 (2019-11-19)

0.8.3 (2019-11-11)

0.8.2 (2019-11-08)

0.8.1 (2019-10-23)

  • Replace ready_fn with ReadyToTest action (#404)
  • Contributors: Peter Baughman

0.8.0 (2019-09-26)

  • Add an demo component not inherited from rclcpp::Node (#393)
  • Contributors: Michael Carroll

0.7.6 (2019-05-30)

0.7.5 (2019-05-29)

0.7.4 (2019-05-20)

0.7.3 (2019-05-10)

0.7.2 (2019-05-08)

  • changes to avoid deprecated API's (#332)
  • Corrected publish calls with shared_ptr signature (#327)
  • Migrate launch tests to new launch_testing features & API (#318)
  • Contributors: Michel Hidalgo, William Woodall, ivanpauno

0.7.1 (2019-04-26)

  • Renamed launch file, updated to avoid redundant default actions, and set output to screen. (#326)
  • Updated constructor to const ref to NodeOptions. (#323)
  • Added basic composition launch demo. (#324)
  • Contributors: Michael Carroll, William Woodall

0.7.0 (2019-04-14)

  • Updated for new rclcpp_components package. (#319)
  • Added launch along with launch_testing as test dependencies. (#313)
  • Dropped legacy launch API usage. (#311)
  • Contributors: Michael Carroll, Michel Hidalgo

0.6.2 (2019-01-15)

0.6.1 (2018-12-13)

0.6.0 (2018-12-07)

  • Added semicolons to all RCLCPP and RCUTILS macros. (#278)
  • Contributors: Chris Lalancette

0.5.1 (2018-06-28)

0.5.0 (2018-06-27)

  • Updated launch files to account for the "old launch" getting renamespaced as launch -> launch.legacy. (#239)
  • Updated to avoid newly deprecated class loader headers. (#229)
  • Added a periodic log message while waiting for a service response.
  • Contributors: Dirk Thomas, Michael Carroll, Mikael Arguedas, William Woodall

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged composition at Robotics Stack Exchange

No version for distro melodic. Known supported distros are highlighted in the buttons above.