ROS2 Installation

Warning

Care should be taken when installing ROS so that it matches with your CPU’s architecture (i.e. armhf, amd64, arm6, etc.)

Note

All the ROS related software should be installed/run on remote PC/Raspberry Pi/Nvidia board, nothing needed to be installed on robots control board if bought with the ROS pkg.

PC Setup

ROS2 Foxy installation requires Ubuntu 20.04.

  1. Download Ubuntu 20.04

  2. Follow the Ubuntu 20.04 installation guide

ROS Foxy Installation

The ROS driver provided can be run either on a remote PC or on board robot computer. Typically, the on-board computer already has a pre-installed ROS distribution, so the instructions below will be applicable to a remote computer. You may execute the following commands to install ROS Foxy, or you can simply follow the instructions from the ROS Wiki.

_images/foxy.png

Set Locale

Ensure that your system supports UTF-8 locale. Verify your locale settings with the following command:

locale

If necessary, set up a UTF-8 locale:

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

Setup Sources

Add the ROS2 apt repository to your system. First, make sure that the Ubuntu Universe repository is enabled:

sudo apt install software-properties-common
sudo add-apt-repository universe

Next, add the ROS2 GPG key with apt:

sudo apt update && sudo apt install curl -y
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc -o /usr/share/keyrings/ros-archive-keyring.gpg

Then, add the repository to your sources list:

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

Install ROS2 Packages

Update your apt repository caches after setting up the repositories:

sudo apt update

Ensure your system is up to date before installing new packages:

sudo apt upgrade

ROS-Base Install (Bare Bones)

Install communication libraries, message packages, and command line tools without GUI tools:

sudo apt install ros-foxy-ros-base python3-argcomplete

Development Tools

Install compilers and other tools to build ROS packages:

sudo apt install ros-dev-tools

Environment Setup

Source the setup script to set up your environment:

# Replace ".bash" with your shell if you're not using bash
# Possible values are: setup.bash, setup.sh, setup.zsh
source /opt/ros/foxy/setup.bash

Try Some Examples

If you installed Desktop Install (Recommended) above, try some examples:

Run a C++ talker in one terminal:

source /opt/ros/foxy/setup.bash
ros2 run demo_nodes_cpp talker

Run a Python listener in another terminal:

source /opt/ros/foxy/setup.bash
ros2 run demo_nodes_py listener

This verifies both the C++ and Python APIs are working properly.

Next Steps After Installing

Continue with the tutorials and demos to configure your environment, create your own workspace and packages, and learn ROS2 core concepts.

Using the ROS1 Bridge

Connect topics from ROS1 to ROS2 and vice-versa using the ROS1 bridge. See the dedicated documentation on how to build and use the ROS1 bridge.

Additional RMW Implementations (Optional)

ROS2 uses Fast-RTPS as the default middleware (RMW), but you can replace it at runtime. See the guide on how to work with multiple RMWs.

Troubleshooting

Refer to the troubleshooting techniques found here if you encounter any issues.

Uninstall

If you need to uninstall ROS2 or switch to a source-based install once you have already installed from binaries, run the following command:

sudo apt remove ~nros-foxy-* && sudo apt autoremove

You may also want to remove the repository:

sudo rm /etc/apt/sources.list.d/ros2.list
sudo apt update
sudo apt autoremove
# Consider upgrading for packages previously shadowed.
sudo apt upgrade