ros2 nodes on different subnets
Hello,
i'm trying to make ros2 communication work between hosts on different subnets using the latest (dashing) release. i have 2 hosts, one 192.168.2.22 and one 192.168.1.40. i use the following DEFAULTFASTRTPSPROFILES.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<profiles>
<participant profile_name="participant_somename" is_default_profile="true">
<rtps>
<builtin>
<metatrafficUnicastLocatorList>
<locator/>
</metatrafficUnicastLocatorList>
<domainId>4</domainId>
<initialPeersList>
<locator>
<udpv4>
<address>192.168.1.40</address>
</udpv4>
</locator>
<locator>
<udpv4>
<address>192.168.2.22</address>
</udpv4>
</locator>
</initialPeersList>
</builtin>
</rtps>
</participant>
</profiles>
this makes the simple demonodescpp talker and listener work, but 2 nodes on the same machine can't exchange images anymore (eg cam2image and showimage). When i remove the metatrafficUnicastLocatorList, the local communication works again, but then the remote talker/listener scenario doesn't work anymore.
Anybody knows what i'm doing wrong ? Greetings, Frank
Asked by Frank Dekervel on 2019-06-07 07:45:40 UTC
Answers
The problem is that fastRTPS unicast discovery based on initial peers only probes for 4 participants by default. This means that when you have more than 3 ros nodes things will fail with the above XML (roslaunch is also a node, so 4 nodes + roslaunch = 5 nodes).
The following XML solves the problem for me.
<?xml version="1.0" encoding="UTF-8" ?>
<profiles>
<transport_descriptors>
<transport_descriptor>
<transport_id>veelpeers</transport_id> <!-- string -->
<type>UDPv4</type> <!-- string -->
<maxInitialPeersRange>100</maxInitialPeersRange> <!-- uint32 -->
</transport_descriptor>
</transport_descriptors>
<participant profile_name="participant_somename" is_default_profile="true">
<rtps>
<builtin>
<metatrafficUnicastLocatorList>
<locator/>
</metatrafficUnicastLocatorList>
<domainId>4</domainId>
<initialPeersList>
<locator>
<udpv4>
<address>192.168.1.40</address>
</udpv4>
</locator>
<locator>
<udpv4>
<address>192.168.2.22</address>
</udpv4>
</locator>
<locator>
<udpv4>
<address>127.0.0.1</address>
</udpv4>
</locator>
</initialPeersList>
</builtin>
<userTransports>
<transport_id>veelpeers</transport_id>
</userTransports>
<useBuiltinTransports>false</useBuiltinTransports>
</rtps>
</participant>
</profiles>
Note that unicast discovery sends a packet to every known port to check if there is a participant running there. so this can create a lot of network traffic.
Asked by Frank Dekervel on 2019-06-14 08:46:29 UTC
Comments
Seems for simple cases the above example xml just works, but as i add more nodes things start to break. So i suspect a bug in FastRTPS unicast locators.
Asked by Frank Dekervel on 2019-06-07 15:03:39 UTC
So i found out that the maximum initial peers is probably too small for my situation, and the fast-RTPS unicast discovery only probes 3 participants on every peer by default. still trying to figure out how to change maxInitialPeers in this XML
Asked by Frank Dekervel on 2019-06-14 08:29:39 UTC