Discussion - Crafting your Dockerfile (Docker for Robotics Part 3)

This is the discussion topic for the video linked above. Please keep all replies relevant to the content, otherwise create a new topic.

Interesting series of articles.

I finally got around to watching them and trying out ROS2 on Docker. I would appreciate it if you could share any insights you have on running the docker-based development system on systems with AMD-based GPUs.

I am a weirdo, I know CUDA and Nvidia-based systems dominate the robotics/AI space, but I prefer to support the second-place vendor to encourage competition in the market.

Ironically, getting things running well on an AMD-based system could be an interesting niche that attracts tons of hits for search algorithms. People come for the AMD information and stay for the great ROS2 content!

David

2 Likes

I saw your videos just in time while I was having trouble interfacing Matlab and Gazebo. I had a problem with this, since Matlab 2023 has a version requirement for glibc which is higher than Ubuntu 20 system’s version. Moreover, the gazebo libraries and tutorials they have are only supported for ROS Noetic in Ubuntu 20. I upgraded to Ubuntu 22, and created a docker image with ROS Noetic, and after some work, I could follow Matlab’s tutorial (though it runs fairly slow on my laptop). Do you have any experience interfacing Matlab and ROS? Are there better solutions to this?
Thanks for your videos btw, they’re awesome!

1 Like

Nice one, it’s great you were able to work around that!
Unfortunately I’ve not used MATLAB with ROS before so don’t have anything to add there…maybe I should ask Mathworks if they’re interested in a sponsorship…

1 Like

I am using noetic-desktop-full image for ROS1 in Docker. I can start ros master using roscore and gazebo in another terminal. But , whenever I try to start rviz it says bash: rviz: command not found. Please help me here @JoshNewans

Hi, it’s a while since I’ve used ROS 1 and especially in docker, but confirm that the installation has been sourced (source /opt/ros/noetic/setup.bash) and maybe try rosrun rviz rviz.

So I’m nearly giving up on trying to get anything working in ROS2 on Raspberry pi 4. For a platform so popular, the support for it from the ROS2 side of things is completely absent. First, the “official” OSRF images are ALL amd64. Raspberry Pi is arm64. You will NEVER get those images to work on raspberry pi. 2nd, the other images are incomplete without rviz gazebo turtlesim etc. These are from the actual ROS2 development community. I am suffering/losing my life due to trying to get this to work. I hope others read this message and get the appropriate warning to not spend time on this. I regret diving into this. I haven’t done anything of worth spending time on this project. Nothing to show for.

I’m sorry you had such a difficult time with it. I hadn’t noticed but you are right, the “Docker Official Library” repo (Docker ros) which only has the base stuff without the desktop tools supports both platforms, while the “OSRF Profile” (Docker osrf/ros) which has the desktop tools only supports x64.
I’m sure this is fine for many people who are running the tools on their desktop machine, connected to a headless ARM device on the robot. But it’s not so suitable for someone trying to run the tools direcly on the ARM PC.

Can you create a Dockerfile deriving directly from ros:humble-ros-base and then install the additional required tools on top of that? I imagine that should work fine.

Edit: It’s worth noting (as this really confused me at first) that both sets of Docker images come from the same GitHub repo and the Readme kind of clarifies things.

https://www.youtube.com/watch?v=KAASuA3_4eg The video seems to imply that the ros2 tool is installed on the PI. How would “ros2” run over ssh if ros2 wasn’t installed on the pi itself? This would imply that ssh is somehow seeing the ros2 command from the remote to the host. Either something is missing in the earlier setup videos or ros2 is in fact installed on the pi.

The actual supported raspberry pi software is debian (buster at this time). If you start frankenstein-ing unsupported Ubuntu onto the raspberry pi, you’ll end up with absolutely no support for official hardware for the pi. For example, Arducam has it’s own Debian maintainers for their cameras SPECIFICALLY for the pi on offical debian, and they flat out state that they do not support Ubuntu/whatever they are doing with libcam drivers. This a complete nonstarter with ROS2 running only on ubuntu and the pi only supporting Debian. As a user, I’m blamed for doing “hacks” and things not working (docker on debian for installing ros2, since docker was never meant o be used as a desktop replacement), or I get blamed for doing “hacks” and things not working (installing ubuntu on the pi and hardware completely is not working because the drivers aren’t official/not supported). This is pretty much an unsolveable linear equation at this point.

Yep ROS 2 is installed directly on the Pi in that series (I’m pretty sure I actually show the installation in another video). I’m not sure what you’re getting at there?

The Docker series is more recent and unrelated (and in fairness to you, I don’t demonstrate Docker on the Pi but it should work).

I’m not sure who is blaming you but I’m sorry to hear you are being blamed for anything! You are right that sometimes Raspberry Pi supporting Debian and ROS supporting Ubuntu leads to some subtle but difficult to resolve clashes.

