As part of the upcoming Iron Irwini release, Open Robotics is planning to address a couple of common requests/complaints regarding DDS behaviour in ROS 2:
- nodes can too-easily discover other nodes that are not part of their application, leading to, for example, robots suddenly moving; and
- discovery traffic by default goes everywhere, flooding networks, which can bring down networks or at least degrade network performance significantly.
ROS 2 currently includes a ROS_LOCALHOST_ONLY
environment variable.
Setting this environment variable to a true value causes ROS 2 nodes to only perform discovery on the local machine.
In effect, it isolates an application from the network.
This is useful for preventing the accidental discovery and control of robots, and for preventing a discovery storm on the local network segment.
However it does not satisfy all use cases: if you wish to control a robot you have to have discovery traffic going over the entire network segment, and you must coordinate DDS domain IDs to prevent accidental control of other robots.
To make control of discovery both easier and more fine-grained, in Iron Irwini we are considering doing the following.
- Deprecating the
ROS_LOCALHOST_ONLY
environment variable. - Adding a new environment variable,
ROS_AUTOMATIC_DISCOVERY_RANGE
, which will control how far discovery traffic for the automatic discovery process can travel. - Adding a new environment variable,
ROS_STATIC_PEERS
, which will allow users to specify the address(es) of other hosts (robots, etc.) to connect to.
The ROS_AUTOMATIC_DISCOVERY_RANGE
variable will accept the following values.
-
1
: Disable automatic discovery. No other nodes will be found automatically, even on the same host. -
2
: Limit automatic discovery to the local host only. Nodes on the same host will be automatically found, unless they disable their own automatic discovery, but no discovery traffic will leave the host. -
3
: Enable automatic discovery on the local subnet. Nodes on other hosts that are on the same subnet will be found automatically, unless they disable their own automatic discovery.
The ROS_STATIC_PEERS
variable will accept a semi-colon-separated list of addresses (IP addresses and hostnames searchable via DNS).
All nodes on the hosts specified in this variable will be discovered, even if they have turned off automatic discovery.
The combination of these two variables will enable, for example, automatically discovering only nodes on the local host, while also talking to a robot at a known address, but nothing else on the network.
The interaction of these two variables can be a little difficult to grasp.
The below tables will help, we hope.
A indicates that nodes A and B will not discover each other and communicate.
A indicates that nodes A and B will discover each other and communicate.
Same host | Node B setting | |||||||
---|---|---|---|---|---|---|---|---|
No static peer | With static peer | |||||||
Off | Localhost | Subnet | Off | Localhost | Subnet | |||
Node A setting | No static peer | Off | ||||||
Localhost | ||||||||
Subnet | ||||||||
With static peer | Off | |||||||
Localhost | ||||||||
Subnet |
Different hosts | Node B setting | |||||||
---|---|---|---|---|---|---|---|---|
No static peer | With static peer | |||||||
Off | Localhost | Subnet | Off | Localhost | Subnet | |||
Node A setting | No static peer | Off | ||||||
Localhost | ||||||||
Subnet | ||||||||
With static peer | Off | |||||||
Localhost | ||||||||
Subnet |
Note that only one of the two hosts needs to set a static peer address for communication to succeed.
We chose this approach to allow a host to communicate with a robot without needing to change the configuration of the robot.
A value for ROS_AUTOMATIC_DISCOVERY_RANGE
of 3
and an empty ROS_STATIC_PEERS
is equivalent to the current default in Humble Hawksbill.
A value for ROS_AUTOMATIC_DISCOVERY_RANGE
of 2
and an empty ROS_STATIC_PEERS
is equivalent to setting ROS_LOCALHOST_ONLY
in Humble Hawksbill.
As part of the above changes, we are also considering making the default value for ROS_AUTOMATIC_DISCOVERY_RANGE
to be 2
, therefore preventing network connections as the default.
We believe this should satisfy many common use cases for ROS 2.
However we are aware that there are complex corner cases that may not be satisfied.
What we want to hear from ROS 2 users is:
- does this satisfy your use case(s)?
- are there any situations where you would have problems with these variables?
- are there alternative settings that should be exposed that would better address the same problems?
- what would you like the default values for these to be?
If you want to try these variables out, you can do so already.
You will need to compile ROS 2 Rolling Ridley from source, using the following branches in these repositories.
- Branch
gbiggs/discovery-peers-specification
for thercl
repository. - Branch
gbiggs/discovery-peers-specification
for thermw
repository. - Branch
gbiggs/discovery-peers-specification
for thermw_fastrtps
repository. - Branch
gbiggs/discovery-peers-specification
for thermw_cyclonedds
repository.
We would like to emphasise that the above sources are a prototype.
The behaviour does not perfectly match the ideal specified in the above tables, and even that ideal may change based on feedback.
We are still working with DDS vendors to identify the correct settings for their DDS implementations.
However it is working well enough, particularly between two hosts, to try out the behaviour and understand if it will meet your needs.
The most complete implementation is for rmw_fastrtps
.
Please try it out, and let us know how happy or sad you are about this proposed change.