rosdep init/update 解决方法

1 篇文章 0 订阅
1 篇文章 0 订阅

rosdep init/update 解决方法

最近在国内上github越来越难,我自己的校园网曾经还是很好使的,但是最近也上不去了,加上不想花钱在ubuntu上买代理,所以在很多需要上git的场景很头疼。包括今天写的这个ros 安装过程中出现的问题。我使用的是ubuntu 18.04系统 ros melodic
当我们在

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.

大部分解决方法是修改我们的hosts,但是现在不好使了
之后我发现了一篇宝藏文章,很少人阅读
在这里写下作者(发哥爱开源)
文章地址
https://blog.csdn.net/weixin_42584917/article/details/114448355
但是由于我第一次看作者文章时能力有限没有读懂,所以第一次没有成功,但第二次尝试时突然开窍,故在此分享,希望大家不要卡在ros安装上被劝退。



原理

raw.githubusercontent.com实际上就是github的用户数据服务器
rosdep程序下载的就是从github.com/ros/rosdistro这个repo里的yaml文件
虽然raw.githubusercontent.com服务器无法访问,但是yaml文件可以直接从git clone的repo中获得

第一步

将rosdistro clone到本地

git clone https://github.com/ros/rosdistro.git

如果卡住了,可以百度云下载
链接: https://pan.baidu.com/s/1BwAskFFs_Qd7Fp_gZX-GdQ
提取码: as59
解压到home下,我的用户名是tft,那么这个文件夹的地址就是

/home/tft/rosdistro

第二步

第一个文件

终端打开刚刚下载(clone)下来的rosdistro文件夹
以下的所有yourname 都改成你们自己的用户名!!!!

cd /home/yourname/rosdistro/rosdep/sources.list.d/
sudo gedit 20-default.list 

将里面所有的 raw.githubusercontent.com
替换成自己的地址,如下

# os-specific listings first
yaml file:///home/yourname/rosdistro/rosdep/osx-homebrew.yaml osx

# generic
yaml file:///home/yourname/rosdistro/rosdep/base.yaml
yaml file:///home/yourname/rosdistro/rosdep/python.yaml
yaml file:///home/yourname/rosdistro/rosdep/ruby.yaml
gbpdistro file:///home/yourname/rosdistro/releases/fuerte.yaml fuerte

# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead

第二个文件

cd /usr/lib/python2.7/dist-packages/rosdep2/
sudo gedit gbpdistro_support.py

同样的替换,如下

FUERTE_GBPDISTRO_URL = 'file:///home/yourname/rosdistro/' \
    'releases/fuerte.yaml'

第三个文件

cd /usr/lib/python2.7/dist-packages/rosdep2/
sudo gedit rep3.py

同样的替换,如下

REP3_TARGETS_URL = 'file:///home/yourname/rosdistro/releases/targets.yaml'

第四个文件

cd /usr/lib/python2.7/dist-packages/rosdistro/
sudo gedit __init__.py
(我的电脑里是 __init__.py,但是原作者的是init.py,大家可以自己查看)

同样的替换,如下

DEFAULT_INDEX_URL = 'file:///home/yourname/rosdistro/index-v4.yaml'

第三步

打开一个终端,执行以下指令创建root并切换至root用户

sudo su //输入你的密码切换至root
sudo mkdir -p /etc/ros/rosdep/sources.list.d   
cd /etc/ros/rosdep/sources.list.d
sudo gedit 20-default.list

将以下的内容复制进20-default.list中

#os-specific listings first
yaml file:///home/yourname/rosdistro/rosdep/osx-homebrew.yaml osx
#generic
yaml file:///home/yourname/rosdistro/rosdep/base.yaml
yaml file:///home/yourname/rosdistro/rosdep/python.yaml
yaml file:///home/yourname/rosdistro/rosdep/ruby.yaml
gbpdistro file:///home/yourname/rosdistro/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
出现如下

reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit file:///home/tft/rosdistro/rosdep/osx-homebrew.yaml
Hit file:///home/tft/rosdistro/rosdep/base.yaml
Hit file:///home/tft/rosdistro/rosdep/python.yaml
Hit file:///home/tft/rosdistro/rosdep/ruby.yaml
Hit file:///home/tft/rosdistro/releases/fuerte.yaml
Query rosdistro index file:///home/tft/rosdistro/index-v4.yaml
Skip end-of-life distro "ardent"
Add distro "bouncy"
Add distro "crystal"
Add distro "dashing"
Add distro "eloquent"
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"
updated cache in /home/tft/.ros/rosdep/sources.cache

大功告成!


最后再次感谢作者,解决了这个“千古难题”。

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

  • 117
    点赞
  • 360
    收藏
    觉得还不错? 一键收藏
  • 99
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值