In my case I have been running Ubuntu MATE 20.04 and 22.04 on the Pi and can interface with the camera but fully acknowledge that it was not as smooth or functional as it is under Raspbian (or whatever it’s called now).

If I understand correctly, you’re trying to use Docker on Rasbian to get the best of both worlds (ROS 2 and native camera support) which I’ve never tried or encouraged, but like you I would have assumed it would work. I hope you are able to get to a working solution eventually and not remain stuck! :slight_smile:

This ends my short journey into linux robotics. All the problems of linux and hardware raise their ugly heads yet again, year after year after year. The hardware vendors have so much trouble with linux, they have to hire 4th party companies to write software to make devices compatible with linux. I spoke with Arducam about their hardware compatibility problems and they state that they only support an operating system which is EOL for security updates in 5 months. So you’re left writing everything from scratch and wasting your entire life trying to get a camera to focus on something. Mind as well build a computer from scratch by digging with a shovel and refining silicon from the earth.

Hello, This reply may be irrelevant, bu I am new on using this docker platform. The docker playlist in youtube is so useful for me. Also, i wanted to create a custom package test_package which publishes the topic named /talker contains the info of std_msgs:String. This below is the docker file i created for the above all happen, when i execute the docker run -it command.

FROM osrf/ros:noetic-desktop-full

RUN apt-get update \
    && apt-get install -y \
    nano \
    tree \
    && rm -rf /var/lib/apt/lists/*
             
WORKDIR /catkin_ws/src 

RUN /bin/bash -c "source /opt/ros/noetic/setup.bash \
                && catkin_create_pkg test_package std_msgs roscpp rospy"

COPY test_package/src/talker.cpp /catkin_ws/src/test_package/src/talker.cpp

WORKDIR /catkin_ws
RUN /bin/bash -c "source /opt/ros/noetic/setup.bash \
                  && catkin_make"
RUN echo "source /catkin_ws/devel/setup.bash" >> /root/.bashrc

CMD ["bash", "-c", "source /opt/ros/noetic/setup.bash \
                    && roscore & sleep 1 \
                    && source /catkin_ws/devel/setup.bash \
                    && rosrun test_package talker"]

and the error showing is

...........
started core service [/rosout]
[rosrun] Couldn't find executable named talker below /catkin_ws/src/test_package

I know that we have to modify the CMakelists.txt file to run the rosnode like add_executable, target_link_libraties and one other which is runtime destination after created the talker.cpp file under the src directory in the package. To do that i have to write the command in the dockerfile. I don’t know how to add that here. If someone help me out in this, it would be so helpful for me. Thanks in Advance.

a file for Raspberry Pi

FROM arm64v8/ros:humble-perception-jammy

FROM arm64v8/ros:foxy-ros1-bridge-focal

RUN apt-get update \

&& apt-get install -y \

nano \

vim \

gedit \

ros-foxy-desktop \

python3-argcomplete \

ros-foxy-navigation2 \

ros-foxy-nav2-bringup \

inetutils-ping \

&& rm -rf /var/lib/apt/lists/*

RUN apt-get update
&& apt-get install -y nano
vim
gedit
ros-humble-desktop
python3-argcomplete
ros-humble-rmw-cyclonedds-cpp
ros-humble-twist-mux
ros-humble-turtlebot3*
ros-humble-slam-toolbox
inetutils-ping \
&& rm -rf /var/lib/apt/lists/*

COPY config/ /site_config/

Create a non-root user

ARG USERNAME=ros
ARG USER_UID=1000
ARG USER_GID=$USER_UID

RUN groupadd --gid $USER_GID $USERNAME
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME
&& mkdir /home/$USERNAME/.config && chown $USER_UID:$USER_GID /home/$USERNAME/.config

Set up sudo

RUN apt-get update
&& apt-get install -y sudo
&& echo $USERNAME ALL=(root) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME
&& chmod 0440 /etc/sudoers.d/$USERNAME
&& rm -rf /var/lib/apt/lists/*

RUN apt-get update \

&& apt-get upgrade\

&& apt-get install ros-humble-slam-toolbox\

&& apt-get install ros-humble-xacro\

&& apt-get install ros-humble-twist-mux\

&& apt-get install ros-humble-navigation2 ros-humble-nav2-bringup\

&& apt-get install ros-humble-turtlebot3*

Copy the entrypoint and bashrc scripts so we have

our container’s environment set up correctly

COPY entrypoint.sh /entrypoint.sh
COPY bashrc /home/${USERNAME}/.bashrc

Set up entrypoint and default command

ENTRYPOINT [“/bin/bash”, “/entrypoint.sh”]
CMD [“bash”]