Can i use Robot hat with ubuntu server 24.04 lts

I wanna now if when or is ubuntu serve 24.04 lts usable for the sunfounder robot hat if possible?

Very sorry, but currently have no idea to make Ubuntu system compatible with Robot Hat.

thats okay thanks for replying

I have ported picar-x to run on Ubuntu server 24.04. Most of the example codes run successfully. I also have example robot code using ros2 jazzy. The port is not complete (no support for pi camera (picamera)). I’ve documented the changes and installation procedure.

Hi, I added picamera ros2 jazzy support previously ( for orbslam3). Was humble but since updated to jazzy. Note this is running on raspbian not ubuntu

If you’d like to collaborate then maybe we could share notes at some time?

Definitely. I did a partial port of the picar-x to ros2 on raspberry pi os. Had lots of issues finding ros2 dependencies. In particular I couldn’t find buildable joystick control code.

I did a raspbian jazzy build from source last week. I’ll post my script here when I get back to my computer. It’s quite short, but with a couple of important tweaks.

I did my ros joystick build on humble, so it may or may not still work, not sure.

My joystick build should be on an old sd card somewhere. I’ll see if I can find it.

I’m not doing ros stuff at present, focussing on different autonomy models instead. Hopefully when I’ve learned a bit more about them I may integrate into ROS, TBD.

#If you wish to try a raspbian build then my ros2 jazzy build script is below, or just stick with Ubuntu if it’s working fine already.

#Usual to ensure all upto date

sudo apt update
sudo apt upgrade

#I like vim! But please swap for favorite editor
sudo apt install vim

#Max out everything for swap!
#increase swap space (allocate more if needed): and zram compression
sudo apt install zram-tools

sudo dphys-swapfile swapoff
##Edit to increase swap as needed I used 8g on a 4g pi4
sudo vim /etc/dphys-swapfile
#AND SAME FOR I used 8g
sudo vim /sbin/dphys-swapfile
sudo dphys-swapfile setup
sudo dphys-swapfile swapon
sudo reboot now

#####################################################################################
#Installing ROS2
#Directly installing ROS2 on Pi raspbian is not possible; it must be built from source. as below

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

mkdir -p ~/ros2_jazzy/src
cd ~/ros2_jazzy # important NOT the src subdirectory created above, but this parent.

#This seems to be a very unreliable link, may need to run several times until no more “E”'s
##Otherwise can get missing libraries etc
vcs import --input https://raw.githubusercontent.com/ros2/ros2/jazzy/ros2.repos src

sudo rm /etc/ros/rosdep/sources.list.d/20-default.list
sudo apt upgrade
sudo rosdep init

rosdep update
rosdep install --from-paths src --ignore-src --rosdistro jazzy -y --skip-keys “fastcdr rti-connext-dds-6.0.1 urdfdom_headers python3-vcstool”

#This takes about 8 hours on rpi4 4Gb. could even freeze due to memory problems, just rerun. Reduce/increase parallel workers if you have less/more memory than my 4GB
colcon build --symlink-install --parallel-workers 2

echo “source ~/ros2_jazzy/install/local_setup.bash” >> ~/.bashrc
source ~/.bashrc

1 Like

I think I I got my joystick drivers from here

`https://app.circleci.com/pipelines/github/ros-drivers/joystick_drivers `

Then just wrote my own listener node

do you got a link for it?

Hi,

I’ve got Robot-HAT v4 installed on a raspberry pi5 running Ubuntu 24.04 LTS.

So far I have been able to install the sound card successfully and was able build pinctrl from raspi-utils github repository to get it working. TTS with espeak works great.

servo and motor test files also working as expected.

I have ROS2 jazzy installed already and will try to get a basic robot running with the robot-hat. I can’t see why it should not work

So far I have had luck in getting the robot-hat v4 working on a Pi5 running ubuntu 24.04 LTS. Was able to get the sound card installed and working but had to build pinctrl from github repository. TTS is working as is tone_test.py with onboard speaker. Motor and servo tests also successful

do you have links or instructions for it so i can use it?

No links. I went through the install script for the robot-hat v4 and manually executed the various steps and tried some work-arounds for the bits that were not the same between piOS and Ubuntu 24.04. I was a bit surprised I could get it working but it seems to work.

It would be great if someone else could try and see if they too can get it working. I’ll go back through my notes and document the steps and post it back here later in the week. I can’t guarantee it doesn’t break things but so far it seems workable.

thanks i cannot wait :+1:

1 Like

Installing Robot HAT v4 on Ubuntu

I have double checked the install.py file and i2samp.sh script and reviewed the breif notes I made at the time and I think just a few simple steps should successfully install a robot-HAT v4 on a Raspberry Pi 5 runnung Ubuntu 24.04

