Installing Ubuntu and ROS Noetic on Raspberry Pi 4: A Step-by-Step Guide

From Setup to Teleop Twist

Protonest IoT
4 min readJul 6, 2023
Installing Ubuntu Server 20.04 and ROS Noetic on Raspberry Pi 4: From Setup to Teleop Twist

In this tutorial, I’ll cover the process of installing Ubuntu Server 20.04 on a Raspberry Pi 4, logging in via SSH, installing ROS Noetic, and controlling ROS via keyboard inputs using Teleop Twist.

Before we start, ensure that you have,

  1. Raspberry Pi 4 Amazon (Buy the complete package)
  2. A microSD card of at least 16GB
  3. A computer with an internet connection
  4. SSH clients such as PuTTY for Windows or the Terminal for macOS/Linux
  5. Monitor with HDMI input
  6. Keyboard and mouse
  7. HDMI to Micro HDMI cable (for connecting Raspberry Pi 4 to your monitor)
  8. Power supply compatible with Raspberry Pi 4

Installing Ubuntu Server 20.04 on Raspberry Pi 4

Step 1: Download and install Raspberry Pi Imager from the official Raspberry Pi website. Insert your microSD card into your computer.

Step 2: Open the Raspberry Pi Imager, select “Ubuntu Server 20.04” from the list of available operating systems, select your microSD card, and click on “Write”.

Step 3: Before safely ejecting the microSD card, we need to add our Wi-Fi credentials to the network-config file to allow our Raspberry Pi to connect to the internet automatically.

Step 4: Locate the network-config file in the 'system-boot' partition of your microSD card.

Step 5: Open the network-config file with a text editor, you will see a section for Wi-Fi configuration that looks like this:

Replace "yourssid" with the SSID (name) of your Wi-Fi network, and replace "yourpassword" with the password of your Wi-Fi network. Ensure that the quotation marks are retained.

Step 6: Safely eject the microSD card and insert it into your Raspberry Pi 4. Connect your Raspberry Pi 4 to power, a monitor, mouse, and keyboard.

Step 7: Ubuntu Server 20.04 will boot up. Login using the default username “ubuntu” and password “ubuntu”.

Finding the IP Address and Connecting via SSH

Step 1: After logging in, reset the password when prompted. Then, find the IP address of the Raspberry Pi 4 by typing ip an into the terminal.(Note it down)

Running “Ip a” command to find the IP address

Step 2: Now, from your computer, open your SSH client. Type ssh ubuntu@<ip> where <ip> is the IP address you obtained in the previous step.

Step 3: When prompted, type the password. Now you are remotely connected to your Raspberry Pi server.

Installing ROS Noetic

Step 1: Start by adding the ROS repository to your sources list.

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

Step 2: Add the ROS key

sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

Step 3: Update the package list

sudo apt update

If you encounter any issues, run the following command,

sudo dpkg --configure -a

Step 4: Install ROS Noetic

sudo apt install ros-noetic-ros-base

Step 5: Set up the environment for ROS

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

Step 6: Install necessary ROS dependencies

sudoapt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential
sudo rosdep init
rosdep update

Creating a Workspace for ROS

Step 1: In your home directory, create a workspace for ROS

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws

Step 2: Initialize the workspace

catkin_make

Step 3: Source your new setup.bash file

source devel/setup.bash

You can verify the workspace by echoing $ROS_PACKAGE_PATH. It should display something like /home/youruser/catkin_ws/src:/opt/ros/noetic/share.

Running Teleop Twist

Step 1: Start the ROS core. In a new terminal, type

roscore

Step 2: Now we will run Teleop Twist. Ensure that you are in the workspace directory

cd ~/catkin_ws

Step 3: Run the Teleop Twist keyboard node

rosrun teleop_twist_keyboard teleop_twist_keyboard.py

Step 4: In another terminal (ensure that you’re in the same workspace), echo the cmd_vel topic

rostopic echo /cmd_vel

This should display the messages published by the Teleop Twist node.

Teleop Twist Results

That’s it! Now you have successfully installed Ubuntu Server 20.04 on a Raspberry Pi 4, set up SSH, installed ROS Noetic, and tested it with Teleop Twist. Happy coding!

I hope this guide was helpful for you in setting up your Raspberry Pi 4 with Ubuntu and ROS Noetic! Please feel free to share your thoughts, ask questions, or provide feedback in the comments section below. Your input helps us improve and continue to provide quality guides. Thanks for reading!

References

  1. noetic/Installation/Ubuntu — ROS Wiki
  2. Ubuntu Server Wi-Fi Setup on Raspberry Pi (Fix it now) — YouTube
  3. #9 How to ROS : The Easy Way ! | Part 2: Installing ROS on a Raspberry Pi 4! | #ROS — YouTube

If you enjoyed this article and would like to show some support, consider buying me a coffee on Ko-Fi.

Your support not only helps me keep creating content like this but also fuels me! ☕️📚

Thank you for being an amazing reader!

Here’s my Ko-Fi link: https://ko-fi.com/udarakumarasena

--

--

Protonest IoT
Protonest IoT

Written by Protonest IoT

We make your IoT ideas a reality

No responses yet