This is page is showing published content. Click here to enter preview mode!

Blog.

Installing Ros2 and RTabMap

Emile Swain
Emile Swain

Intro

I'm looking to explore photogrammetry and 3D scanning. Basically, its very cool.

So i figured i'd try my hand at getting RTabMap up and running on a Raspi 4. The following are my notes on getting my realsense cameras up and running on a Pi4.

First attempt

For my first attempt I pretty much made the wrong decission every step of the way. Aside from one. I new that the Pi was not running the version of ubuntu I was likely to need to get Ros2 up and running. Unfortunately I subsequently chose the wrong version of Ubuntu and the Ros2 pacakges I could.

I misunderstood an article that suggested ubuntu 20.10, and well that requires significant knowledge to resolve the dependencies and versions of the other packages. So i switched back to 20.04. But then i accidently picked the 32bit version, and only realised halfway through compiling ros2, why packages were missing and so forth.

I also tried to compile Ros2 Galactic, again i mis read an article somewhere along the way, rather that Ros2 Foxy. Which currently most tutorials seem to be targeting.

So today(a day after my first attempt) i'm starting from scractch, Ubuntu server 20.04, With Ros2 Foxy packages. Here i read again, and correctly this time that https://dev.intelrealsense.com/docs/ros-wrapper Ros2 requires Ubuntu 20.04 Focal. So thats what i've installed on my Pi image.

uname -r
Raspberry Pi OS: Linux raspberrypi 5.4.79-v7l+

lsb_release -r
Release:     20.04

lsb_release -r
Release:     20.04
lsb_release -a
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.3 LTS
Release:        20.04
Codename:       focal

Picking a Ubuntu Sever Desktop

Headache 1. With a new Ubuntu server setup, I want a GUI. Specifically i need a GUI that will work with

  • Ros2 foxy

  • RTabMap

So I ended up here on optionally installing a desktop flavour. But i need to see if there is a specific desktop thats good for Ros2 applications. Which I don't know.

So for lack of any specific recommendation that I could find, I went with ubuntu-desktop which i believe the the Gnome variety.

sudo apt install ubuntu-desktop
> lots of the matrix
> lots of wifi problems, i.e. wrong wifi password
> 2-3 hours down a wifi rabbit hole.
> just needed to reboot and be patient

Once installed, the desktop looses access to the keyboard, Needed to add a new region in the desktop settings using the onscreen keyboard i.e. keyboard/locale for UK and then reboot.

You can then type with the keyboard.

Installing Ros2

I started here https://dev.intelrealsense.com/docs/ros-wrapper and carefully re-read everything again. Because first time i was too rash and lazy. I then picked out this page to follow the exact steps.

and Decided to follow the debians install steps.

Setup Locale

In previous attempts, sudo apt update can result in packages not found, this is due to not actually having a network connection. Just check your connected. If you get the below, it means your not connected. Try rebooting, then make sure you set the correct password in /etc/netplan/50-cloud-init.yml .

ip a
...stuff
wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether dc:a6:32:57:b9:bb brd ff:ff:ff:ff:ff:ff

If you have a connection the the below should work just fine.

sudo apt update && sudo apt install locales

Hit:1 http://ports.ubuntu.com/ubuntu-ports focal InRelease
Hit:2 http://ports.ubuntu.com/ubuntu-ports focal-updates InRelease
Hit:3 http://ports.ubuntu.com/ubuntu-ports focal-backports InRelease
Hit:4 http://ports.ubuntu.com/ubuntu-ports focal-security InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
Reading package lists... Done
Building dependency tree
Reading state information... Done
locales is already the newest version (2.31-0ubuntu9.2).
locales set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8
locale

LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

Setup sources

Again, if you have errors, check your connected to the internet. Also, when trying this on ubuntu 20.10 you can feel like your succeeding, but will fail later.

