ROS2 on UBuntu 24 and a UGV Rover [FAIL] ~[SUCCESS] ?

A UGV Rover 6-wheeled robot with Raspberry Pi5, awesome camera (pan & tilt / stabilisation) and a LiDar - what's not to like?  Well, it's open-source too.


However, it comes with a bit of an odd setup, it is running a Raspberry Pi 5 board, but to control the device itself it's also running an ESP32 board that controls all the components.

OOTB the setup is "okay", it's a web-browser based access to all the bits you need, it even has the concept of a jupyter notebook style Python setup that allows you to control / access all the features.  Although, this soon becomes a bit limiting.

I hooked up a mini-HDMI to the Raspberry Pi 5 and it booked to Bookworm (12, I believe), which allowed me to then install things natively, I installed YOLO and got some really good camera / vision analysis going on.


However, I then had the addition of the LiDar D500 attachment.  


Now, this is where the "fun" started.  The lidar component came with links to a Windows .exe. sigh. I tried & failed to install wine onto bookworm - yes, after all these years I'm still not able to get this to work properly, so I thought, "there must be an easier way"

Yes, I did find reference to the SDK link here:


That downloaded a .zip file that contained a folder of files that needed to be compiled, although it was still ROS2 (and UBuntu 20!) it still required a NATIVE installation.  hmmm...


I went through the trials & tribulations (?) of flashing new 32GB SDCards with UBuntu - looked up online sources only to find lots of instructions telling me that I can only run ROS2 with UBuntu 23.10 - YOU go find an UBuntu 23.10 download for ARM! - I did in the end, but it was difficult.  Eventually found out why, but still.... then I found a LOT of references to installing ROS2 as a Docker container.

First line of the Dockerfile = use UBuntu 22.04.  okay. Then I did all the stuff & eventually got ROS2 running inside a Docker container, able to pub / sub messages and then to monitor the messages - so proving that it all works, technically.

Then I found a lidar ros 2 piece of code that...oh, needed me to plug it inside ros 2 - okay, did that.  But then, the nagging doubt I'd had in the back of my mind several hours ago came to light.  If I'm running ROS2 inside a Docker container - how is it going to map across to the HOST Raspberry Pi 5 device in order to access the USB hardware and all the other hardware for that fact.  Hmmm... it didn't is the answer.

https://medium.com/@apskanda/setting-up-ros2-in-docker-a-step-by-step-guide-3e02ad2669e7

Now, I did see a snippet in a article below in reference to sharing the serial / usb between Docker and the host (/dev/xxx) however, it was mentioning just changing permissions to allow this, however inside my Docker container I didn't even have anything that resembled serial or usb connections. sigh.

https://medium.com/@antonioconsiglio/how-to-install-ros2-humble-on-raspberry-pi-5-and-enable-communication-with-esp32-via-micro-ros-2d30dfcf2111

So.....I went back to flashing the firmware again. I put UBuntu 24.10 (latest) onto the SD Card, I thought, you know what, I'll do a NATIVE installation of ROS2 onto there.  This is where you can tell I've been doing "management stuff" for too long as my "techie brain" should have kicked in at this point & stopped myself.  I was looking up & following guidance / instructions for installing ROS2 "Humble" version, downloading & compiling on the Raspberry Pi 5 itself... it "seemed" to be going okay.

https://lkseng.github.io/posts/2024/01/07/ros-2-humble-on-raspberrypi-5.html

Until about HOUR 2 and right at the end... then it failed to compile, what turned out to be quite a crucial piece of code - it did not look like an easy fix either.  I did read that "Humble" was not 'supported' on UBuntu 24, only 22.  Sigh, was I going to go back & do a firmware flash again on the SDCard for UBuntu 22 & then do a NATIVE install of ROS2.  

Just as I was doing this, I thought "what are you doing?".  This is 2024.  Why can I not just install the latest UBuntu 24 and have ROS2 running on it?

I went to bed & slept (very well, in fact!)

Fresh minded, I returned to the thankless task - having spent far too much of my time wasting my time, I thought, what is it I want & need to do?

I want to correctly install ROS2 (latest version) in UBuntu 24 - so I did an old fashioned DuckDuckGo search for that term - and there we go, a YouTube video is my result!


Now, this very nice chap has a series of similar videos that I'll paste below as they all build from this setup video - THANK YOU!

I'll summarise the steps I executed to make this work (I'm actually doing this LIVE as I write this article - so at the moment I type, I have no idea if I will succeed or not! fingers-crossed for "future me")

Burn UBuntu 24 to the SDCard (again):


Stick it into the Robot.

Boot. Connect to WiFi.

