ros2 / rmw_cyclonedds

ROS 2 RMW layer for Eclipse Cyclone DDS
Apache License 2.0
112 stars 91 forks source link

Execute cycloneDDS example across network #462

Open CristianChachaLeon opened 1 year ago

CristianChachaLeon commented 1 year ago

Steps to reproduce issue

PC1 and PC2 are connect LAN in the same network

  1. Create a docker container with ubuntu 18.04 in PC1
  2. install cyclonedds in docker container
  3. Install cyclonedds in PC2
  4. Execute ./helloWordSuscribe inside de docker (PC1)
  5. Execute ./helloWordPublisher in PC2

Expected behavior

Communication succesfull

Actual behavior

No comunication between applicacition examples

eboasson commented 1 year ago

Historically there's been a lot of trouble with docker not supporting multicast properly, so that would be my first guess, especially since it looks like you're on a somewhat older software stack. (Examples aplenty on the internet.) The other classic Cyclone DDS problem is it choosing the "wrong" network interface in a multi-hosted machine.

I would start out by trying to what happens when you disable multicast and list the peers for unicast discovery. https://husarion.com/tutorials/other-tutorials/husarnet-cyclone-dds/#configure-cyclone-dds is a good guide, though that utilizes IPv6 which I expect is relevant for you. Adapting from it, this would be a good starting point (I expect you'll have to change "eth0", "PC1" and "PC2"):

<?xml version="1.0" encoding="UTF-8" ?>
<CycloneDDS xmlns="https://cdds.io/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://cdds.io/config https://raw.githubusercontent.com/eclipse-cyclonedds/cyclonedds/master/etc/cyclonedds.xsd">
  <Domain id="any">
    <General>
      <NetworkInterfaceAddress>eth0</NetworkInterfaceAddress>
      <AllowMulticast>false</AllowMulticast>
    </General>
    <Discovery>
      <ParticipantIndex>auto</ParticipantIndex>
      <Peers>
        <Peer address="PC1"/>
        <Peer address="PC2"/>
      </Peers>
    </Discovery>
  </Domain>
</CycloneDDS>
CristianChachaLeon commented 1 year ago

Hello @eboasson , thanks for your quick response.

I've used the suggested settings, but it seems there's still no communication. In my case I use IPv4 for both PC1 and PC2.

I'm afraid that the docker configuration is not correct and this avoids discovering PC2 hellowordPublisher application example

eboasson commented 1 year ago

@CristianChachaLeon, I'm afraid you'll really have to provide some information. I don't even do docker myself, but I can try.

The first step is to find out Cyclone is really doing by getting a pair of log files. Those files not the easiest to read, but I know how to do it. They do not always provide enough information, but often they do.

To get them, add this in your XML:

<Tracing>
  <Category>trace</Category>
</Tracing>

This'll write a file named cyclonedds.log. If you want to run multiple processes in the same working directory, that becomes a mess, and in that case I'd advise to add <OutputFile>cdds.log.${CYCLONEDDS_PID}</OutputFile> to the "Tracing" section.

If you're curious what they say, there is some documentation, but I expect you'll quickly decide it is better if I take a look. The easiest way is to attach them to a GitHub comment.

ksuszka commented 1 year ago

@CristianChachaLeon by default docker isolates containers in their own network. How did you set up the network between those docker containers? Did you use --net=host? To check if this is a docker network issue try to run both containers with --net=host, this will eliminate docker network isolation. If this works, then you can play with docker network configuration if some form of isolation is required.