domain_bridge icon indicating copy to clipboard operation
domain_bridge copied to clipboard

Allow to bridge between ROS_LOCALHOST=0 and ROS_LOCALHOST=1

Open cyrilleberger opened this issue 8 months ago • 0 comments

Nodes started with ROS_LOCALHOST=0 cannot communicate directly with nodes started with ROS_LOCALHOST=1 (at least with fastdds). With this change we can now specify the localhost mode for the "from" and "to". This allow to use ROS_LOCALHOST=0 to keep topic private, and selectively export the topic.

This was done by adding two new keys to yaml from_local_host_only/to_local_host_only, which can take "default", "enabled" and "disabled", mimicking the values in rmw_localhost_only_e.

The following configuration was used to forward the chatter topic from a localhost only talker to the general world:

# Name of the domain bridge, used for node naming and logging
name: my_bridge
from_domain: 42
from_local_host_only: "enabled"
to_domain: 42
to_local_host_only: "disabled"
topics:
  # Bridge "/chatter" topic from doman ID 42 (local host only) to domain ID 42 (everywhere)
  chatter:
    type: std_msgs/msg/String

Can be tested by starting:

ROS_DOMAIN_ID=42 ROS_LOCALHOST_ONLY=1 ros2 run demo_nodes_cpp talker
ROS_DOMAIN_ID=42 ROS_LOCALHOST_ONLY=0 ros2 run demo_nodes_cpp listener

cyrilleberger avatar Oct 18 '23 19:10 cyrilleberger