Ubuntu下安装ROS:sudo rosdep init与rosdep update出错解决办法

背景:

ubuntu上安装ROS,不管是在ubuntu16.04上装kinetic,还是在18.04上装melodic,安装完毕后,进行初始化时,反复失败,试遍了网上公开的方法,都没能解决。最后,通过本地创建配置文件的方法,终于搞定。

1.执行 sudo rosdep init 失败

反复尝试一下,一般情况下反复个几次,init这步就可以成功。

如果反复不成功,根据提示错误,可以先参考下面链接提供的方法尝试一下

https://www.cnblogs.com/xuhaoforwards/p/9399744.html

上面的操作都不成功,可以参考下面。

sudo rosdep init 这个操作最主要的工作就是从https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list,下载文件20-default.list,并把它放到/etc/ros/rosdep/sources.list.d/这个目录下。

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

操作起来就是:直接创建目录/etc/ros/rosdep/sources.list.d/,并在此目录下创建20-default.list这个文件。创建这个文件需要sudo权限。

2. 执行rosdep update失败

这步的操作失败原因是从raw.githubusercontent.com/下载文件失败,主要是防火墙限制了对这个网站的访问,能科学上网的同学就不用往下看了。

(1)可以先参考下面链接的方法,将python脚本的超时时间写长一点比如120s,然后反复尝试。但是单纯使用这个方法,对我没用。

https://www.cnblogs.com/zxzmnh/p/11758103.html

(2)如果单纯上面的操作对你也没用,请继续往下看。分析了前面链接提到的sources_list.py、gbpdistro_support.py、rep3.py几个脚本,发现主要在打开20-default.list里的链接时失败,也就是无法下载20-default.list列举的几个配置文件。有了这个发现,下面的事情就是,把这些文件下载到本地,然后修改20-default.list脚本文件就可以了。

具体操作如下:

a.将20-default.list中的链接在浏览器中打开,然后创建一个同名文件,最好连目录结构一起建好,这样后面改脚本比较容易。我是直接建在了/etc/ros/建了相应的目录。

也可以从下面云盘中直接下载,解压到/etc/ros目录下。需要超级权限。

链接: https://pan.baidu.com/s/19OCXIUgZ1RNHV33noc1auw

提取码: tnn9

b.修改20-default.list脚本文件,需要超级权限。可以跟前面的脚本内容做下对比。

# os-specific listings first
#yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx
yaml file:///etc/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
 
yaml file:///etc/ros/rosdistro/master/rosdep/base.yaml
yaml file:///etc/ros/rosdistro/master/rosdep/python.yaml
yaml file:///etc/ros/rosdistro/master/rosdep/ruby.yaml
gbpdistro file:///etc/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。

在更新过程中,还有部分配置信息会从raw.githubusercontent.com上下载,但是反复几次,基本上就可以成功了。

(3)经过上面两步,还是失败,请继续往下看。

sudo 打开/usr/lib/python2.7/dist-packages/rosdistro/init.py这个文件,按照下面的代码进行修改。

# index information
 
#DEFAULT_INDEX_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml'
DEFAULT_INDEX_URL = 'file:///etc/ros/rosdistro/master/index-v4.yaml'

保存后,执行rosdep update。如果一次不成功,再执行个一两次,应该就会出现下面成功完成的这些打印。

reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit file:///etc/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit file:///etc/ros/rosdistro/master/rosdep/base.yaml
Hit file:///etc/ros/rosdistro/master/rosdep/python.yaml
Hit file:///etc/ros/rosdistro/master/rosdep/ruby.yaml
Hit file:///etc/ros/rosdistro/master/releases/fuerte.yaml
Query rosdistro index file:///etc/ros/rosdistro/master/index-v4.yaml
Skip end-of-life distro "ardent"
Skip end-of-life distro "bouncy"
Skip end-of-life distro "crystal"
Add distro "dashing"
Add distro "eloquent"
Add distro "foxy"
Skip end-of-life distro "groovy"
Skip end-of-life distro "hydro"
Skip end-of-life distro "indigo"
Skip end-of-life distro "jade"
Add distro "kinetic"
Skip end-of-life distro "lunar"
Add distro "melodic"
Add distro "noetic"
updated cache in /home/xxxx/.ros/rosdep/sources.cache
 

————————————————
版权声明:本文为CSDN博主「super_sean」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/super_sean/article/details/105433250

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值