Install Terminator, modify the Desktop settings (as I have OCD!)

Then follow the instructions to perform the installation of ROS2 NATIVELY.

http://docs.ros.org/en/jazzy/Installation.html

Well, me being me, I failed at the FIRST STEP - but we'll see if I have to rollback & adhere to this later.  The first step is to check which version of UBuntu you are running by executing:

$ lsb_release -a

He says to not continue if you are not using 24.04 (noble).  Hmmm... I have 24.10 (Oracular).  It's close enough, but we'll see if it has a problem.

Next step is to basically follow the steps identified here:

http://docs.ros.org/en/jazzy/Installation/Ubuntu-Install-Debs.html#system-setup

I was doing well, until the "Install development tools (optional)"

Err:6 http://packages.ros.org/ros2/ubuntu oracular Release

Error: The repository does not have a Release file.

Let's go check what it's looking for, ah. okay, yes, oracular does not exist.

right, back to noble then.  Well, this means I have to download 24.04 .iso for ARM64 and tell the RPi imager to use that and burn the SDCard AGAIN.

It was worth the try!  At least I know to check the above location regularly (I see it was updated 2 days ago!) and when I see the oracular directory appear I know I can use the 24.10 install of UBuntu.

Right, time to rewind a few steps.

https://www.releases.ubuntu.com/24.04.1/

OOPS! I did it again.  AMD64 version, it needs to be the ARM64 version.  d'oh!
Here's the proper link: https://cdimage.ubuntu.com/releases/24.04/release/


I "think" this is the right image? it might require me to untar it directly onto the SDCard without using the Imager software - we'll see: 

Actually, using the Imager worked fine.

Got further than before.  yay! down to:

$ sudo apt install ros-jazzy-desktop

This does the install for ALL the tools - that's what we want, we want everything.

A quick TEST to prove ROS2 is working as it should.


