To install and set up ROS2 we will follow this ROS2 Documentation:

https://docs.ros.org/en/humble/index.html

After clicking the link this page must show up:

image.png

On the left side of the screen click on installation and choose Ubuntu (deb packages) as shown below:

image.png

This page must show up:

image.png

Scroll down to the Set locale section and start following the steps in the documentation. For Reference, I am going to include the commands and show how to setup ROS2 Environment.

Follow the below commands to install ROS2 and Gazebo:

locale  # check for UTF-8

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

locale  # verify settings

sudo apt install software-properties-common

sudo add-apt-repository universe

sudo apt update && sudo apt install curl -y

sudo curl -sSL <https://raw.githubusercontent.com/ros/rosdistro/master/ros.key> -o /usr/share/keyrings/ros-archive-keyring.gpg

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

sudo apt update

sudo apt upgrade

sudo apt install ros-humble-desktop

sudo apt install ros-humble-gazebo*

sudo apt install gazebo

Follow the below commands to setup the environment for ROS2 and Gazebo:

gedit ~/.bashrc