ROS2 Foxy Installation With ROS1

Install Foxy ROS2 when ROS1 is already installed

Featured image

Video Tutorial

Installation

Official Documentation can be found here: Link

Run the following commands in your terminal:

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

apt-cache policy | grep universe

If following line not there

500 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 Packages
    release v=20.04,o=Ubuntu,a=focal,n=focal,l=Ubuntu,c=universe,b=amd64

then enter:

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

Add ROS2 apt Repo

sudo apt update && sudo apt install curl gnupg2 lsb-release
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 $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
sudo apt update
sudo apt upgrade

Install ROS2 - Full

sudo apt install ros-foxy-desktop

Install ROS2 - Base

sudo apt install ros-foxy-base

Environment Setup

nano ~/.bashrc

At the end of bashrc file update the source commands as following:

alias noetic="source /opt/ros/noetic/setup.bash;echo 'Noetic is Active'"
alias foxy="source /opt/ros/foxy/setup.bash;echo 'Foxy is Active'"

CTRL + O : For Saving

CTRL + X : For Exit

Now in the terminal when you want to work on foxy enter:

foxy

Now in the terminal when you want to work on noetic enter:

noetic

ROS_DOMAIN_ID

The way DDS is implemented is that you will be having shared network on which you can divide system communication based on domain id, this is achieved by setting flag.

If you want to completely isolate your system follow the steps mentioned in the video.

ROS2 Domain ID Youtube Video

export ROS_DOMAIN_ID=2 # 0 is Default

Note: This can be added in .bashrc file as shown in the above video

Detailed Documentation: Link

FAQ

Foxy vs Galactic

So there is a lot of confusion on using Foxy and Galactic as they both support Ubuntu 20.

For this you can refer this article : Link