(BREAK NOW to go & stick some decals onto the side of my Campervan, whilst it is still daylight & not raining! - will add a photo - well, note to self, do not do it in the rain again [okay, it was a light mist, but still made the decal sticking a problem], looks okay for 10ft away & it's not going to be permanent)


Now, where is that SDK from the LiDaR web-page with the extracted .zip file.

Going through the readme.md it states:

Clone the repo into ROS2 workspace:

$ mkdir -p ~/ros2_ws/src/

$ cd ~/ros2_ws/src/

$ git clone https://github.com/Myzhar/ldrobot-lidar-ros2.git

Build the Packages:

$ cd ..

$ sudo rosdep init

$ rosdep update

$ rosdep install --from-paths src --ignore-src -r -y

I got some errors, here, although the last comment is:

#All required rosdeps installed successfully

Now, the next step was todo a colcon build, except it failed.  Although the error message it gives does kind of indicate how to make it work:

$ colcon build --symlink-install --cmake-args=-DCMAKE_BUILD_TYPE=Release

===================================================================

Starting >>> ldlidar_component

--- sterr: ldlidar_component

CMake Warning at CMakeLists.txt:52 (message):

   * ROS2 distro variable not set.  Trying to figure it out...

CMake Error at CMakeLists.txt:75 (message):

   *** WARNING *** ROS2 distro is unknown. This package could not work correctly.

---

Failed   <<< ldlidar_component [1.67s, exited with code 1

Summary: 0 packages finished [1.89s]

 1 package failed: ldlidar_component

 1 package had stderr output: ldlidar_component

 2 packages not processed

===================================================================

Now, there is a next step in the readme.md that states to set the environment variables - so let's try that and redo the above.

$ echo source $(pwd)/install/local_setup.bash >> ~/.bashrc

$ source ~./bashrc


Now re-run the colcon command.  Hmmmm... same error. bugger.

So, taking a look at the following file:

~/ros2_ws/src/ldrobot-lidar-ros2/ldlidar_component/CMakeList.txt

Hmmm, line 52 and 75 imply that I need to have some ENVIRONMENT variable values set as the script doesn't seem to understand that I have ROS2 Jazzy installed.  hmmm.... I wonder.

FFS.

Let to set the variables with the following command:

$ source /opt/ros/jazzy/setup.bash

That command runs the script in that file - that has set the environment variables within this Terminal session.  Now, re-running the following:

$ colcon build --symlink-install --cmake-args=-DCMAKE_BUILD_TYPE=Release

===================================================================

Starting >>> ldlidar_component

--- sterr: ldlidar_component

CMake Error at CMakeLists.txt:75 (message):

  ROS2 jazzy is not officially supported by this package.  Correct working is not guarantee.

---

Failed   <<< ldlidar_component [0.08s, exited with code 1

Summary: 0 packages finished [0.30s]

 1 package failed: ldlidar_component

 1 package had stderr output: ldlidar_component

 2 packages not processed

===================================================================

Hmm... okay, so, well, hmmm... okay.  That just means that the ldlidar code was written to only work with certain ROS2 versions.  Let's go look at the CMakeLists.txt file & see what they list.

Line 53 has reference to:

set(ROS_DISTROS "ardent;crystl;dashing;eloquent;foxy;galactic;humble;rolling")

then a bit further down, line 67:

if(ROS2_FOUND)

  if(${FOUND_ROS2_DISTRO} STREQUAL "humble")

    message(STATUS "* ROS ${FOUND_ROS2_DISTRO} is officially supported by this package.")

    add_definitions(-DFOUND_HUMBLE)

  else()

    message(FATAL_ERROR "ROS2 ${FOUND_ROS2_DISTRO} is not officially supported by this package.  Correct working is not guarantee.")


Okay, so that answers that, THIS code is built to work with HUMBLE and not for JAZZY.  sigh.

Am I going to go back to step 1, wipe the SDCard, re-install using the humble installation instructions and then get back to this point?  Well, yes, probably, however, let me HACK that CMakeList.txt file to allow me to see if I can get further pretending that I'm using humble as jazzy.

Nope, didn't think it would be as simple as just swapping the word "humble" for "jazzy".  You know what, back to Step 1, I go....

After the UBuntu install & boot up, I'll be going to this page instead:

http://docs.ros.org/en/humble/Installation/Ubuntu-Install-Debs.html


Although I do wonder if I need to install UBuntu 22.04 instead of 24.04.  We'll see. I might be back to this point again in an hour!

OH BUGGER!  I forgot that Raspberry Pi 5 does NOT BOOT from a 22.04.5 - sigh!!!!

I was here a few days ago - Tony, you are looping!

https://forums.raspberrypi.com/viewtopic.php?t=359566

I'm going to modify the config.txt file to have:

os_check=0

and see if that stops it attempting to check the OS. let's see.

https://www.raspberrypi.com/documentation/computers/config_txt.html#os_check

Whilst waiting for the Imager to burn the OS again I started pondering, yet another "use docker" article: 

https://adventures-with-pi.blogspot.com/2024/08/running-ros2-on-raspberry-pi-5.html


OKAY, AM ANNOYED NOW:

I might have to resort back to using Bookworm & not UBuntu - at this point I just want something to WORK!

https://github.com/ozandmrz/ros2_raspberry_pi_5

Getting the ORIGINAL SDCard back, booting up Bookworm and then cloning the above git repo.

The script is basically the same steps as above, it's compiling the ROS2 humble code locally, going to take some time.

#!/bin/bash

# ROS2 Humble Installation Script

# Install necessary packages

sudo apt update

sudo apt install -y git colcon python3-rosdep2 vcstool wget \

python3-flake8-docstrings python3-pip python3-pytest-cov \

python3-flake8-blind-except python3-flake8-builtins \

python3-flake8-class-newline python3-flake8-comprehensions \

python3-flake8-deprecated python3-flake8-import-order \

python3-flake8-quotes python3-pytest-repeat python3-pytest-rerunfailures \

python3-vcstools libx11-dev libxrandr-dev libasio-dev libtinyxml2-dev

# Create a new ROS2 workspace

mkdir -p ~/ros2_humble/src

cd ~/ros2_humble

# Download ROS2 source code

vcs import --input https://raw.githubusercontent.com/ros2/ros2/humble/ros2.repos src

# Update system packages

sudo apt upgrade -y

# Configure rosdep

sudo rosdep init

rosdep update

rosdep install --from-paths src --ignore-src --rosdistro humble -y --skip-keys "fastcdr rti-connext-dds-6.0.1 urdfdom_headers python3-vcstool"

# Build ROS2

colcon build --symlink-install

# Set up environment variables

echo "source ~/ros2_humble/install/local_setup.bash" >> ~/.bashrc

source ~/.bashrc

echo "ROS2 Humble installation completed!"


Once it is done, I am then hoping I can then follow the steps to BUILD the ldlidar code..

WOW! this is one hell of a journey - why was it so tough?

I've read so many articles on "use docker", "use docker", "use docker", however, for using ROS2 to use the NATIVE HARDWARE it is not as simple as just "use docker".

In about 2hours time, I'll find out if I can use the NATIVE HARDWARE with this setup.

Nearly 3 hours now, 334/345.... sigh, going to have to leave running overnight.

okay - so after 16 HOURS I pulled the plug.


I rebooted. I was cautious.  What had I broken? What was not going to work?


In order to get all the ROS2 environment variables setup, first have to run:

$ source ~/.bashrc

Now, let's revert back to what failed yesterday:

Clone the repo into ROS2 workspace:

$ mkdir -p ~/ros2_ws/src/

$ cd ~/ros2_ws/src/

$ git clone https://github.com/Myzhar/ldrobot-lidar-ros2.git

Build the Packages:

$ cd ..

$ sudo rosdep init

$ rosdep update

$ rosdep install --from-paths src --ignore-src -r -y

This seems to be executing scipts / github pull downs, IT JUST MIGHT BE WORKING


OMG! That looks like a success?!?!!

As Dawn used to say to me - "if there is no photo or video, Tony, it didn't happen"

So, here's the video:


I have totally forgotten what I was meant to be doing next.  LOL.

Oh yeah - I was just meant to be getting the LIDAR running on the Robot.  Time to plug it back in, let's go check out the github repo and the readme.md to see what the next steps were.

SO CLOSE!

okay, so the next step in the github repo is to just run the $ ros2 command.  Hmm... running that gives a "command not found" error.  Oh, I need to go $ source ~.bashrc

Errr....that didn't seem to do anything.  looking back at these steps:

mkdir -p ~/ros2_humble/src

cd ~/ros2_humble

# Download ROS2 source code

vcs import --input https://raw.githubusercontent.com/ros2/ros2/humble/ros2.repos src

# Update system packages

sudo apt upgrade -y

# Configure rosdep

sudo rosdep init

rosdep update

rosdep install --from-paths src --ignore-src --rosdistro humble -y --skip-keys "fastcdr rti-connext-dds-6.0.1 urdfdom_headers python3-vcstool"

# Build ROS2

colcon build --symlink-install


I then thought, hang on - the last step AFTER the colcon build executes the /install/local_setup.bash >> bashrc.  wait a minute, that file no longer exists?!?!

Does that mean it only gets created / generated once the colcon build finishes successfully?! Hmm... maybe I should try a few things.

cd ~/ros2_humble

$ colcon build --symlink-install --packages-skip-build-finished --catkin-skip-building-tests


What was my thinking here? Well, I can pass the params to tell it to "continue where I pulled the plug" and I'm hoping that last command says to NOT build the tests.  anyway, the output is:

Starting >>> rosbag2_transport

Starting >>> rviz_default_plugins

Starting >>> test_rclcpp

[34.4s] [0/11 complete] [3 ongoing] [rosbag2_transport:build 85% - 32.2s] [rviz_default_plugins:build 3% - 32.1s] ...


Hmm... to me, that looks like it is continuing from where I pulled the plug, I was at 334/345 - which, if my maths is right is 11 things left to build.  So, I see 0/11 - that makes sense. I also see 85% - when I pulled the plug that was at 84% - so this looks like a RESUME command I've given it.

Oh well, it's midday (the next day), so I'll leave this to run for the rest of the afternoon / evening and hope that it finishes?! My theory is that once it does finish it will generate that /install/local_setup.bash file so I can then "do the thing" that needs to be done & then I can run $ ros2 from the command line and then FINALLY get to see the lidar output!


Here's a TEASER for what I want to get to:





hmmmm... so with Task Manager running, I see the CPU = 100%, GPU = 3% and Memory = 3769MB of 4041MB, it appears to have rebooted once :-(

Started again at 4pm.  Sigh, that may have been a "few" hours wasted?!

UPDATE: it has gone past 10pm & it's still going.  After a bit of research I found out that it might take WEEKS to build the ros-humble-desktop directly on the Raspberry Pi 5?!?!?! I did a bit of digging & it sounds like people do the ros-humble-base build install onto the Raspberry Pi 5, that takes 3-5hours and THEN install all the visual stuff onto a laptop that they then connect to across the network.

That's actually pretty smart / obvious if you think about it.  Hmmm.... I'll leave it running over night again & go check at 8am tomorrow - worst case, I pull the plug again & start it again when back in work environment & then just leave it running for days / weeks.  However, probably need to unscrew it all first to sort out that noisy fan!

I just installed ros2-jazzy onto an UBuntu 24 VM image in about 15 mins.

I could run $ rviz2 and I get to see the tool that I am looking for.

I wonder. I wonder. I wonder if I do just rollback to the above and just do a ros2-humble-base install, as that might be all that I need?  That makes sense now how & why people are going with the "docker" install (although that doesn't get me my USB access - but am sure there's a way to hack that) - but if I did the base install, then I reckon it'd finish okay & wouldn't be installing stuff that I really don't need.

I think I'll go for that option tomorrow.

"If it were simple, I wouldn't do it" ;-)



As promised MORE VIDEOS!







a

Comments