Laptop & Rpi Connectivity - Workshop 1

Video of Workshop 1

The video of the first workshop 1 presentation is here. Warning: it is 3 hours of mostly working with participant's connectivity problems, but the last hour goes into docker theory.

apt quick reference

You'll use apt for installing apps on Linux systems (RPis, VMs and wsl)

Editors: vi or nano

TODO: add ssh & sftp/scp instructions

HW required:

Prerequisites:

Content outline

Where we will run and view apps of different kinds

The laptop displays all terminals and GUIs, whether their I/O be generated by the RPi or by the PC.

Laptop:

RPi from ssh login:

RPi from VNC client window

Hands-on

Laptop Configuration

This section describes how to configure your laptop to work with ROS2 software running on an rpi.

It is possible to use only vnc, and to run all exercises on an rpi.  In that case, no laptop configuration is needed. You can delay the decision to install ROS on a laptop - it will not affect the exercises.

Configure Laptop to monitor RPi boot over serial

Install a comms program to the base Linux or Windows PC in order to use the RPi serial port for monitoring boot and configuring networking. miniterm is a lightweight choice for linux, but minicom is also suitable, or any other standard comms program). If you're running Windows you'll also need a driver for the USB-serial cable.

Add RPi to etc/hosts on laptop

Edit your laptop's hosts file and add the IP address of the RPi

Install ssh client on laptop

Install an ssh client on the Windows or Linux PC to enable launching ROS programs from the command line. openssh is a good choice. (It looks like Windows 10 might come with an ssh command-line client, so a GUI client may not be necessary.) ssh clients also provide sftp - an ssh-based implementation of ftp, useful for file transfers between laptop and rpi.

Install the remote-ssh extension into vs-code (optional)

If you want to use vs-code to edit files on the RPi, launch vs-code and install the Remote - SSH extension. It will use the openssh keys you installed in the preceding step.

Install a VNC client on laptop

In this segment we install tigervnc-viewer or equivalent on the base Windows or Linux PC in order to perform graphical operations on the RPI. Oddly, configuring networking using the Network Manager seems to be one of the most useful cases, but also ROS utilities can be run directly on the RPi

Install rpi-imager

In this segment we install rpi-imager to the base Linux or Windows PC in order to load Raspberry Pi OS onto an SD card or SSD. Be sure to get version 1.8.4 or later.

RPi Configuration

In this segment we install the latest Raspberry Pi OS onto an SD card on a Raspberry Pi and configure it for developing ROS software.

The overall approach taken is to run Raspberry Pi OS on the RPi, because it is the latest and best suited to RPi hardware, but ROS programs are run inside a docker container, because ROS isn't supported on Raspberry Pi OS. The ROS docker container uses the host's networking stack, and mounts /dev for hardware access. 

My configuration: user bouchier is the main user account on both linux laptop and the RPi and inside the ROS docker container, and has ability to commit to github from either laptop or rpi4, and to ssh from laptop to rpi4 without needing to enter a password.  Consider doing something similar with your config.

ROS source code is saved in the recommended places on RPi OS and is edited (generally) on the RPi OS filesystem then built and tested and run in the docker container. Build products are stored on the RPi OS filesystem, so as to persist across container instances. 

Containers are (generally) removed after each use, and re-instantiated from the image each time they're started. See the ROS docker page for more details.

The ROS docker containers are configured with the ROS GUI apps, which can be run either on the rpi or on the laptop. Generally, running on the laptop will perform better and may be more convenient because they won't be bound inside a vnc window.

rpi-imager configuration

In this step we connect the boot media (typically SD-card, but could be SSD) to the laptop, run rpi-imager to install a firmware update image or a Raspberry Pi OS image, then reconnect the boot media to the rpi and boot the rpi from it.

VERY IMPORTANT: DON'T SKIP THIS STEP

You want your initial user on RPi to be the same as on your Ubuntu-PC. If you don't do this step you'll end up having to configure networking manually, add your username to sudoers, get it synced to github, or you'll forever be user pi and your identity will feel quite mixed up.

Note: I found RPi didn't seem to boot the first time until I connected a monitor (but I may not have waited long enough).

RPi firmware configuration

The purpose of these steps is to provide a serial console interface which can be used to configure RPi networking when the robot is placed in a new wifi environment.

This section describes settings in the boot config files. The only change required is to modify config.txt and cmdline.txt.


# Enable uartenable_uart=1

dtoverlay=uart2

dtoverlay=uart3

dtoverlay=uart4

dtoverlay=uart5

Test serial console and networking

Raspberry Pi Header showing TXD and RXD and Ground pins

Raspberry Pi OS Configuration

These are the steps to configure Raspberry Pi OS on the RPi once it has been installed and is bootable. 

Host rpi4    HostName rpi4    User bouchier

Package Installation

This section describes installation of packages needed to make ROS on RPi work as desired. Note: some of these steps are no longer necessary if using the 1.8 version of rpi-imager; it does a lot more to pre-configure the system.

Install VNC on RPi

VNC was chosen for graphical use because generally the robot's RPi would run headless, but remote desktop capability is sometimes valuable. 

Observations: the current version of RPi OS doesn't support the RealVNC server which ships with it, owing to Raspberry Pi OS using Wayland and RealVNC using X11. Tigervnc is the recommended alternative

Test vnc

miniterm for linux (optional)

Miniterm is a lightweight python serial comms app. It is useful for talking to the robot microcontroller. Installing it can be delayed. Configure python for miniterm, (serial port access from python, etc). sudo apt install python-is-python3; sudo apt install python3-pip; Add the following to .bash_aliases: alias miniterm='python -m serial.tools.miniterm --eol LF'

Make ROS source directory in the RPi home

mkdir -p ros2_ws/src

Configure Laptop to run ROS2 locally

It is (in Paul's opinion) beneficial to run ROS in a docker on the laptop, because you have so much more power there, and because ROS2 windows can be intermixed with your other desktop windows, rather than being locked into a VNC or a VM desktop. For example, exploring data in interactive GUIs should be much snappier, and you can run simulations. But this is a "soft benefit", not a hard requirement. In this segment we either use wsl or we configure a virtual machine on the laptop or we install Ubuntu 22.04 on a PC, in order to run ROS2 in a docker container.

Option 1 (More Preferred for Windows Users: Enable WSL2 on Windows and download a preconfigured VM

wsl --import <distro_name> <install_location> <tar_file_name> [Options]

For example:

wsl --import Ubuntu-ROS2 C:\Users\dprg\Downloads\Pauls_ros2_distro Ubuntu22.04.ros2.tar

Test the ros2 VM

Option 2: Install VirtualBox and Install Ubuntu 22.04 on laptop

This step is recommended if you're not running Linux on your laptop - it enables you to run ROS2 with laptop performance.

If you have some other way of getting Ubuntu 22.04 to run on your laptop (e.g. a different VM) you can use that. Or you can run the tutorials on your RPi.

If you need to install VirtualBox on Ubuntu, this page gives instructions: https://ubuntu.com/tutorials/how-to-run-ubuntu-desktop-on-a-virtual-machine-using-virtualbox#1-overview

Configure Ubuntu 22.04 in the VM

%sudo ALL=(ALL:ALL) NOPASSWD:ALL

Install ros2 and the extras in the Ubuntu install