sudo apt update && sudo apt install curl gnupg2 lsb-release
...
Hit:3 http://ports.ubuntu.com/ubuntu-ports focal-backports InRelease
Hit:4 http://ports.ubuntu.com/ubuntu-ports focal-security InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
Reading package lists... Done
Building dependency tree
Reading state information... Done
lsb-release is already the newest version (11.1.0ubuntu2).
lsb-release set to manually installed.
curl is already the newest version (7.68.0-1ubuntu2.7).
curl set to manually installed.
The following NEW packages will be installed:
  gnupg2
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 4,584 B of archives.
After this operation, 51.2 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://ports.ubuntu.com/ubuntu-ports focal-updates/universe arm64 gnupg2 all 2.2.19-3ubuntu2.1 [4,584 B]
Fetched 4,584 B in 0s (50.7 kB/s)
Selecting previously unselected package gnupg2.
(Reading database ... 176886 files and directories currently installed.)
Preparing to unpack .../gnupg2_2.2.19-3ubuntu2.1_all.deb ...
Unpacking gnupg2 (2.2.19-3ubuntu2.1) ...
Setting up gnupg2 (2.2.19-3ubuntu2.1) ...
Processing triggers for man-db (2.9.1-1) ...

Note: As i understand it, the next cmds get the keys that are used to pull the ros2 packages later. When i tried this with Galactic, i think this is where things went wrong. The key worked, but the packages didn't exist in the Galactic pacakge.

sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key  -o /usr/share/keyrings/ros-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null

No console outputs for these commands (above)

Note Again, when i did this with Galactic, this update, given the above configuration was where I went down a rabbit hole of packages not found and so on. Which is when I started over.

sudo apt update

Hit:1 http://ports.ubuntu.com/ubuntu-ports focal InRelease
Hit:2 http://ports.ubuntu.com/ubuntu-ports focal-updates InRelease
Hit:3 http://ports.ubuntu.com/ubuntu-ports focal-backports InRelease
Hit:4 http://ports.ubuntu.com/ubuntu-ports focal-security InRelease
Get:5 http://packages.ros.org/ros2/ubuntu focal InRelease [4,670 B]
Get:6 http://packages.ros.org/ros2/ubuntu focal/main arm64 Packages [942 kB]
Fetched 947 kB in 3s (273 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.

Which version of Ros2?

Honestly I do not know which one is the best to choose. I'm going for the ros-foxy-desktop because i do have a screen attached to the pi. I want to be able to visualise the scanning process.

I'll have to suffer the performance loss of not just running a server instance and streaming the data to a centralised computer.

sudo apt install ros-foxy-desktop
or
sudo apt install ros-foxy-ros-base

I went with Foxy-Desktop

Note: When I made the mistake of either picking 20.10 or 20.04(32bit) or was it the manual billed, it all went wrong. and I could not find the packages. So its critical to get those early versions correct.

sudo apt install ros-foxy-desktop
> the matrix
> requests confirmation of file size usage.
...
Get:924 http://ports.ubuntu.com/ubuntu-ports focal/universe arm64 python3-pyqt5.qtsvg arm64 5.14.1+dfsg-3build1 [25.1 kB]
....
Setting up ros-foxy-desktop (0.9.2-1focal.20211119.170212) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
ubuntu@ubuntu:~$

Took 10+ minutues I think.

Check ros is all up and running

ros2 run demo_nodes_cpp talker
[INFO] [1642961731.532272703] [talker]: Publishing: 'Hello World: 1'
[INFO] [1642961732.532168268] [talker]: Publishing: 'Hello World: 2'

I then created another terminal (on my pc ssh'd in)

source /opt/ros/foxy/setup.bash
ros2 run demo_nodes_py listener
[INFO] [1642961780.606942992] [listener]: I heard: [Hello World: 50]
[INFO] [1642961781.536814722] [listener]: I heard: [Hello World: 51]
[INFO] [1642961782.536770959] [listener]: I heard: [Hello World: 52]

All Good!


More Stories

Ubuntu Commands

Ubuntu commands

Emile Swain
Emile Swain

Raspi4

research

Emile Swain
Emile Swain