ROS2 Foxy issues in docker
I'm having issues running my system within a docker container. By experimenting, I've managed to observe that
- it seems like my publishers don't publish. Noting shows up ros2 topic hz/echo in the container, same outside of it. Weird thing is that most of the time ros2 topic info will show the right number of publishers, sometimes it will show 0
- Some service works, others don't. While I can call some services using rqt_service_caller and get the correct response, when I can others, the node providing the service will print out the correct request but rqt_service_caller will freeze as it never get the response.
- The problem may be limited to my package, I've tried running examples_rclpy_minimal_publisher publisher_local_function it works without any issues (except that it seems a bit low view from outside the container on rqt_topic)
- If I run ros2 topic echo topic before the publisher is launched it will work, but if I restart the echo, it will no longer connect
So additional information:
- Publisher in my package all uses qos.qos_profile_system_default
- Nodes run using USE_SIM_TIME=True (I've tried without it but no change)
- Launching nodes using a launch file
- Nodes are written python
Run my docker using
docker run --rm -it
and below is the dockerfile if created
FROM ros:foxy-ros-base-focal
ARG DEBIAN_FRONTEND=noninteractive
# Install required packages
RUN ln -fs /usr/share/zoneinfo/America/Toronto /etc/localtime && \
apt-get update -qq \
&& apt-get install --no-install-recommends -y -qq \
apt-utils \
build-essential \
git \
tmux \
openssh-server \
sudo \
python3-pip \
dialog \
tzdata \
curl \
nano \
screen \
keyboard-configuration && \
dpkg-reconfigure --frontend noninteractive tzdata \
&& apt-get clean -qq
COPY ./src/ /home/src/
COPY ./.git/ /home/.git/
COPY ./requirements.txt /home/
COPY ros_entrypoint.sh /
WORKDIR /home/
RUN pip install -r requirements.txt
# Build autosoar packages
RUN . /opt/ros/foxy/setup.sh && \
colcon build --cmake-args --symlink-install
ENTRYPOINT ["/ros_entrypoint.sh"]
CMD ["bash"]