Skip to content

RaspberryPiSetup

Vincent Belpois edited this page May 16, 2024 · 4 revisions

Setup of the raspberry pi 4

To run ROS2 on the raspberry pi 4, the following steps were taken :

  • Choose and install an OS
  • Install

Choice and installation of the OS

As we do not need a desktop environment ont the raspberry embedded in the robot's electronics, we chose to install Ubuntu Server 22.04 64bits :

  • Ubuntu was chosen because it is both well supported on the raspberry pi and for ROS2
  • 22.04 was the latest LTS version at the time of the installation
  • 64 bits was chosen for the increased performance

We used raspi-imager to flash the OS on a microSD card.

sudo apt install raspi-imager

The following parameters were changed before flashing :

  • The hostname was changed to raspi
  • The user was changed to ezbot with the password ezbot
  • The region was set to France for the input methods
  • The region was changed to Fr fot the wifi
  • The wifi network was configured
  • The ssh server was enabled

Configuration of kernel settings

Serial configuratio

As we want to use some serial interfaces on the raspberry pi, we need to enable them in the kernel settings. This was changed in the overlay file /boot/firmware/usercfg.txt by adding the following lines :

dtoverlay=uart1 

I2C configuration

dtparam=i2c_arm=on

Installation of ROS2

Once the SD card is flashed and inserted in the raspberry pi, we can connect to it using ssh :

We first update the system :

sudo apt update
sudo apt upgrade

Then we install ROS2 (based ont the tutorial here : https://docs.ros.org/en/humble/Installation/Ubuntu-Install-Debians.html) :

sudo apt install software-properties-common
sudo add-apt-repository universe
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
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
sudo apt update
sudo apt upgrade
sudo apt install ros-humble-ros-humble-ros-base ros-dev-tools

Setting up the robot's workspace

git clone -b ezBot-ROS_ws --depth 1 https://github.com/ensmasteel/ezBot

Other dependencies

For serial communication :

sudo apt install libserial-dev

For xacro :

sudo apt install ros-humble-xacro

For the game controller :

sudo apt install ros-humble-joy

to launch the main launch file with the log_level variable set to INFO

ros2 launch ezbot_descr_simul real_robot.launch.py log_level:=INFO

nav2-util and libudev-dev seems to be necessary for the lidar module tow work

sudo apt install ros-humble-nav2-util libudev-dev

To create a virtual serial port for testing :

socat -d -d pty,raw,echo=0 pty,raw,echo=0

region setting :

in /boot/firmware/cmdline.txt add the following line : 
cfg80211.regulatory=US