rosdep init ROS安装问题解决方案

https://www.guyuehome.com/12640

问题简述

操作系统:Ubuntu18.04 ROS版本:melodic 笔者在很长一段时间里,由于自身电脑问题,只能通过VMWare软件安装Ubuntu操作系统的虚拟机进行ROS相关的学习与应用,并偶然并多次的发现安装完系统后,进行ROS安装过程中,跟着官方安装教程执行到下面贴出的命令行时,出现了如下图所示的错误提示:

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.

于是试着通过浏览器访问error中提及的网址:浏览器启动——!!!
在这里插入图片描述
发现网址都无法打开,于是尝试以下代码,ping一下这个网址

ping raw.githubusercontent.com

却发现其实通过终端ping的方式,我们是可以访问上述网页地址的
在这里插入图片描述
那么究竟error中返回的地址到底有什么内容呢,于是从一台安装好ROS的电脑上,我们访问了这个error中提及的网址,从下图可以看出这个网址页面的一些信息。
在这里插入图片描述
于是在安装好ROS的电脑上翻看了相关文件,发现在/etc/ros/rosdep/sources.list.d文件目录下有一个名称为20-default.list文件,打开显示如下,通过对比发现,该文档的内容与error返回网址的内容一致,于是笔者猜测sudo rosdep init为链接上述网址,下载相关文件(20-default.list)到上述目录中,并且通过rosdep update访问该文件中的相关地址,下载相关文件。
在这里插入图片描述
解决方案

  • 解决方案0x01

如果你正遇到这个问题,那么第一个解决方案就是,更换网络,你可以尝试使用你的手机热点,然后继续尝试以下指令,如果你成功了,那么你可以结束本文章的阅读,当然欢迎你继续阅读。

sudo rosdep init

rosdep update

  • 解决方案0x02

该解决方案是针对由于以下两个无法正常访问,但可以ping通,于是修改hosts文件,加入以下两个网址的IP地址实现访问。

sudo gedit /etc/hosts

199.232.28.133 raw.githubusercontent.com

151.101.228.133 raw.github.com

修改完成后,在终端执行

sudo rosdep init

rosdep update

  • 解决方案0x03

如果使用解决方案0x01仍然无法解决你的问题,那么你可以尝试以下步骤,此解决方案的原理是基于手动完成sudo rosdep init的步骤,然后再通过rosdep update完成整个方案的实施。

  1. 步骤一:首先打开一个终端,执行以下指令创建root并切换至root用户
    sudo passwd //接着提示输入UNIX密码,输入你的用户密码即可
    sudo su //或者su root 然后输入密码切换至root用户
    sudo mkdir -p /etc/ros/rosdep/sources.list.d
    cd /etc/ros/rosdep/sources.list.d
    sudo gedit 20-default.list

  2. 将以下内容复制进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

  3. 执行以下指令
    exit //退出root用户
    rosdep update
    如果你成功了,那么你可以结束本文章的阅读,当然欢迎你继续阅读。 但也许你会遇到如下图所示的问题,发现20-default.list中的地址都无法连接,此时你可以将20-default.list中的内容替换如下,即将raw.githubusercontent.com替换为raw.github.com后保存文件,在终端中执行
    rosdep update

    sudo su
    sudo gedit /etc/hosts

    在hosts中添加以下内容并保存,在执行完后继续rosdep update

    199.232.28.133 raw.githubusercontent.com
    151.101.228.133 raw.github.com

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值