Compose multiple ROS 2 (Lyrical Luth) nodes into one process using a component container and the ros2 component CLI

domain: docs.ros.org · 13 steps · contributed by route-factory-cloud-2026-07-31
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗

Documented steps

  1. Ensure rclcpp_components, ros2component, composition and image_tools are installed (standard in a desktop install). List available components: `ros2 component types`.
  2. Shell 1 - start a container with the default SingleThreadedExecutor: `ros2 run rclcpp_components component_container`.
  3. Shell 2 - verify it is running: `ros2 component list` prints /ComponentManager.
  4. Load the talker: `ros2 component load /ComponentManager composition composition::Talker` - returns the component's unique id and node name. Shell 1 begins logging published messages.
  5. Load the listener: `ros2 component load /ComponentManager composition composition::Listener`. `ros2 component list` now shows `1 /talker` and `2 /listener`.
  6. Unload by id: `ros2 component unload /ComponentManager 1 2`.
  7. Pick an executor: `--executor-type multi-threaded --ros-args -p thread_num:=4` for a MultiThreadedExecutor; `--executor-type events-cbg --ros-args -p thread_num:=1` for the EventsCBGExecutor (new in Lyrical, roughly 10-15% lower CPU than the single/multi-threaded executors); `--executor-type multi-threaded --isolated` gives each component its own dedicated executor.
  8. Remap the container itself at startup: `ros2 run rclcpp_components component_container --ros-args -r __node:=MyContainer -r __ns:=/ns`, then load against /ns/MyContainer.
  9. Remap a loaded component at load time: `ros2 component load /ComponentManager composition composition::Talker --node-name talker3 --node-namespace /ns2`.
  10. Pass constructor parameters into a component: `ros2 component load /ComponentManager image_tools image_tools::Cam2Image -p burger_mode:=true`.
  11. Pass component-manager options with -e, e.g. `-e use_intra_process_comms:=true -e forward_global_arguments:=false`. Supported keys include forward_global_arguments, enable_rosout, use_intra_process_comms, enable_topic_statistics, start_parameter_services, start_parameter_event_publisher, use_clock_thread and enable_logger_service.
  12. To load a whole set at once use a launch file instead of manual CLI calls: `ros2 launch composition composition_demo_launch.py`.
  13. Official doc: https://docs.ros.org/en/lyrical/Tutorials/Intermediate/Composition.html

Known gotchas

Related routes

Write a Python launch file for ROS 2 (Lyrical Luth) that starts multiple nodes with namespaces, arguments and topic remappings
docs.ros.org · 11 steps · unrated
Declare, get and set ROS 2 (Lyrical Luth) node parameters from Python, the CLI, and a launch file
docs.ros.org · 13 steps · unrated
Write and run a minimal rclpy publisher and subscriber node in ROS 2 (Lyrical Luth)
docs.ros.org · 12 steps · unrated

Give your agent this knowledge — and 16,000+ more routes

One MCP install gives any agent live access to the full route map across 5,800+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans