ROS2:Iron Docker on Raspberry Pi 4 - Installation and set up

All Aboard the ROS2 and Docker Express on Raspbian

Ahoy code-voyagers! Time to assemble our geeky gears because today we're setting sail with Docker and digging deep into ROS2 on Raspbian. Our journey is divided into four epic stages: installation, setup, remote GPIO connection setup, and the Docker Compose creation grand finale. So, hold on to your hats, we're diving in!

Stage 1: Installation

First up, Docker installation; the heart of our geeky adventure. Brace yourselves for pigpiod - the unsung hero behind local and remote GPIO control. And to sweeten the deal, we are also adding the current user to the Docker group, so you won't need to prefix Docker commands with 'sudo'. Let the magic commands do their thing:

sudo apt-get update && sudo apt-get upgrade
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker ${USER}
newgrp docker
Stage 1 Install Script

Calling 'newgrp docker' will update your group membership otherwise, Log out and log back in so that your group membership is re-evaluated.

Stage 1 Add group

Stage 2: Directory Setup

Next, the directory setup for our imminent ROS2 project. Ready your keyboards for this easy command:

mkdir -p ~/ros2_ws/src
Stage 2 Project Directory

Don't forget to update 'ros2_ws' to your epic project name.

Stage 3: Remote GPIO Connection Setup

Now, we venture into the thrilling realm of remote GPIO control. Remember, step carefully, the world of Raspberry Pi's GPIO is not for the faint-hearted.

# Step 1: Install pigpio.
sudo apt-get install pigpio python3-pigpio python3-gpiozero 

# Step 2: Enable the pigpio daemons.
sudo systemctl enable pigpiod
sudo systemctl start pigpiod

Stage 3 GPIO set up

Stage 4: Pulling Docker Images and Testing ROS2

The grand finale - pulling pre-made Docker Hub images! Brace yourselves, it's command-line magic time!

docker pull ros:iron-ros-core-jammy

Now that we have our shiny new image, let's create and start a container using this image:

docker run -i -t ros:iron-ros-core-jammy

And we're in! Let's use ROS2 commands for testing, for example:

ros2

Voila! It's working, captain!

Stage 4 Screenshot

With that, we reach the colorful sunset of our adventure. But the journey doesn't end here, the next voyage takes us into the depths of Docker Build and Docker Compose. Stay tuned, and until then, bon voyage, code-voyagers!