解决rosdep init与rosdep update失败的问题

网上的教程鱼龙混杂,根本不能用,还是自己写一个吧

我们安装完ROS后,要进行如下两个操作:

sudo rosdep init
rosdep update

rosdep能帮助我们安装ROS包所需要的依赖,然而执行的时候,通常会出现:

image-20230118170105143

这个问题来源是大陆的DNS污染,我们首先要手动更改域名解析:

打开https://site.ip138.com/ ,输入raw.githubusercontent.com,查询其IP地址:

image-20230118171754504

打开一个终端,输入:

sudo vim /etc/hosts

在文件最后的末尾添加:

185.199.110.133 raw.githubusercontent.com

当然,换成185.199.110.133或者185.199.109.133都可以

保存退出,再执行:

rosdep init

如果还是访问不了的话,那我们手动进行rosdep init的操作:

用电脑访问https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list ,可看到如下界面:

image-20230118170300075

我们复制一下如下这几行,

# 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

之后在终端中输入:

sudo mkdir -p /etc/ros/rosdep/sources.list.d/
cd /etc/ros/rosdep/sources.list.d/
sudo vim 20-default.list

把前面复制的内容粘贴进去,这实际上就完成了rosdep init的操作

之后执行:

rosdep update

通常情况下,会出现:

image-20230118173841755

我们使用域名代理的方法进行解决

执行:

sudo vim /usr/lib/python2.7/dist-packages/rosdistro/__init__.py

在第68行的https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml前面加上https://ghproxy.com/

image-20230118174655958

执行:

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

在第34行的https://raw.githubusercontent.com/ros/rosdistro/前面加上https://ghproxy.com/

image-20230118175214266

执行:

sudo vim /usr/lib/python2.7/dist-packages/rosdep2/sources_list.py

在第64行的https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list前面加上https://ghproxy.com/

image-20230118175357488

同一个文件,在第301行中添加:url="https://ghproxy.com/"+url

image-20230118174829167

执行:

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

在第36行的https://raw.githubusercontent.com/ros/rosdistro/master/releases/targets.yaml前面加上https://ghproxy.com/

image-20230118175630420

执行:

sudo vim /usr/lib/python2.7/dist-packages/rosdistro/manifest_provider/github.py

在第68行的https://raw.githubusercontent.com/%s/%s/package.xml前面加上https://ghproxy.com/

image-20230118175827618

同一个文件,在第119行的https://raw.githubusercontent.com/%s/%s/%s前面加上https://ghproxy.com/

image-20230118175927888

之后再执行:

rosdep update

可以看到成功执行,至此ROS完美安装成功

image-20230118180305825

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值