1) Clone robot hat repository to home directory (follow instructions on Sunfounder website)

  1. cd ~/
    git clone -b v2.0 https://github.com/sunfounder/robot-hat.git
    cd robot-hat
    
  • DO NOT run the instal.py file as it will fail
  • Install required packages and setup manually as below

2) Install required packages from APT repository

  • raspi-config (not bundled in Ubuntu 24.04)

  • i2c-tools

  • espeak

  • libsdl2-dev

  • libsdl2-mixer-dev

  • portaudio19-dev

  • sox

  • sudo apt install raspi-config i2c-tools espeak libsdl2-dev libsdl2-mixer-
    dev portaudio19-dev sox
    

3) Install required python packages

  • smbus2

  • gpiozero

  • pyaudio

  • spidev

  • pyserial (package not on apt. Use python3-serial instead)

  • pillow (newest version python3-pil with ubuntu and is automatically selected instead

    by apt)

  • pygame>=2.1.2 (was unable to install version 2.1.2 from apt. used python3-pygame

    instead which downloads v2.5.2-2 instead)

I installed each package system-wide using:

  • sudo apt install python3-<PACKAGE_NAME>
    

If installing into a virtual environment, use pip instead

  • python3 -m pip install <PACKAGE_NAME>
    

4) Enable I2C and SPI interfaces

  • Open raspberry pi configuration tool by typing following into terminal

  • sudo rasp-config
    
  • Select option 3 - Interface options and enable I2C and SPI

5) Copy hardware dtoverlays to overlays directory

  • Copy required harware overlays from within robot-hat directory to /boot/firmware/overlays/ directory

  • cd robot-hat
    
  • cp ./dtoverlays/* /boot/firmware/overlays/
    
  • This will copy sunfounder-robothat5.dtbo and sunfounder-servohat+.dtbo to the directory

  • Edit config.txtto apply these overlays at time of boot

  • cd ~/
    sudo nano /boot/firmware/config.txt
    
  • Add the following lines to config.txt after the [All]

  • dtoverlay=sunfounder-robothat5
    dtoverlay=sunfounder-servohat+
    
  • Exit with ctrl-X and Y to save changes

6) Reboot and try python programs in test folder

  • NOTE: you MUST copy the robot_hat folder (robot_hat module) into the tests folder for the python testing programs to work

  • Motor and servo demo files should now work

  • Sound card setup and audio testing follows separately

Setup robot-HAT v4 Soundcard and test audio on Raspberry Pi 5 running Ubuntu 24.04

  • Instructions to setup soundcard and audio on raspberry pi running raspbian OS linked here:

https://docs.sunfounder.com/projects/robot-hat-v4/en/latest/install_i2s_for_speaker.html

  • Running i2samp.sh bash script in terminal will fail as Ubuntu 24.04 does not have the expected required packages:
    • raspi-config needed to enable pulseaudio
    • raspi-gpio (pi 4 or older) or pinctrl (pi 5) to control GPIO pins
  • raspi-config was installed during the initial hardware install above and this should now work

1) Installing pinctrl on Ubuntu

  • pinctrl is not part of Ubuntu distribution and cannot be installed from APT or snap.

  • Install prerequisites:

  • sudo apt install cmake device-tree-compiler libfdt-dev libgnutls28-dev
    
  • Clone utilsrepository to home directory and then change to utils directory

  • git clone https://github.com/raspberrypi/utils.git
    cd utils
    
  • Can either build all utilities in the utils directory, or change to pinctrldirectory and build pinctrl only (I built them all)

  • cd pinctrl
    cmake .
    make
    sudo make install
    
  • If you need to build the associated libraries (like libdtovl, gpiolib, piolib) as shared libraries instead of static ones, use the following cmake command instead:

  • cmake -DBUILD_SHARED_LIBS=1 .
    make
    sudo make install
    
  • Verify install was successful:

  • pinctrl --help
    

2) Run i2samp.sh script to complete installation and configuration of soundcard and test speaker audio

  • The script will:
    • verify / install required apt packages ( pulseaudio, pulseaudio-utils, alsa-utils, jq, sox)
    • detect soundcard for either v4 or v5 HAT and install overlays and configure appropriately
    • enable pulseaudio using raspi-config
    • select robot-hat soundcard
    • play test audio via pinctrl on appropriate GPIO pin
  • You may need to restart / re-run the i2samp.shscript a few times for it to work
  • cd ~/robot-hat
    sudo bash i2samp.sh
    
  • You should hear the audio from the HAT onboard speaker

NOTES:

  1. I found that after reboot, audio test python file did not work and I had to re-run i2samp.sh script after each reboot for the soundcard to work / selected

Addendum to apt install list

I was going through the install.py script again and just noticed that there is a raspbain version check function that determines which version of libttspico_utils and libttspico to install with apt. These are used for pico2wave TTS package.

If there are any issues, perhaps check / install these with apt to be sure