Communication btw ROS docker container and Jetson bot
I created a container that runs ROS melodic, and I want it to communicate with a robotic rover, which has a Jetson onboard and runs melodic as well. Both my computer and my rover are in the same network, as ping
and netcat
are working fine as advised here.
When I run roscore
in the container, I can successfully run my pkgs on my rover after setting
ROS_MASTER_URI=http://ip.of.the.computer:11311
.
But nothing coming in when running rostopic echo /rosout
in the container. The same command prints normal outputs on the rover. Also, rostopic list
on both sides gives the same list. On interesting thing is, when nothing is publishing to a topic, running rostopic echo
in the container shows
WARNING: topic [/xxxx] does not appear to be published yet
but it shows nothing when there is something publishing to the topic.
When I run roscore
on the rover, I set ROS_MASTER_URI
in the container to http://ip.of.the.rover:11311
. This time, running rostopic list
in the container gives the error
ERROR: Unable to communicate with master!
I tried to set up ROS_IP
as suggested in this post, but that doesn't help. Can anyone give me some hints of how to make the communication working fine?
My script for running the docker container:
!/bin/bash
XSOCK=/tmp/.X11-unix
sudo docker run -it \
--runtime=nvidia \
-e DISPLAY=$DISPLAY \
-v $XSOCK:$XSOCK \
-v $HOME/.Xauthority:/root/.Xauthority \
-v $PWD/ros_dev:/ros_dev \
-v $PWD/data:/data \
-p 11311:11311 \
--privileged \
--net=host \
--name=melodic \
ros:melodic "$@"
And my Dockerfile
is:
FROM osrf/ros:melodic-desktop-full
# nvidia-container-runtime
ENV NVIDIA_VISIBLE_DEVICES \
${NVIDIA_VISIBLE_DEVICES:-all}
ENV NVIDIA_DRIVER_CAPABILITIES \
${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics
# Minimal setup
RUN echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
RUN source ~/.bashrc
Asked by doplidoob on 2022-08-15 12:58:45 UTC
Comments
Ahoy! What does your firewall for both machines look like? ROS1 uses a range of nondeterministic for message transport that won't be predefined, this most firewalls can interfere with ROS1 connectivity. BTW, you shouldn't need to port forward 11311 if you arr already using the host network interface. Also, rather than sourcing the setup or bashrc script from your Dockerfile, you'd want to add that to the container entrypoint instead:
https://docs.docker.com/engine/reference/builder/#entrypoint
Asked by ruffsl on 2022-09-20 05:26:15 UTC