ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

ROS 2 talker-listener on 2 machines not working

asked 2022-07-11 14:41:17 -0500

ccpjBoss gravatar image

updated 2022-07-11 14:41:49 -0500

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 ROS_DOMAIN_ID variable, so they should be communicating.

Any help on how to debug this problem?

edit retag flag offensive close merge delete

Comments

Can you ping these computers between each other normally?

ljaniec gravatar image ljaniec  ( 2022-07-11 15:34:20 -0500 )edit

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

ccpjBoss gravatar image ccpjBoss  ( 2022-07-11 16:52:17 -0500 )edit

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

ljaniec gravatar image ljaniec  ( 2022-07-11 16:56:00 -0500 )edit

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

ccpjBoss gravatar image ccpjBoss  ( 2022-07-11 16:59:52 -0500 )edit

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

ccpjBoss gravatar image ccpjBoss  ( 2022-07-11 17:00:42 -0500 )edit

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

ccpjBoss gravatar image ccpjBoss  ( 2022-07-11 17:02:38 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-07-11 17:40:22 -0500

ccpjBoss gravatar image

updated 2022-07-12 02:10:08 -0500

ljaniec gravatar image

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!

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2022-07-11 14:41:17 -0500

Seen: 958 times

Last updated: Jul 12 '22