在 ubuntu 20.04 LTS 上安装 ROS2 执行 rosdep update 命令时出现的问题的解决办法
1、sudo rosdep init
在执行 sudo rosdep init
命令的时候,会出现如下错误:
-
Certificate verification failed: The certificate is NOT trusted.
解决办法:安装 ca-certificates
apt install ca-certificates
-
无法访问 raw.githubusercontent.com
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.
该命令的作用是从目标网址中下载 20-default.list
文件。
第一种方法,使用手机热点,重新输入命令:sudo rosdep init
第二种方法:
- 建立一个文件夹
/etc/ros/rosdep/sources.list.d
- 然后写入文件
sudo gedit 20-default.list
将下面的内容复制到创建的文件中:
# 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
保存完毕,执行 rosdep update
命令。
具体的可以参考 古月居 的文章。
2、rosdep update
由于近期国内 Github Raw
的可用 IP
越来越少,通过修改 hosts
文件解决 rosdep update
超时问题的方法已经不太好用,本文通过修改 rosdep
源码中下载资源的函数来解决这一问题。
网站 https://ghproxy.com/
支持 github
的资源代理,非常好用,我们将用此代理加速rosdep
对 Github Raw
的访问,进而解决 rosdep update
超时问题。
首先定位 rosdep
资源下载函数。从报错信息中得知,该函数名为download_rosdep_data
,位于 /usr/lib/python3/dist-packages/rosdep2/sources_list.py
。我们修改这一函数,添加:
url = "https://ghproxy.com/" + url
应用 ghproxy
的代理服务。
用同样的方法修改 /usr/lib/python3/dist-packages/rosdistro/__init__.py
里面的DEFAULT_INDEX_URL
。即将 DEFAULT_INDEX_URL
进行如下替换:
DEFAULT_INDEX_URL = 'https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml'
![](https://i-blog.csdnimg.cn/blog_migrate/55b24eb8d9ad2a3d3ef99c9779ad187d.png)
除此处外,下述文件中也含有 github
地址,分别是:
/usr/lib/python3/dist-packages/rosdep2/gbpdistro_support.py # 36行
/usr/lib/python3/dist-packages/rosdep2/sources_list.py # 72行
/usr/lib/python3/dist-packages/rosdep2/rep3.py # 39行
/usr/lib/python3/dist-packages/rosdistro/manifest_provider/github.py # 68、119行
/usr/lib/python3/dist-packages/rosdep2/gbpdistro_support.py
# 204 行下面添加 gbpdistro_url = "https://ghproxy.com/" + gbpdistro_url
- /usr/lib/python3/dist-packages/rosdep2/sources_list.py
![](https://i-blog.csdnimg.cn/blog_migrate/36c6e89e09a960433000247d510299e6.png)
- /usr/lib/python3/dist-packages/rosdep2/rep3.py
![](https://i-blog.csdnimg.cn/blog_migrate/98f0f498f41375a2ec3739fcbc7b8292.png)
- /usr/lib/python3/dist-packages/rosdistro/manifest_provider/github.py
![](https://i-blog.csdnimg.cn/blog_migrate/c030b51936581db9c58b8c171e408a91.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f055ff169ca3786b40b3cb0d0eed80f7.png)
- /usr/lib/python3/dist-packages/rosdep2/gbpdistro_support.py
![](https://i-blog.csdnimg.cn/blog_migrate/2d93bda1fc9963ee4c5fc61b8b5f7fc7.png)
![](https://i-blog.csdnimg.cn/blog_migrate/4c1eb237d16841f76a2da7465b35206e.png)
均可通过在地址前添加 https://ghproxy.com/
前缀来应用代理服务。
完成以上更改之后,再次尝试执行 rosdep update
。
第二种方法:
修改 /etc/ros/rosdep/sources.list.d/20-default.list
文件:
在所有 https://raw.githubusercontent.com
前加上 https://ghproxy.com/
,如下所示:
# os-specific listings first
yaml https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx
# generic
yaml https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
yaml https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
yaml https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
gbpdistro https://ghproxy.com/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
修改 /usr/lib/python3/dist-packages/rosdistro/__init__.py
文件:
在 DEFAULT_INDEX_URL
前面加上 https://ghproxy.com/
,修改完成如下所示:
DEFAULT_INDEX_URL = 'https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml'