ROS installation and error solutions

Table of contents

1. Installation steps

(1) Add ROS software source

(2) Add secret key

(3) Install ROS

(4) Initialize rosdep

(5) Set environment variables

(6) Install rosinstall

2. Solutions to installation errors 

(1) Add ROS software source

(2) Add secret key

(3) Install ROS

(4) Initialize rosdep

(5) Set environment variables

(6) Install rosinstall  


        In the process of installing ROS, the author almost made mistakes at every step. The following article summarizes the solutions to the errors. The article refers to many blogs.

1. Installation steps

(1) Add 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'

(2) Add secret key

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

(3) Install ROS

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

        The ros version needs to be consistent with the Ubuntu version.
        Ubuntu18.04: melodic
        Ubuntu16.04: kinetic
        Ubuntu14.04: indigo

(4) Initialize rosdep

        sudo rosdep init
        rosdep update

(5) Set environment variables

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

(6) Install rosinstall

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

2. Solutions to installation errors 

(1) Add ROS software source

(2) Add secret key

        Issue 1: Executing: /tmp/apt-key-gpghome.xFJY0Xqqye/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
gpg: Failed to receive from public key server: Server failure

***@vmware:~$ sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

Executing: /tmp/apt-key-gpghome.xFJY0Xqqye/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
gpg: 从公钥服务器接收失败:服务器故障

        Problem 1 Solution:

        The reason for the error is that the virtual machine is not connected to the network.

        (1) Switch to mobile phone hotspot.

        (2) Open Computer Management->Services and Applications->Check whether all vMware services are turned on.

(3) Install ROS

        Issue 2: E: Unable to obtain lock /var/lib/apt/lists/lock. The lock is being held by process 5167 (apt-get)
        N: Please note that directly removing the lock file is not necessarily a suitable solution and may damage your system.
        E: Unable to lock directory /var/lib/apt/lists/

***@vmware:~$ sudo apt update
正在读取软件包列表... 完成
E: 无法获得锁 /var/lib/apt/lists/lock。锁正由进程 5167(apt-get)持有
N: 请注意,直接移除锁文件不一定是合适的解决方案,且可能损坏您的系统。
E: 无法对目录 /var/lib/apt/lists/ 加锁

         Problem 2 Solution:

        Execute command: sudo rm /var/lib/apt/lists/lock

        Issue 3: E: Unable to locate package ros-melodic-desktop-full

***@vmware:~$ sudo apt install ros-melodic-desktop-full
正在读取软件包列表... 完成
正在分析软件包的依赖关系树       
正在读取状态信息... 完成       
E: 无法定位软件包 ros-melodic-desktop-full

        Problem 3 Solution: 

        Check the Ubuntu version, version 20.04 corresponds to the noetic of ros. sudo apt install ros-noetic-desktop-full

(4) Initialize rosdep

        Question 4: Executing rosdep update, sudo: rosdep: command not found

sudo: rosdep:找不到命令

        Problem 4 Solution:

        20.04 Terminal input: sudo apt install python3-rosdep2

        18.04 terminal input: sudo apt install python-rosdep2

        Then initialize rosdep again: sudo rosdep init

        问题5: ERROR: default sources list file already exists: /etc/ros/rosdep/sources.list.d/20-default.list Please delete if you wish to re-initialize

***@vmware:~$ sudo rosdep init
ERROR: default sources list file already exists:
	/etc/ros/rosdep/sources.list.d/20-default.list
Please delete if you wish to re-initialize

        Problem 5 Solution:

        Execution: sudo rm /etc/ros/rosdep/sources.list.d/20-default.list 

        问题6: ERROR: cannot download default sources list from:
https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list
Website may be down.

***@vmware:~$ sudo rosdep init
ERROR: cannot download default sources list from:
https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list
Website may be down.

        Problem 6 Solution: 

        Website may be down appears because https://raw.githubusercontent.com/ is an external network URL and access is unstable (you can try sudo rosdep init several times)

        If it still doesn't work after several attempts, try the following method:
        1) Execute: sudo gedit /etc/hosts
         and add the following paragraph at the end of the file: 151.101.84.133 raw.githubusercontent.com
        2) Then save and exit and sudo rosdep init again. If it still doesn't work, log in. IPAdress website https://www.ipaddress.com/Enter raw.githubusercontent.com to query the real IP address:

        Replace the queried IP with 151.101.84.133 in the above code and then sudo rosdep init again will generally succeed.

        

        Question 7: <urlopen error timed out>

***@vmware:~$ rosdep update
reading in sources list data from /etc/ros/rosdep/sources.list.d
ERROR: unable to process source 
...
[https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml]:
	Failed to download target platform data for gbpdistro:
	<urlopen error timed out>
]]]

        Problem 7 Solution: 

Reference link: https://blog.csdn.net/weixin_44023934/article/details/121242176

(5) Set environment variables

        Question 8: bash: /opt/ros/melodic/setup.bash: No such file or directory

***@vmware:~$ source ~/.bashrc
bash: /opt/ros/melodic/setup.bash: 没有那个文件或目录
bash: /opt/ros/melodic/setup.bash: 没有那个文件或目录
bash: /opt/ros/melodic/setup.bash: 没有那个文件或目录
bash: /opt/ros/melodic/setup.bash: 没有那个文件或目录
bash: /opt/ros/melodic/setup.bash: 没有那个文件或目录
bash: /opt/ros/melodic/setup.bash: 没有那个文件或目录

         Problem 8 Solution: Reference article

        1) Open the virtual machine terminal and enter: gedit .bashrc

        Pop up a file and find the last line, as shown in the figure:

         2) The ros version needs to be consistent with the Ubuntu version.
        Ubuntu18.04: melodic
        Ubuntu16.04: kinetic
        Ubuntu14.04: indigo

        I changed the melodic in the file to its corresponding version, deleted all duplicates, saved it, and opened the terminal again, and it was fine.

(6) Install rosinstall  

        Question 9: The package python-rosinstall has no installation candidates

***@vmware:~$ sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential
正在读取软件包列表... 完成
正在分析软件包的依赖关系树       
正在读取状态信息... 完成       
没有可用的软件包 python-rosinstall,但是它被其它的软件包引用了。
这可能意味着这个缺失的软件包可能已被废弃,
或者只能在其他发布源中找到
然而下列软件包会取代它:
  python3-rosinstall
...
E: 软件包 python-rosinstall 没有可安装候选
E: 软件包 python-rosinstall-generator 没有可安装候选
E: 软件包 python-wstool 没有可安装候选

        Problem 9 Solution:

        According to the prompt, the version of python is wrong.

        Change the input to: sudo apt install python3-rosinstall python3-rosinstall-generator python3-wstool build-essential
 

Guess you like

Origin blog.csdn.net/qq_41921826/article/details/128417100