Note: I follow these instructions: https://articulatedrobotics.xyz/ready-for-ros-1-what-you-need/ which lead here: https://www.techradar.com/how-to/how-to-install-ubuntu-on-the-raspberry-pi then adapt them following these guidelines to port to Humble: https://www.youtube.com/watch?v=qoj5_fVBPII
ROS2 Humble requires Ubuntu 22.04 Jammy Jellyfish (or derivative)
-
Buy a 64Gb microSD card (as recommended here: https://ubuntu-mate.org/raspberry-pi/).
-
Format the card FAT32. Not straightforward from a Windows 11 computer, which will insist you use exFAT formats for drives >32Gb. Command line:
> format /FS:FAT32 E:
seemed to be working but was veeery slow! Instead I did it in Ubuntu. Straightforward. -
Download the Ubuntu MATE 22.04.3 LTS arm64 image from here: https://ubuntu-mate.org/download/arm64/jammy/ You may want to verify the checksum (in Windows use
> certutil -hashFile PATH-TO-FILE SHA256
) -
Flash the image onto the card using e.g. balena etcher. A Windows portable version can be downloaded from here: https://etcher.balena.io/ and run by double-clicking. Flashing was reasonably fast, but verification failed, twice. I tried from linux instead and it worked the first time.
-
Insert the SD card in the RPi, connect it to a keyboard, mouse, screen and power, switch it on, and follow the steps of the ubuntu MATE OS setup process. This takes time.
-
Set up the network as part of the OS installation. Note I did not use netplan despite this recommendation
-
Update and upgrade. This fixes some bugs with Welcome, Software Boutique and others, see: https://ubuntu-mate.community/t/ubuntu-mate-welcome-and-software-boutique-fail-to-run-with-similar-errors/25371):
$ sudo apt update
$ sudo apt upgrade
Also it is veery sloow.
At the end of this process some issues remain:
- still no audio output from RPi HDMI despite I tried several fixes including selecting output, plugging on HDMI0 (from here), and modifying config files from here.
- git with:
$ sudo apt install git
- arduino 1.8.19 for ARM with:
$ sudo apt install arduino
. Then add the user to thedialout
group with$ sudo usermod -a -G dialout <username>
then logout (GUI also asks for this, and reminds logout is required). Serial ports were not working due to a conflict with some Braille package, which needs deinstallling with$ sudo apt remove brltty
cfr. https://www.youtube.com/watch?v=qoj5_fVBPII. Test with Blink and AnalogReadSerial from Examples/01. Basics - ssh with:
$ sudo apt install openssh-server
get local IP address of bot with$ ip addr
and write it down. Now we can remotely ssh from laptop withssh <bot_username_bot>@<bot_addr> # e.g. [email protected]
- pyserial-miniterm (previously
miniterm
, note the change of name in 22.04) with:$ sudo apt install python3-serial
- install and configure vs-code ssh and arduino extensions to remotely flash arduino from RPi4 following these instructions: https://www.youtube.com/watch?v=2BJ-iJF04VA
Follow these instructions: https://docs.ros.org/en/humble/Installation/Ubuntu-Install-Debians.html
- If needed, set locale to support UTF-8
(in minimal environments (e.g. docker), the locale may be something minimal like
POSIX
)
$ locale # check for UTF-8
$ sudo apt update && sudo apt install locales
$ sudo locale-gen en_US en_US.UTF-8
$ sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
$ export LANG=en_US.UTF-8
$ locale # verify settings
- Setup Sources
Add the ROS 2 apt repo: 1) ensure Ubuntu Universe repository is enabled, 2) add the ROS 2 GPG key with apt, and 3) add the repo to your sources list.
$ sudo apt install software-properties-common
$ sudo add-apt-repository universe #enable ubuntu universe repo
$ sudo apt update && sudo apt install curl -y
$ sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg #add gpg key
$ 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" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null # add repo to sources
- Ensure your system is up to date before installing ROS2 packages. Always recommended, but particularly in 22.04
systemd
andudev
-related packages must be updated before installing ROS 2 or your system may crash.
$ sudo apt update && sudo apt upgrade
- Install ROS 2 Desktop Install which includes ROS, RViz, demos, tutorials.
$ sudo apt install ros-humble-desktop
- Install colcon
$ sudo apt install python3-colcon-common-extensions
- Source the ROS2 environment
$ echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc
$ source ~/.bashrc
- Test communication between a C++ node running on the PC and a python node on the bot
$ ros2 run demo_nodes_py listener
...
[INFO] [1662750392.965285945] [listener]: I heard: [Hello World: 63]
[INFO] [1662750393.965151014] [listener]: I heard: [Hello World: 64]
[INFO] [1662750394.965403701] [listener]: I heard: [Hello World: 65]
...
(PC):$ ros2 run demo_nodes_cpp talker
...
[INFO] [1662750396.990408713] [talker]: Publishing: 'Hello World: 67'
[INFO] [1662750397.990414028] [talker]: Publishing: 'Hello World: 68'
[INFO] [1662750398.990288416] [talker]: Publishing: 'Hello World: 69'
...
Hurray! It works even with foxy on PC and humble on RPi!
Next steps:
- upgrade laptop to Humble (see this Articulated Robotics video and this Medium article )
- or maybe use docker?: https://betterprogramming.pub/how-to-use-docker-to-run-multiple-ros-distributions-on-the-same-machine-d851b42aed5
Continue following instructions here: https://www.youtube.com/watch?v=qoj5_fVBPII
Need to install some more dependencies:
$ sudo apt install ros-humble-ros2-control ros-humble-xacro
Create a workspace, clone repos and build
Clone: robot repo from manolobot (used "the good way", making a symlink, see https://github.com/mhered/manolobot/blob/main/Part-4-Simulation-Jan23.md), diffdrive from specific branch of buzzology fork and serial library from josh fork:
$ git clone https://github.com/mhered/manolobot.git
$ mkdir -p ~/robot_ws/src
$ ln -s ~/manolobot/manolobot_uno/ ~/robot_ws/src/
$ cd ~/robot_ws/src
$ git clone http://github.com/buzzology/diffdrive_arduino
$ cd diffdrive_arduino
$ git checkout 3883c00
$ cd ~/robot_ws/src
$ git clone http://github.com/joshnewans/serial
Then build and source workspace, run the node that listens for commands:
$ cd ~/robot_ws
$ colcon build --symlink-install
$ source install/setup.bash
$ ros2 run serial_motor_demo driver --ros-args -p serial_port:=/dev/ttyUSB0 -p baud_rate:=57600 -p loop_rate:=30 -p encoder_cpr:=1975
In the PC build workspace and run GUI:
(PC):$ cd dev_ws
(PC):$ source install/setup.bash
(PC):$ $ ros2 run serial_motor_demo gui
Hurray! Can control motor over ROS2 with PC in foxy and bot in humble!!
However, the original launch file does not work...
$ ros2 launch manolobot_uno launch_robot.launch.py
[Some Error]
- To do: find out what is wrong
-
Connect the Pi camera. Note if camera was connected while the RPi was on, you may need to reboot.
-
Reinstate the legacy camera driver from 20.04 (fix suggested by Josh Newan) by editing the following lines in the config file with
(Rpi):$ sudo nano /boot/firmware/config.txt
:... camera_auto_detect=0 # was 1, modified by MH to reinstate legacy camera driver display_auto_detect=1 start_x=1 # added by MH to reinstate legacy camera driver ...
-
Install sfw in Rpi ( v4l2-utils video driver library and ros node):
$ sudo apt update $ sudo apt upgrade $ sudo apt install libraspberrypi-bin v4l-utils ros-humble-v4l2-camera
-
If needed add the user to the video group:
$ sudo usermod -aG video mhered $ groups mhered adm dialout cdrom sudo dip plugdev lpadmin sambashare
Reboot for group changes to take effect
-
Check the camera is detected and supported with:
$ vcgencmd get_camera
supported=1 detected=1, libcamera interfaces=0
If the RPi is connected to a screen you may check streaming with:
$ raspistill -k
Quit with x
Check if v4l
(video for linux) can see the camera with:
$ v4l2-ctl --list-devices
bcm2835-codec-decode (platform:bcm2835-codec):
/dev/video10
/dev/video11
/dev/video12
/dev/media1
bcm2835-isp (platform:bcm2835-isp):
/dev/video13
/dev/video14
/dev/video15
/dev/video16
/dev/media0
mmal service 16.1 (platform:bcm2835-v4l2):
/dev/video0
Install image transport library and rqt_image_view:
$ sudo apt install ros-humble-image-transport-plugins ros-humble-rqt-image-view
Launch driver node:
$ ros2 run v4l2_camera v4l2_camera_node --ros-args -p image_size:="[640,480]" -p camera_frame_id:=camera_link_optical
Then launch rqt_image_view
from the PC:
(PC):$ ros2 run rqt_image_view rqt_image_view
Hurray! the bot broadcasts video to the laptop!!
Note: it broadcasts only over /image_raw_compressed/
See https://www.youtube.com/watch?v=qoj5_fVBPII
- fix screen rotation problem?
- Setup lidar? ros humble rplidar