ROS2 - let's try this again
Okay, so after wasting a LOT of time going around in circles? (Which does make me wonder how far & how not-far (!far), we've actually come in the IT Industry, we seemed to have peaked in the mid/late 1990s/early 2000s & then seemed to have gotten stuck & repeated ourselves and gone in a downward spiral - wow, I really do sound like a Gen-X-er! which I am, so get over it)
I often confess I'm no genius, I just keep trying different positions to put the square block into the circle hole repeatedly, until I either wear down the sides of the square or I make the circle more square - such is life :-)
What has this got to do with ROS2. Well, I thought this was going to be a 10minute job, super simple & I could move onto the "good stuff" and do something useful with my time. Over the years, I have learnt that I tend to spend the time between xmas & new year just doing "installs & setups", I rarely actually get to the point where I "use" what I've setup, because it took so long to get to the stable setup.
This year, that subject of interest is the ROS2 humble running in Docker, on a Raspberry Pi 5.
Sounds like a 10-minute job, doesn't it?! I mean there are hundreds of thousands of Raspberry Pi5 devices out there, every man & his dog has gotten hooked onto the software-drug named Docker (yeah, I have b33f about this software, but will save that for later), so surely there are super-simple instructions & guides out there to follow.
Building my own Dockerfile seemed like the thing to do - as I discover later, maybe not, or maybe yes. It's all a bit quantum, y'know.
I was trying this all on the original RPi5 that is running Debian Bookworm 12 & Docker - it was okay, but it still took quite some time to get to the point of failure.
<Now, I did start to wonder if my woes were due to the fact I'm sitting in a field, hooked up to a 4G router that may or may not have a perfect signal : when I got the failure errors, I could copy the link / references to a web-browser & they are available & downloadable, so hmmmmm>
I switched to using my Honor Magicbook laptop that is running UBuntu 24. It runs a LOT faster than the RPi5. I installed Docker engine to match the RPi5.
I went through the same process & got the same failures. I then decided to just make a new / fresh Dockerfil myself, doing it bit by bit. This seemed to go really well, until it didn't. Failures to download key files towards the end, 1317 files through. sigh.
I even discovered that I could pass an extra parameter to the $ docker build CLI that tells it to make an image for the RPi5 platform. awesome.
[Dockerfile]
#an empty Dockerfile
#use UBuntu 22.04 as that is what ROS2 humble is supported on
#why humble? because the UGV Rover uses RPi5 that has a lidar that has a module that is written for humble. however, can we do this another way?
FROM ubuntu:jammy
#following prevents any prompt questions coming up when installing
ENV DEBIAN_FRONTEND=noninteractive
#perform the usual update & upgrade
#use apt-get as it works better than just apt for docker
RUN apt-get update && apt-get upgrade -y
#this is actually where most of the issues are created
RUN apt-get install -y curl software-properties-common
#set the ubuntu repo
#https://help.ubuntu.com/community/Repositories/Ubuntu
RUN add-apt-repository universe
#following specific for ROS2
#set the correct locale
RUN apt-get install -y locales
RUN locale-gen en_GB en_GB.UTF-8 | update-locale LC_ALL=en_GB.UTF-8 LANG=en_GB.UTF-8 | export LANG=en_GB.UTF-8
RUN locale # verify settings
#now add the ROS GPG Key
RUN curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
#add the repositories to the sources list
#the UBUNTU_CODENAME value here can be overridden to say jammy
#to find out what you have, type: cat /etc/os-release
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null
#as we've added new repos, we need to update/upgrade
RUN apt-get update && apt-get upgrade -y
#now, finally we can actually install the ROS software!
#let's go for the full system with demos/tutorials
#RUN apt-get install -y ros-humble-desktop
#the above ALWAYS gets failures
#657.8 Fetched 787 MB in 10min 52s (1208 kB/s)
#657.8 E: Failed to fetch http://packages.ros.org/ros2/ubuntu/pool/main/r/ros-humble-ament-xmllint/ros-humble-ament-xmllint_0.12.11-1jammy.20241125.232936_amd64.deb 400 Bad Request [IP: 140.211.166.134 80]
#657.8 E: Failed to fetch http://packages.ros.org/ros2/ubuntu/pool/main/r/ros-humble-sensor-msgs/ros-humble-sensor-msgs_4.2.4-1jammy.20241128.010813_amd64.deb 400 Bad Request [IP: 140.211.166.134 80]
#657.8 E: Failed to fetch http://packages.ros.org/ros2/ubuntu/pool/main/r/ros-humble-examples-rclcpp-minimal-subscriber/ros-humble-examples-rclcpp-minimal-subscriber_0.15.3-1jammy.20241128.023151_amd64.deb 400 Bad Request [IP: 140.211.166.134 80]
#657.8 E: Failed to fetch http://packages.ros.org/ros2/ubuntu/pool/main/r/ros-humble-examples-rclpy-minimal-publisher/ros-humble-examples-rclpy-minimal-publisher_0.15.3-1jammy.20241128.015730_amd64.deb 400 Bad Request [IP: 140.211.166.134 80]
#657.8 E: Failed to fetch http://packages.ros.org/ros2/ubuntu/pool/main/r/ros-humble-lifecycle/ros-humble-lifecycle_0.20.5-1jammy.20241128.031241_amd64.deb 400 Bad Request [IP: 140.211.166.134 80]
#657.8 E: Failed to fetch http://packages.ros.org/ros2/ubuntu/pool/main/r/ros-humble-quality-of-service-demo-cpp/ros-humble-quality-of-service-demo-cpp_0.20.5-1jammy.20241128.025837_amd64.deb 501 Not Implemented [IP: 140.211.166.134 80]
#657.8 E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
#so let's try the BASIC install
RUN apt-get install -y ros-humble-ros-base
#now, did we get an /opt/ros/humble/ folder created with the software inside?
#source /opt/ros/humble/setup.bash
#ros2 run demo_nodes_cpp talker
This command builds the docker image from the Dockerfile for the amd64 laptop:
$ docker build . -t ros2johnny5:humble-honor-v1
and this command does the same but for the arm64 RPi5:
$ docker build . -t ros2johnny5:humble-pi5-v1 --platform="linux/arm64"
except, it doesn't. They both failed at different points. However, the "theory" is correct. Maybe I need to test this next week with a fixed network connection?
Okay, so I decided I am not going to move or do ANYTHING else until I get a working environment.
I went back to BASICS. Let's see if I can just do a very basic thing. Get the OOTB pre-built docker image, pull it & create a container from it and then execute 2 instances and get them talking to each other.
Let's do the most basic, pull that base humble image:
$ docker image pull osrf/ros:humble
We can check that all is good with $ docker images list. Now, we'll make a container from that image:
$ docker run -it --name base_ros2_container ros:humble
and that's it. we're in. we can source the setup.bash file and we can now call the ros2 command.
Now, let's see if we can get the FULL Desktop version that includes the demo & tutorials nodes.
$ docker image pull osrf/ros:humble-desktop-full
$ docker run -it --name ros2_desktop osrf/ros:humble-desktop-full
okay, so that proves that we have ROS2 running within a Docker container that is running within UBuntu jammy / 22.04. (This is what we need for the LiDAR to work later on the RPi5).
Whilst I've shown the $ docker run -it command, when you finish then instance stops. I'm using Portainer, so I can just go to the UI and [start] the container manually.
Once running, I can open 2 Terminals and do the following:
[Terminal 1]
$ docker exec -it ros2_desktop /bin/bash
[Terminal 2]
$ docker exec -it ros2_desktop /bin/bash
That proves that the ROS2 Desktop Full docker image provides me with what I want - running on the amd64 laptop. I am not sure, but will find out shortly, if the OOTB docker pull images are built for amd64 OOTB - therefore, just repeating the above on the RPi5 will not work, I need to either find the image re-made for arm64 (someone, somewhere, must have done this? or even ROS themselves?) or I have to go back to what I was originally trying and build from the Ubuntu OS upwards.
AH HA!
I stumbled over this page:
and this implies that I can pull these specific images for the Raspberry Pi5:
docker pull ros:humble-ros-core docker run -it --rm ros:humble-ros-core
Hmmm....
Well, look at that, apparently I did this ages ago & just got around to coming back to the same point (sounds familiar, I just heard something on the audiobook (see below) that reminds me of talking to a guy at Objective Computing, back in 2001 & asking him "why is it that I cannot pass my hand through this can of coke? and what stops the coke can from sinking through the desk?" - he naturally looked at me & thought I'd "lost it", but I do hope that he recalls that discussion in his future - it was a thought reminder of "how we perceive reality" and how atoms & molecules adhere to unwritten rules that if you were to know how to manipulate those rules, you could "change reality". lol. anyway, just hearing that on the audiobook (see below) reminded me of that)
On the RPi5, ros:humble-ros-desktop and ros-desktop-full do NOT exist. I wonder if this is where I got choked up before?
BUT, the humble-rose-base & humble-ros-core do exist. I quick execution of the above and there we have it. ROS2 humble running in Docker on the RPi5.
I cannot do the quick demo_nodes_cpp talker / listener test as they are not included. I'll look to set these up manually later on.
UPDATE:
From within the container, in theory I can just run the following command & it should download the demo nodes for me to use / test:
sudo apt-get update
sudo apt-get install ros-$ROS_DISTRO-demo-nodes-py
sudo apt-get install ros-$ROS_DISTRO-demo-nodes-cpp
Yup, theory was right - so that worked well! awesome. progress might start to being made.
I'll also go back to see if I can find the LiDAR UGV source-code git-hub repo, so I can get that "into" the container and see if I can get the LiDAR connected to the USB to the host machine to spit out the content it is picking up so that I can then START to make this UGV autonomous!
Oh, what is this UGV? oh the one from the first image above!
This one:
https://www.waveshare.com/wiki/UGV-Rover
https://www.waveshare.com/wiki/UGV_Rover_PI_ROS2
https://www.waveshare.com/wiki/UGV_Rover_PI_ROS2_1._Preparation
https://www.waveshare.com/wiki/UGV_Rover_PI_ROS2_4._2D_Mapping_Based_on_LiDAR
I noted along this journey that I can create the container to use the host machine devices, such as USB, so that was a good lessons to learn / pick-up along the way.
--privileged : grants extended privileges to the container, allowing it to access host resources such as USB devices, which is useful for robotics applications
--net=host : shares the hosts network stack with the container, allowing ROS nodes to communicate over the network as if they were on the host machine
I'll come back to this a little later - as I may or may not have mentioned? I left the tiny LiDAR connector board "in the office", so whilst I have the LiDAR on the UGV, I cannot connect it to the USB. But, if I have ROS2 running now, I have the potential to do all the "other stuff" until I can get the LiDAR up & running.
oh, yeah, Happy Holiday thing. I just remembered that, apparently for some bizarre human implanted memory, a lot of people decide to do strange rituals today.
----------------------------------------------------------------------------------
Whilst doing all of the above, this has been playing in the background via Spotify premium - "The Simulation Hypothesis - we are in a video game" Rizwan Virk. It is amusing, as the author sounds like a very similar age/background. I did go down this same path in the early 2000s, I believe I even have diagrams / drawings / thoughts in some of the books of that time & I remember talking to people about this mindset approach & noted how they thought I had potential "mental health issues", which is funny as this author is now making $$$ from this audiobook, but y'know, I had "issues". sigh. ah well, it's actually a good book & took me back through my own video game / IT background journey & also matches my thoughts about how, when we get the Quantum chips out there, we have the ability to loop inside the fractal once more. ie. we are pixels in a game who are then able to make pixels in a game inside a game inside a game. but, hey, y'know, enjoy your xmas turkey :-D
Comments
Post a Comment