Install ROS and error resolution on Ubuntu 18.04 system

Introduction

I encountered a lot of problems during installation and searched a lot of schemes. This is just a summary, and I don't remember the source. Welcome to point out the source.

Set ROS Software Source

`sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'`

(Domestic mirror sources are available to improve software download and installation progress)

  1. Ubuntu's official source server is slow to access in Europe, so it is necessary to change the software source to the domestic source. There are many sources in China. We choose Ubuntu sources from Aliyun and Tsinghua University:

    Ali Yunyuan

    deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

    Source of Tsinghua University

    deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
    deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/bionic-security main restricted universe multiverse
    deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
    deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse

  2. Sources for Ubuntu are stored in / etc/apt/directory sources. In the list file, we make a backup before modifying, and execute the following commands in the terminal:

    sudo cp /etc/apt/sources.list /etc/apt/sources.list.bcakup
    
  3. Then execute the following command to open sources.list file, empty the contents, copy the above Aliyun and Tsinghua University's Ubuntu source, save and exit.

    sudo gedit /etc/apt/sources.list
    
  4. Next, execute the following command on the terminal to update the software list and detect the software that can be updated:

    sudo apt-get update
    
  5. Finally, execute the following commands on the terminal to update the software:

    sudo apt-get upgrade
    

Add Public Key

`sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654`

(Refer to if failed** Problem 1 and Solutions**)

  • Install ROS:

    • Update package:

      sudo apt-get update

    • Install the complete ROS Kinetic package:

      sudo apt-get install ros-melodic-desktop-full

    • Initialize rosdep:

      sudo rosdep init

      (Refer to if failed** Problem 2 and Solutions**)

      rosdep update

      (Refer to if failed** Question 3 and Solutions**)

    • Configure the ROS environment:

      echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc

      source ~/.bashrc

    • Installation Dependency - The rosinstall tool, which can be used to download and install Feature Pack programs from ROS:

      sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential

  • Test whether ROS was installed successfully:

    roscore

    If the version, node, etc. of the ROS is installed, then the ROS installation is successful. If the ROS installation fails, follow the steps above to re-install.

Problems and Solutions

Question 1 and Solutions:

  • **Problem: ** Public key addition failed
  • **Scheme: **Suo apt-key adv --keyserver' hkp://keyserver.ubuntu.com:80 '--Recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 Public key server replaced with hkp://pgp.mit.edu:80

Question 2 and Solutions:

  • Problem: Initialization of rosdep failed

  • Scheme:

    #Open hosts file (with gedit/vi/vim)
    sudo gedit /etc/hosts
    #Add the following line to the end of the file:
    199.232.96.133 raw.githubusercontent.com
    #Exit after saving and try to initialize rosdep
    

    Note: The IP address above corresponds to the following web address, which may change. You can query the IP address of the web address below:

    www.ipaddress.com

Question 3 and Solutions:

  • Problem: cannot download default sources list, unable to access github's user data server properly due to wall

  • Scheme:

    Replace rosdep's network map address with a local address:
    Download the rosdistro folder, either from the ROS open source package on github or Resources I Provide

Modify the following contents in the downloaded folder: (Path Note Replace with your local)

  • First file:
cd home/username/ROS-DAQ_V1.0/doc/03 Development Documentation/rosdistro/rosdep/sources.list.d/
sudo gedit 20-default.list 

Raw inside. Githubusercontent. Com replaced with local mapped address:

# os-specific listings first
yaml file:///home/username/ROS-DAQ_V1.0/doc/03 Development Document/rosdistro/rosdep/osx-homebrew.yaml osx

# generic
yaml file:///home/username/ROS-DAQ_V1.0/doc/03 Development Document/rosdistro/rosdep/base.yaml
yaml file:///home/username/ROS-DAQ_V1.0/doc/03 Development Document/rosdistro/rosdep/python.yaml
yaml file:///home/username/ROS-DAQ_V1.0/doc/03 Development Document/rosdistro/rosdep/ruby.yaml
gbpdistro file:///home/username/ROS-DAQ_V1.0/doc/03 Development Document/rosdistro/releases/fuerte.yaml fuerte

# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead

(Note that the address is the real local file address and needs to be replaced as appropriate)

  • Second file:
cd /usr/lib/python2.7/dist-packages/rosdep2/
sudo gedit gbpdistro_support.py

Same replacement

FUERTE_GBPDISTRO_URL = 'file:///home/username/ROS-DAQ_V1.0/doc/03 Development Document/rosdistro/'\
    'releases/fuerte.yaml'
  • Third file:
cd /usr/lib/python2.7/dist-packages/rosdep2/
sudo gedit rep3.py

Same replacement

REP3_TARGETS_URL = 'file:///home/username/ROS-DAQ_V1.0/doc/03 Development Document/rosdistro/releases/targets.yaml'
  • Fourth file:
cd /usr/lib/python2.7/dist-packages/rosdistro/
sudo gedit __init__.py

Same replacement

DEFAULT_INDEX_URL = 'file:///home/username/ROS-DAQ_V1.0/doc/03 Development Document/rosdistro/index-v4.yaml'
  • Open the terminal and execute the following instructions to create a root and switch to the root user
sudo su //Enter your password and switch to root
sudo mkdir -p /etc/ros/rosdep/sources.list.d   
cd /etc/ros/rosdep/sources.list.d
sudo gedit 20-default.list

Copy the following into 20-default. In list

#os-specific listings first
yaml file:///home/username/ROS-DAQ_V1.0/doc/03 Development Document/rosdistro/rosdep/osx-homebrew.yaml osx

# generic
yaml file:///home/username/ROS-DAQ_V1.0/doc/03 Development Document/rosdistro/rosdep/base.yaml
yaml file:///home/username/ROS-DAQ_V1.0/doc/03 Development Document/rosdistro/rosdep/python.yaml
yaml file:///home/username/ROS-DAQ_V1.0/doc/03 Development Document/rosdistro/rosdep/ruby.yaml
gbpdistro file:///home/username/ROS-DAQ_V1.0/doc/03 Development Document/rosdistro/releases/fuerte.yaml fuerte

#newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
  • Finally, open a new terminal:
rosdep update

Tags: Linux Ubuntu

Posted by pfdesigns on Wed, 20 Jul 2022 00:00:31 +0530