0
$\begingroup$

Rosanswers logo

Currently I have ROS2 foxy on a docker container and what I want to do is to publish and subscribe from the container to Windows side and the other way around as well. The container runs the tag base (link text). The installation I followed for ros2 foxy on windows is the official one (link text). Right now I am testing with ros2 examples (minimal publisher and minimal subscriber (link text) . I have tried to do this between two separate containers and it just works out of the box. It works if I do it between my ubuntu container and ubuntu host.

  • Docker networking in Windows:

First I tried to do the following https://docs.docker.com/docker-for-windows/networking/#use-cases-and-workarounds (the I WANT TO CONNECT FROM A CONTAINER TO A SERVICE ON THE HOST section) and it successfully connected to the host. But when running the publisher and subscriber nodes nothing goes through.

  • I also tried to publish the port:

    docker run -p 7412 my_ros_container

  • eProsima configuration:

One thing I tried but didn't fix is to change the RMW_IMPLEMENTATION to eProsima (link text). It should be the default value though. Having said that I am not at all experienced with DDS.

set RMW_IMPLEMENTATION=rmw_fastrtps_cpp

<?xml version="1.0" encoding="UTF-8" ?>
<profiles xmlns="http://www.eprosima.com/XMLSchemas/fastRTPS_Profiles">
    <participant profile_name="ROS2_profile" is_default_profile="true">
        <rtps>
            <builtin>
                <initialPeersList>
                    <locator>
                        <udpv4>
                            <address>host.docker.internal</address>
                            <port>7412</port>
                        </udpv4>
                    </locator>
                </initialPeersList>
            </builtin>
        </rtps>
    </participant>
</profiles>
  • CycloneDDS configuration:

I also tried with Cyclone DDS setting it both in the ubuntu container and in my Windows system. And then I included:

<?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>auto</NetworkInterfaceAddress>
      <AllowMulticast>false</AllowMulticast>
    </General>
    <Discovery>
      <ParticipantIndex>auto</ParticipantIndex>
      <Peers>
        <Peer address="host.docker.internal"/>
      </Peers>
    </Discovery>
<Tracing><Verbosity>finest</Verbosity></Tracing>
  </Domain>
</CycloneDDS>

which also did not work but it produced a log file which I can copy paste as a comment if needed.

  • WSL2

I also tried this: https://github.com/docker/for-win/issues/6736 but there is no default.conf in my container so I copied it under /etc. I also tried to replace host with host.docker.internal as suggested at: https://github.com/docker/for-win/issues/6736

So I created a default.conf as below:

server {
    listen       7412;
    listen  [::]:7412;
    server_name  host.docker.internal;
}

and run my image:

docker run --rm --net host --volume $PWD/default.conf:/etc/default.conf my_img

and when I try to communicate with curl it fails: curl http://127.0.0.1:7412
curl: (7) Failed to connect to 127.0.0.1 port 7412: Connection refused

This is my Dockerfile in case it is of any use:

> FROM ros:foxy as base
> 
> RUN apt-get update \
>     && apt-get install -y \
>     python3-pip \
>     build-essential \
>     nano \
>     ros-$ROS_DISTRO-examples-rclcpp-minimal-publisher \
>     ros-$ROS_DISTRO-examples-rclcpp-minimal-subscriber\
>     ros-${ROS_DISTRO}-rmw-cyclonedds-cpp \
>     gdb \
>     git

Originally posted by anastasiaPan on ROS Answers with karma: 123 on 2021-01-20

Post score: 1


Original comments

Comment by tfoote on 2021-01-25:
Please edit your question with the full commands that you're running and any settings you've configured on you system relating to netowrking. This likely has to do with how you've configured your docker networking. @ruffsl suggested you look at https://github.com/docker/for-win/issues/6736 for a potential issue if you're using WSL2.

Comment by anastasiaPan on 2021-01-25:
Ok so I have updated my answer and I tried to be as thorough as possible.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Solution: https://github.com/eclipse-cyclonedds/cyclonedds/issues/677


Originally posted by anastasiaPan with karma: 123 on 2021-01-28

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.