How to install ROS2 on ubuntu 20 ?



 Follow These commands one by one to install ROS2 on Ubuntu PC.

 

$   locale  

 
Make sure you have a locale which supports UTF-8. 
If you are in a minimal environment (such as a docker container), 
the locale may be something minimal like POSIX.
if Locale is not installed or You are getting some different output 
 you can install locale with the following commands :
$   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 
to verify the setting :
 $ locale 
For me LANG=en_IN  as I'm installing from India .
 

Setup Sources:

  
$ apt-cache policy | grep universe 
If you are getting some different output you can set it up by using following commands :
$   sudo apt install software-properties-common
$   sudo add-apt-repository universe 
 

Add the ROS 2 apt repositories to your system  :

$  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 

"It is always recommended that you ensure your system is up to date 
before installing new packages"
$  sudo apt update 
$  sudo apt upgrade
 

ROS2 Desktop Install , includes : ROS, RViz, demos, tutorials.

$  sudo apt install ros-foxy-desktop 
 
$  sudo apt install ros-foxy-ros-base 
 
$  source /opt/ros/foxy/setup.bash   
 

"Successfully installed ROS2 (ros-foxy-desktop) in your system💥"