Posted underEducationROS2

Installing ROS and ROS2 on Linux Machines

Installing the Robotic Operating System can be an arduous task and numbers of hours just to get it set up and configured. This article walks through how to install ROS and ROS2.

Jeremy Liu
Jeremy Liu

Introducing ROS

If you’re just starting off, entering robotics world for the first time—your experience is probably similar to the first time when you tried to learn how to swim. Everything is against you—the water, the current, and even the physics. It’s absolutely overwhelming, and that same feeling applies to robotics as well. It sometimes just doesn’t make sense that your servo needs loads of steps completed out of multi-hundred page manual to make it turn it exactly ninety degrees, it doesn’t make sense when the overcurrent alert goes off when your voltmeter shows nothing is wrong, and it doesn’t make sense on how to even go about processing the gigabytes of random bits your LiDaR sensor is spitting out a second. It physically just feels like you’re fighting for your life, simply trying to stay afloat in a complex ecosystem.

Yet, out of all those struggles you might have been experiencing so far, you’ve probably discovered ROS—the robotics operating system. But, for some reason, even a software meant to simplify your overall robotics experience is just as complex to install.

If you’re just starting off or is unfamiliar with what ROS is, ROS is basically a group of software libraries and tools that come together to form an “operating system” or “wrapper” that wraps all the code that will exist on your robot. You can read through this article to see the evolution from ROS to ROS2. By laying slightly above where all the code you will create, it effectively enables your code to go much further, providing numerous tools to communicate between sensors, process data types, and preform many essential tasks like Localization, Path Planning, or Odometry.

Getting Started

Before we jump right into the installation process, make sure that, on the device you want to execute your code on for your robot, that you have Linux installed. While it is possible to install ROS on Windows and MacOS, the installation instructions are extremely untested and outdated and rarely work. If you are, however, interested in attempting that, please refer to the the specific ROS distros installation guide.

What ROS version and distribution do I use?

Another confusion a lot of people face when entering the ROS ecosystem is the fact that there exists so many different distributions across both ROS and ROS2. It’s a bit confusing as to which you should pick so I’ll cover a bit of the pros and cons here. Overall, theres a lot of technical changes that make ROS2 superior to ROS, both in ease of learning and package management. It’s a lot more modern, and is receiving a lot of newer support for things like cloud computing and prebuilt nodes—some of which are offered on Shade Registry. However, if you plan on using large packages like RTABMAP or ORBSLAM3, these packages are extremely large and have been extensively fleshed out for ROS, you’re out of luck. It’s much better staying in ROS for the support vs transitioning to ROS2 at this moment, where it is almost impossible to get these packages to even compile.

Next, what about distribution? It doesn’t actually matter too much! This is because each ubuntu version can only install a specific distribution (or 2 in some cases). However, the differences are extremely minimal in between distributions and support cross distribution is extremely powerful as well. Here is a table showing what ROS and ROS2 versions are available on specific ubuntu versions.

Ubuntu VersionROSROS2
12.04Fruerte, Groovy, Hydro
16.04KineticArdent, Bouncy
18.04MelodicCrystal, Dashing, Eloquent
20.04Noetic, RollingFoxy, Galactic
22.04Humble, Rolling

strikethrough means it is deprecated, rolling means the current development cycle before the next major release.

Installing ROS

Check Locale

Make sure you have a locale which supports UTF-8. If you are in a minimal environment (i.e. a Docker container), the locale may be something minimal like POSIX instead. To check, simply run

locale # to check if you have the proper locale

# if not, run
sudo apt update && sudo apt install locales
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8

Basic Tools

Make sure you have installed the basic tools to begin your installation

sudo apt update
sudo apt install software-properties-common curl gnupg lsb-release
sudo add-apt-repository universe

Set up source and keys

sudo curl -sSL <> -o /usr/share/keyrings/ros-archive-keyring.gpg

# run this for ROS
sudo sh -c 'echo "deb <> $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

# run this for ROS2
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] <> $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null

Installing ROS(2)

sudo apt update # update source list
sudo apt upgrade # helps clear up dependencies issues

export ROS_DISTRO=foxy # modify this to any distro you wish to install
sudo apt install ros-${ROS_DISTRO}-desktop

# if you are constrained by storage, you can also install the base
sudo apt install ros-${ROS_DISTRO}-desktop

# then install additional packages manually or using rosdep in your workspace
sudo apt install ros-${ROS_DISTRO}-rviz2 # replace rviz2 with your desired package
rosdep install --from-paths src --ignore-src -r -y

Getting Started

Then finally, the last step is to simply run source /opt/ros/${ROS_DISTRO}/setup.bash and you’ll be able to run the command ros or ros2 and continue from there!


Cover Image for Robotic Security – a Brief Intro

Robotic Security – a Brief Intro

Each year, over 430,000 new industrial robots arrive in the market. But those are far from the on

Colin Wang
Colin Wang
Cover Image for ASICS – What are they, and are they the future?

ASICS – What are they, and are they the future?

In the era of rapid technological transformation, Application-Specific Integrated Circuits (ASICs

Marcelina Krowinska
Marcelina Krowinska