Skip to main content

LiveKit Portal for ROS composition

Load the LiveKit Portal for ROS as a ROS 2 component and use intra-process communication.

Overview

The LiveKit Portal for ROS can run as a ROS 2 component  inside a component container, a process that loads and runs several nodes. This setup is called composition. Nodes in the same container can exchange messages through intra-process communication instead of the ROS middleware,so the portal can receive high-bandwidth topics such as camera images, point clouds, and other large data types without serializing them.

The package exports the ros_portal::RosPortal component. Composition requires v0.3.0  or later of LiveKit Portal for ROS.

Add the portal to your ComposableNodeContainer

Add a ComposableNode for ros_portal::RosPortal to the container that runs your other nodes. Use a single-threaded container such as component_container:

from launch_ros.actions import ComposableNodeContainer
from launch_ros.descriptions import ComposableNode
container = ComposableNodeContainer(
name='robot_container',
namespace='',
package='rclcpp_components',
executable='component_container',
composable_node_descriptions=[
ComposableNode(
package='ros_portal',
plugin='ros_portal::RosPortal',
name='ros_portal',
parameters=[{'config_path': '/path/to/config.yaml'}],
),
# Add other composable nodes here
],
)

In composition, the container owns the executor, so the node ignores the ros_threads configuration field. If the configuration is invalid or LiveKit fails to initialize, the component fails to load and the container logs the error.

Intra-process communication

Intra-process communication reduces transport overhead and latency for high-bandwidth topics, such as camera images. To use intra-process communication, all of the following must be true:

  • The ROS Portal and its peer nodes run in the same process and have the same ROS context.
  • The ROS Portal and its peer nodes enable use_intra_process_comms.
  • The publishers and subscriptions use compatible QoS.

Enable intra-process communication in each ComposableNode description:

extra_arguments=[{'use_intra_process_comms': True}],

How a producer publishes affects whether ROS copies the message before the ROS Portal receives it. Both styles forward the topic. Only the copy differs.

How the producer publishesResult
publish(std::move(unique_msg))If the ROS Portal is the only local subscriber, the original message and pixel buffer reach it without a ROS copy. Other subscribers can make ROS copy it.
publish(shared_msg) or publish(*shared_msg)Works with existing publishers. On Jazzy, ROS copies the message into its own storage before intra-process communication delivery.

Intra-process communication has the following limitations:

  • Intra-process communication reduces ROS delivery overhead only. Video encoding, decoding, and LiveKit networking still copy data.
  • The ROS Portal republishes inbound LiveKit video as sensor_msgs/CompressedImage, and ROS copies it to local subscribers.
  • On Jazzy, generic serialized topics don't use rclcpp intra-process delivery.
  • Only one ROS Portal can be loaded in a process.

Additional resources

The following resource provides more information about running LiveKit Portal for ROS.

Running LiveKit Portal for ROS

The full guide to running LiveKit Portal for ROS with Docker, Debian packages, and composition.