Install ROS on Ubuntu 20.04.3
ROS is a fundamental library to bridge SLAM systems with real world vehicle applications. This article briefly explains the overall installation process, as well as proposing solutions to some common errors during installation.
Here, we install ROS Noetic Ninjemys on Ubuntu 20.04.3, the overall process is the same for older visions. Please refer to ROS Official Wiki for more details.
Some Setup Before Installation
Configure Ubuntu repositories to allow all four repository type. Under a few circumstances, it’s the system’s default setting and can be skipped.
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
Setup keys. Make sure
curlis installed, and then:
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
The most common error here is
no valid OpenPGP data found, these are some possible workarounds:
Check Internet connection, especially if you are in worldwide web restricted areas such as mainland China. Use a proxy if possible.
wgetto manually download the key and then add it. Personally, I believe it is a more robust method since this error may persist even using a proxy:
wget http://packages.ros.org/ros.key sudo apt-key add ros.key
If the previous steps completed without error, we can head straight to installing ROS, be sure to run
sudo apt update first.
After that, run
sudo apt install ros-noetic-desktop-full to perform a full install. A detailed list of installation options is available on ROS wiki mentioned above.
This is a pretty trivial step and all you need to do is wait patiently. Still, if an error appears saying something like
no packages are found, try open the following URL in your Ubuntu browser:
Or directly click here. This will activate the installation process in Ubuntu GUI.
Post-Installation Setup & Initialize
Run the following command in bash to setup environment:
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc source ~/.bashrc
And install some other dependencies:
sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential
Next and final step, initialize
sudo apt install python3-rosdep sudo rosdep init rosdep update
sudo rosdep init will commonly throw an
Website may be down error, it’s a pretty widespread issue, and these are some solutions may work:
Install CA certificate:
sudo apt-get install ca-certificates
Since this error indicates that the target website cannot be connected, it’s most likely (also sadly) still an Internet connection issue. Try to use a proxy.
If all these failed, we can generate the target file manually:
mkdir -p /etc/ros/rosdep/sources.list.d cd /etc/ros/rosdep/sources.list.d touch 20-default.list
And edit this file:
sudo nano /etc/ros/rosdep/sources.list.d/20-default.list
Paste the following content then save it:
# os-specific listings first yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx # generic yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml gbpdistro https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml fuerte # newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
Please notice that, when using this solution, skip
sudo rosdep initcommand after editing the
20-default.listfile. Directly executing
rosdep updateis sufficient.
If everything goes right, the last output will be something like:
reading in sources list data from /etc/ros/rosdep/sources.list.d Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml Hit https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml Skip end-of-life distro "ardent" Skip end-of-life distro "bouncy" Skip end-of-life distro "crystal" Skip end-of-life distro "dashing" Skip end-of-life distro "eloquent" Add distro "foxy" Add distro "galactic" Skip end-of-life distro "groovy" Skip end-of-life distro "hydro" Skip end-of-life distro "indigo" Skip end-of-life distro "jade" Skip end-of-life distro "kinetic" Skip end-of-life distro "lunar" Add distro "melodic" Add distro "noetic" Add distro "rolling" updated cache in /home/lincoln/.ros/rosdep/sources.cache
And congratulations, ROS is successfully installed.