rosdep init:作用是从服务器下载一个更新列表,
/etc/ros/rosdep/sources.list.d/20-default.list
其内容有:
# os-specific listings first
yaml https://raw.github.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx
# generic
yaml https://raw.github.com/ros/rosdistro/master/rosdep/base.yaml
yaml https://raw.github.com/ros/rosdistro/master/rosdep/python.yaml
yaml https://raw.github.com/ros/rosdistro/master/rosdep/ruby.yaml
gbpdistro https://raw.github.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
其中,raw.github.com 也可为raw.githubusercontent.com,两者都能成功。
ros安装成功后,当进行到rosdep init时,会出现
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.
此时手动创建一个
/etc/ros/rosdep/sources.list.d/20-default.list
文件即可
再进行rosdep update时一般还会出错
此时可能报以下错误
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit http://github.com/ros/rosdistro/raw/master/rosdep/osx-homebrew.yaml
ERROR: unable to process source [http://github.com/ros/rosdistro/raw/master/rosdep/base.yaml]:
<urlopen error _ssl.c:489: The handshake operation timed out> (http://github.com/ros/rosdistro/raw/master/rosdep/base.yaml)
ERROR: error loading sources list:
The read operation timed out
第一步:修改hosts文件:
sudo gedit /etc/hosts
在hosts中添加以下内容并保存,在执行完后继续rosdep update
199.232.28.133 raw.githubusercontent.com
151.101.228.133 raw.github.com
或者
# 199.232.28.133 raw.githubusercontent.com
# 151.101.228.133 raw.github.com
# 151.101.84.133 raw.githubusercontent.com
# 151.101.76.133 raw.githubusercontent.com
# 185.199.108.133 raw.githubusercontent.com
151.101.84.133 raw.githubusercontent.com
raw.githubusercontent.com 中有好几个地址,都可以试一下,是在不同地区的镜像ip,或者也可以去域名解析网站查询 一下最近 的ip地址
http://whoissoft.com/
第二步:更新20-default-list内容:
# os-specific listings first
# yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx
yaml https://dzjoke.gitee.io/rosdep/osx-homebrew.yaml osx
# generic
# yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
yaml https://dzjoke.gitee.io/base.yaml
# yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
yaml https://dzjoke.gitee.io/rosdep/python.yaml
# yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
yaml https://dzjoke.gitee.io/rosdep/ruby.yaml
gbpdistro https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml fuerte
# gbpdistro https://dzjoke.gitee.io/rosdep/fuerte.yaml fuerte
# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
https://dzjoke.gitee.io/rosdep/ 为本人存放相关文件的地址,可打开浏览器直接下载,避免从官网直接下载
第三步,增大下载文件延时:
网络不好,连接手机网络热点或者多试几次,如果不行,修改网络延迟时间:
更改 /usr/lib/python2.7/dist-packages/rosdep2/下的三个文件sources_list.py、gbpdistro_support.py、rep3.py
中的DOWNLOAD_TIMEOUT = 15.0值,改大一点就可以了(改成60.0)。
操作如下
sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/gbpdistro_support.py
然后搜索:/DOWNLOAD_TIMEOUT 搜索到这一行,修改过后保存退出就行了。
这个修改过后只是成功的几率会高很多,后面执行命令的时候发现卡住了就Ctrl + C重来多执行几次。
第四步,本地化targets.yaml
前三步,还是可能卡在
gbpdistro https://raw.github.com/ros/rosdistro/master/releases/fuerte.yaml fuerte
将其本地化,首先将
https://dzjoke.gitee.io/rosdep/targets.yaml
以及
https://dzjoke.gitee.io/rosdep/fuerte.yaml
内容拷贝到本地—在home/rosdep (即在home 文件夹下新建一个rosdep文件夹)下,新建两个文件targets.yaml和fuerte.yaml,将内容复制进去。
然后修改rep3.py内容:
sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/rep3.py
找到
if targets_url is None:
targets_url = REP3_TARGETS_URL
try:
f = urlopen(targets_url, timeout=DOWNLOAD_TIMEOUT)
text = f.read()
f.close()
targets_data = yaml.safe_load(text)
将
f = urlopen(targets_url, timeout=DOWNLOAD_TIMEOUT)
改为刚才对应的本地文件路径
f=open('/home/dzjoke/rosdep/targets.yaml')
同样,打开 gbpdistro_support.py,即
sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/gbpdistro_support.py
找到
targets_data = download_targets_data(targets_url=targets_url)
try:
f = urlopen(gbpdistro_url, timeout=DOWNLOAD_TIMEOUT)
text = f.read()
f.close()
gbpdistro_data = yaml.safe_load(text)
将
f = urlopen(gbpdistro_url, timeout=DOWNLOAD_TIMEOUT)
改为刚才对应的本地文件路径
f=open('/home/dzjoke/rosdep/fuerte.yaml')
退出保存。
第五步,本地化index-v4.yaml
错误信息:
Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
ERROR: error loading sources list:
<urlopen error <urlopen error timed out> (https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml)>
首先下载相关文件到本地:
https://github.com/ros/rosdistro
修改文件,
sudo gedit /usr/lib/python2.7/dist-packages/rosdistro/__init__.py
找到如下字段
DEFAULT_INDEX_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml'
修改为:
DEFAULT_INDEX_URL ='file:/home/dzjoke/Downloads/rosdistro/index-v4.yaml'
再执行 rosdep update即可成功。
参考网址:
https://www.cnblogs.com/zxzmnh/p/11758103.html
https://www.guyuehome.com/12640
https://blog.csdn.net/Bing_Lee/article/details/114557039