大家在使用ROS时都需要执行sudo rosdep init 方法和rosdep update方法。但是在执行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.
问题就是代理的事。 解决方法有两个:
方法一
第一个就是使用代理,我们可以参考“https://gitee.com/ncnynl/rosdep/tree/master”写的方法。
1.更新rosdep相关文件,增加代理地址
rm rosdep_update.sh ; wget https://gitee.com/ncnynl/rosdep/raw/master/rosdep_update.sh ; sudo chmod +x ./rosdep_update.sh; sudo ./rosdep_update.sh
完成之后,运行rosdep update即不会出现错误提示 脚本只能运行一次,多次运行,会提示重复运行信息
2.恢复rosdep相关文件,去掉代理地址
rm rosdep_recover.sh ; wget https://gitee.com/ncnynl/rosdep/raw/master/rosdep_recover.sh ; sudo chmod +x ./rosdep_recover.sh; sudo ./rosdep_recover.sh
但是这个方法并不能保证永远有用,如果哪天这个代理不好使了,还是有问题。
方法二
去把相关文件到github上下载到本地,让init和update读取本地已经下载的文件就可以了。所以我们需要首先把这个“https://github.com/ros/rosdistro.git”下载下来,解压在我们的home目录下。如下图:
git clone https://github.com/ros/rosdistro.git
 解压后可以把名字修改成rosdistro。之后只要找到执行的py文件修改网络地址“https://raw.githubusercontent.com”为本地的就可以了。
我们需要修改4个文件分别为:
1,20-default.list文件
解压到home目录命名为rosdistro,修改rosdistro/rosdep/source.list.d/下的文件20-default.list将这个文件中指向raw.githubusercontent.com的url地址全部修改为指向本地文件的地址.(我的文件名是home,这个改成你自己的文件名xxx,其他的不要变,直接复制就可以。
yaml file:///home/home/rosdistro/rosdep/osx-homebrew.yaml osx
yaml file:///home/home/rosdistro/rosdep/base.yaml
yaml file:///home/home/rosdistro/rosdep/python.yaml
yaml file:///home/home/rosdistro/rosdep/ruby.yaml

2,sources_list.py文件
在计算机目录下/usr/lib/python2.7/dist-packages/rosdep2或者/usr/local/lib/python3.6/dist-packages/rosdep2该文件夹下面的sources_list.py修改默认url(我的文件名是home,这个改成你自己的文件名xxx,其他的不要变,直接复制就可以。这个地址取决于你电脑里安装的默认python版本。 如果是20.04版本的ubuntu安装的是noetic版本的ros的话,目录是在/usr/lib/python3/dist-packages/中。
DEFAULT_SOURCES_LIST_URL = 'file:///home/home/rosdistro/rosdep/sources.list.d/20-default.list'
DOWNLOAD_TIMEOUT = 15.0
 
3,rep3.py
还是在这个目录下操作。
from .core import DownloadFailure
from .rosdistrohelper import PreRep137Warning
REP3_TARGETS_URL = 'file:///home/home/rosdistro/releases/targets.yaml'
DOWNLOAD_TIMEOUT = 15.0
 
4,gbpdistro_support.py
还是在这个目录下操作。
try:
unicode
except NameError:
basestring = unicode = str
FUERTE_GBPDISTRO_URL = 'file:///home/home/rosdistro/' \
'releases/fuerte.yaml'
DOWNLOAD_TIMEOUT = 15.0
 
5,init.py
在计算机 目录下修改/usr/lib/python2.7/dist-packages/rosdistro/或者/usr/local/lib/python3.6/dist-packages/该文件夹下面的__init__.py修改默认url(我的文件名是home,这个改成你自己的文件名xxx,其他的不要变,直接复制就可以。 如果是20.04版本的ubuntu安装的是noetic版本的ros的话,目录是在/usr/lib/python3/dist-packages/中。
__version__ = '0.8.3'
DEFAULT_INDEX_URL = 'file:///home/home/rosdistro/index-v4.yaml'
 
验证
修改完以上文件后执行sudo rosdep init会创建出这个/etc/ros/rosdep/sources.list.d/20-default.list文件。检查看看是不是读取的本地文件。没有问题就可以执行rosdep update。  执行rosdep update,结果如下图。
rosdep update
 这样就完成了。这个方法可以保证一直好用。推荐大家使用。
|