ROS on Raspberry PI 4
Mistry Siddh Lv4

ROS

Overview

We will be install ROS on Raspberry PI 4 without Ubuntu. In this tutorial we we will be using docker insted of using ubuntu or any other software.

Requirments

  • Laptop or Desktop
  • Stable internet connection(Mobile or Router no matter which connection is it)
  • Raspberry Pi with 4GB+ ram (mine is Raspberry Pi 4 B+ model with 8GB of ram)
  • MicroSD card with a minimum of 32GB size
  • Power supply (power bank or cell phone adaptor)
  • MicroB to HDMI with monitor(optional) if you’re going to use a monitor then you will be needing of keyboard
  • And most important thing a cup of coffee

Step 1 - Hardware setup

Ok first of all we need some software which will help us to flash memory card so that we can install os in the memory card to boot in pi.

Raspberry pi software

Go to https://www.raspberrypi.com/software/ and download software according to your OS I’m using Zorin OS which is based on Ubuntu so I will be using the terminal. If you are using terminal use the following command

1
sudo apt install rpi-imager

as you can see in the below image I have already installed it on my device
Terminal

Go ahead and open it up after opening it up plugin your 8GB or higher sd card on your laptop. as you can see in the image I have inserted 8GB of card
Disk

Now do the following steps as soon in the photo’s

Disk

Disk
Select Raspberry Pi OS(other)

Disk
Then select Raspberry Pi OS with desktop

Disk

Now select your disk but before writing your os we will configure it first so that we don’t have to connect any kind of ethernet cable or mini Wi-Fi. Press ALT + SHIFT + X to open secret setting

Disk
Note: set your hostname and remember it we will be needing it later

Disk
Click on Yes and let it complete it. After that, you will be granted this message so it means that it is been completed.

Disk

Step 2 - Booting UP

Remove your memory card from the computer and plug that it into pi and power it on, well as the pi is doing some process grab a cup of coffee and wait for a few minutes.

A few moments later

Open up your terminal and enter the following command

1
2
# as you remember I have told you to set your hostname in the software and remember it.
ssh [email protected]

Replace your hostname with the hostname you have set while preparing the sd card. In my case, I have set my hostname with datacenter so my command will be like this

1
ssh [email protected]

Pi Login

as soon as you hit enter it will as you for a conformation like this

1
2
3
4
~ ➤ ssh [email protected]                                                   
The authenticity of host 'datacenter.local (192.168.32.200)' can't be established.
ECDSA key fingerprint is SHA256:VlnqrEfP5pLc62h2TQbN0Z4pEudRsmRQL4+LqDD6ZB8.
Are you sure you want to continue connecting (yes/no/[fingerprint])?

answer it with yes after that it will as you for a password which we have set during the software installation. As you have given the password right then you will see that you have been login into your account successfully like I did.

Pi Login Successful

Congratulation we have been login successfully into our pi take a break grab a cup of coffee and relax.

Step 3 - Software setup

As we successfully login into pi first we will update the repository as well as we will be upgrading it by the following command don’t worry if you haven’t used Linux in your life this will be your first experience as well as it will be really easy just follow my steps.

Update and Upgradation of packages

1
2
3
sudo apt update
sudo apt upgrade -y
sudo apt full-upgrade -y

The above command will update the repositories as well as it will be upgrading all the packages which are outdated so that we don’t get any kind of error while installing. It will take a few minutes after all the process is completed we will check once again if there is any software that is left to upgrade by the following command.

1
sudo apt update && sudo apt list --upgradable

The following command will check whether any package is upgradable or not, if its all upgrade then it will return it with this message

Pi updated

Package Installation

Now we will install some few pre-required software so that we will use it properly. Follow me oh and don’t forget your cup of coffee ;)

1
2
3
sudo apt update
sudo apt install nano wget git curl htop -y
sudo init 6 # this command will restart your Raspberry PI4

Step 4 - Getting docker

There is a script which will help us to easily install docker on our PI without any command just a single command and then run it. Right simple as it says lets give it a run.

Download the following scipt

1
curl -fsSL https://get.docker.com -o get-docker.sh

After downloading it script rut it with super user permission(root access)

1
sudo bash get-docker.sh

Grab your cup of coffee and wait till the installtion is over

Once Docker is installed, add your login user to the docker group with the following command:

1
sudo usermod -aG docker $(whoami)

For our safty we will reboot out PI for external changes

1
sudo init 6

After rebooting just check docker verion by following command:

1
docker version # if the following command wont work then add sudo in front of it

This is the following version which im running right now:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
docker version
Client: Docker Engine - Community
Version: 20.10.19
API version: 1.41
Go version: go1.18.7
Git commit: d85ef84
Built: Thu Oct 13 16:45:42 2022
OS/Arch: linux/arm64
Context: default
Experimental: true

Server: Docker Engine - Community
Engine:
Version: 20.10.19
API version: 1.41 (minimum version 1.12)
Go version: go1.18.7
Git commit: c964641
Built: Thu Oct 13 16:44:07 2022
OS/Arch: linux/arm64
Experimental: false
containerd:
Version: 1.6.8
GitCommit: 9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6
runc:
Version: 1.1.4
GitCommit: v1.1.4-0-g5fd4c4d
docker-init:
Version: 0.19.0
GitCommit: de40ad0

Step 5 - Installing Docker composer

Docker Compose is a tool for automating Docker projects using a YAML file. With the help of thi file you can create many project from scratch as I did.

1
sudo apt install python3-pip -y

PIP is a tool which will help us to install docker composer. If it already install then we will move on to the next step

1
sudo pip3 install docker-compose

After installing docker composer we will check wheather it is installed properly or not

1
2
3
4
5
docker-compose version
docker-compose version 1.29.2, build unknown
docker-py version: <module 'docker.version' from '/usr/local/lib/python3.10/dist-packages/docker/version.py'>
CPython version: 3.10.7
OpenSSL version: OpenSSL 3.0.5 5 Jul 2022

Step 6 - Installation of ROS (semi-final step)

Before going further we will just give it a reboot so that we make sure that everything is working propely

1
sudo init 6

As we have rebooted our system we will now search for our docker repository by using docker search command

1
2
3
4
docker search siddhmistry
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
siddhmistry/mrfoxie 0
siddhmistry/ros_rpi4 ROS for Raspberry PI 4 0

We need to install second one which is second one siddhmistry/ros_rpi4 follow the following steps

1
2
3
xhost +
docker pull siddhmistry/ros_rpi4:armhf
docker container run -it --name ROS_RPI4 --net=host -e DISPLAY siddhmistry/ros_rpi4:armhf

Now it will take come time so have a coffee break

Step 7 - Final step

As by now you have noticed that a terminator has been popped up run the following command so that we can setup our ROS System

1
2
3
source /opt/ros/noetic/setup.bash
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
source ~/.bashrc

As we have completed all the steps try to run roscore if this commands works then you have successfully installed it. Press Ctrl + C to exit roscore after that type exit to exit it. Now that we have done everything we just need to install just a small thing which is called Portainer which will help to run this container easily

Step 8 - Installing Portainer

As we know we have already install docker so we will start installing Portainer so just follow the steps

First, create the volume that Portainer Server will use to store its database:

1
docker volume create portainer_data

Then, download and install the Portainer Server container:

1
docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest

Portainer Server has now been installed. You can check to see whether the Portainer Server container has started by running docker ps:

1
2
3
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
de5b28eb2fa9 portainer/portainer-ee:latest "/portainer" 2 weeks ago Up 9 days 0.0.0.0:8000->8000/tcp, :::8000->8000/tcp, 0.0.0.0:9443->9443/tcp, :::9443->9443/tcp portainer

Now that the installation is complete, you can log into your Portainer Server instance by opening a web browser and going to: portainer

1
https://localhost:9443

When you open the url you will be asked to steup admin username and password after login into the admin panel it looks like this

Portainer

Here you will see a local enviroment click on it and this page will open it up:

Portainer Enviroment

At the left side panel you will able to see Containers option. When you open that page it will grant you with some containers.

Portainer Enviroment

You will see that there is a container name ROS_PI4 select it and press start anf baam it started working. Portainer is a tool where it will help you control your container and also to add more containers in it. I hope you loved it.

Mr. Blogger

Podcast

Social Media

Donation

Play Store

Get it on Google Play

  • Post title:ROS on Raspberry PI 4
  • Post author:Mistry Siddh
  • Create time:2022-10-17 07:06:04
  • Post link:https://mistrysiddh.com/2022/10/17/ROS-on-RaspberryPI4/
  • Copyright Notice:All articles in this blog are licensed under BY-NC-SA unless stating additionally.
 Comments