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

Connection between ROS in Docker with external ROS MASTER (another PC): The Baxter case

asked 2018-09-12 08:44:17 -0500

Figueredo gravatar image

Hello,

I have been trying to run Demos for the Baxter robot from within a Docker Container, but I can't get the Baxter to respond the ROS within the Docker. The configuration I am looking for is:

  PC 1: Host                                     PC2: Baxter
[ Docker:Running (ROS) ]      <------->         [ Ros Master ]

The Baxter launches the roscore on boot with all the nodes and services on the robot with the ROS_MASTER_URI pointing to its own roscore. That seems to be the problem, since everything works fine if I am running a local master (in the PC1:Host instead of PC2:Baxter).
ps.: The ROS within the Docker is Indigo with Ubuntu 14.04 (the host has the same ROS and Ubuntu).

I have tried multiple solutions exploring the Docker network access. The best I have so far is to use " --net=host " so the container is not be isolated wrt network stack. In other words, the ROS within the Docker has full access to the host network stack. Using the same configuration for the baxter.sh (wrt to the host which works perfectly to connect Host <--> Baxter), I can find the ROS Master and see a list of topics, nodes etc created by the Baxter (and pointing to itself). But, I have no response with "topic echo" (or any other request), which sounds like the ROS Master can't see the ROS within the docker. I am using the same ROS_IP from the host (which works for host <--> baxter) and --net=host which should give Docker access to the network stack.

So the question is, how can I make ROS in a container access a ROS Master launched in an external machine?

I've just started with docker but I can't see to find any straightforward solution for similar issues other than changing the ROS Master to the host. Has anyone had a similar problem? Ideas?

Thank you in advance

Luis

edit retag flag offensive close merge delete

Comments

I'm not so sure this is an issue with docker; given your use of --net=host and the apparent asymmetric issues with rostopic list/echo, I'd say check the NAT between the two computers using something like netcat: http://wiki.ros.org/ROS/NetworkSetup#...

ruffsl gravatar image ruffsl  ( 2018-09-12 13:58:54 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-02-13 12:18:34 -0500

sgira gravatar image

Create your docker file, here an example:

FROM ros:melodic-ros-base
# set enviroment    
ENV ROS_MASTER_URI=http://<your master IP address>:11311
ENV ROS_IP=<your node "static" IP addresse>
ENV ROS_WS=/home/catkin_ws

RUN mkdir -p $ROS_WS/src

COPY <your directory to copy on container> $ROS_WS/src
WORKDIR $ROS_WS

# install ros dependencies packages
RUN apt update && apt-get install -y \
    ros-melodic-desktop-full \
    ros-melodic-navigation \
    ros-melodic-moveit \
    ros-melodic-gazebo-ros-control \
    && apt-get clean 

RUN . "/opt/ros/$ROS_DISTRO/setup.sh" && cd $ROS_WS && catkin_make \
    && sed --in-place --expression \ 
     '$isource "$ROS_WS/devel/setup.bash"' \
      /ros_entrypoint.sh

# run ros package launch file
CMD [ "roslaunch", "<your package>", "<your launch file>" ]

build your image with --network=host:

sudo docker build --network=host -t <your docker hub>/<your image name>:<your tag> .

run your container with the parameter:

sudo docker run --rm --network=host <your docker hub>/<your image name>:<your tag>

Warning This is only a workaround. In this way you are opening all ports of your host to the docker container (see docker build doc mapping the container network to the device network layer.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2018-09-12 08:44:17 -0500

Seen: 3,150 times

Last updated: Sep 12 '18