Robotics StackExchange | Archived questions

ROS 2 talker-listener on 2 machines not working

ROS 2: Galactic

RMW: default

OS: Ubuntu


Hello! I am trying to run the talker-listener example but instead of running both nodes locally I am trying to reproduce the same behavior but using two different machines connected to the same network.

Machine 1 (Ethernet): ros2 run demo_nodes_cpp talker

Machine 2 (Wifi): ros2 run demo_nodes_cpp listener

Output:

Machine 1: String being published

Machine 2: Empty

I have also tried to run ros2 multicast send and ros2 multicast receive between both machines and nothing happens. When I run these two commands in the same machine, I see the desired output.

I am also not using the ROSDOMAINID variable, so they should be communicating.

Any help on how to debug this problem?

Asked by ccpjBoss on 2022-07-11 14:41:17 UTC

Comments

Can you ping these computers between each other normally?

Asked by ljaniec on 2022-07-11 15:34:20 UTC

Yes I can, but from what I have seen this does not necessarily mean that ROS 2 is able to work in this condition. I think that the problem is that UDP multicast does not work

Asked by ccpjBoss on 2022-07-11 16:52:17 UTC

As per https://roboticsbackend.com/ros2-multiple-machines-including-raspberry-pi/, checking with the ping is the first thing to do :) Can you check your firewall settings?

Asked by ljaniec on 2022-07-11 16:56:00 UTC

sudo ufw status returns Status: inactive so I suppose that it is not affecting communications

Asked by ccpjBoss on 2022-07-11 16:59:52 UTC

Another thing I should add: When I try this example but with my laptop and a docker container, it also does not work.

Asked by ccpjBoss on 2022-07-11 17:00:42 UTC

Interesting... If I run 2 docker containers, they can communicate with each other and the talker-listener example works as expected.

Asked by ccpjBoss on 2022-07-11 17:02:38 UTC

Answers

I just solved the issue. I'm going to drop the answer here.


So ROS 2 Galactic default rmw implementation is Eclipse Cyclone DDS which does not enable multicast by default. Unfortunately I was not able to get Eclipse Cyclone DDS working.

So I changed to eProsima Fast DDS with export RMW_IMPLEMENTATION=rmw_fastrtps_cpp After changing I learned that multicast is not enabled by default in eProsima Fast DDS either... So I needed to create a file named fastrtps-profile.xml with the following content inside:

<?xml version="1.0" encoding="UTF-8" ?>
<profiles xmlns="http://www.eprosima.com/XMLSchemas/fastRTPS_Profiles" >
<transport_descriptors>
    <transport_descriptor>
        <transport_id>CustomUdpTransport</transport_id>
        <type>UDPv4</type>
    </transport_descriptor>
</transport_descriptors>

<participant profile_name="participant_profile" is_default_profile="true">
    <rtps>
        <userTransports>
            <transport_id>CustomUdpTransport</transport_id>
        </userTransports>

        <useBuiltinTransports>false</useBuiltinTransports>
    </rtps>
</participant>
</profiles>

This enabled multicast in eProsima Fast DDS. To make DDS use this configuration file, you do: export FASTRTPS_DEFAULT_PROFILES_FILE=<path_to_config_file_created>.

Do this in both machines and it should work!

Asked by ccpjBoss on 2022-07-11 17:40:22 UTC

Comments