Ubuntu 18.04 安装 ROS Melodic 中 sudo rosdep init 和 rosdep update 一定能成功的方法,就硬干

前言

  • 安装ROS相关的博客众多,本篇发布时间为2020-08-13
  • 在国内,由于网络的原因,安装ROS在下面这两步总会多多少少出现各种问题:
    • sudo rosdep init
    • rosdep update
  • 本文目的就是解决这俩问题,即使网不太好(但不能没有网),或者不能翻墙也不用担心,因为我们硬干。
  • 资源:rosdep update需要的所有yaml文件和子文件夹-0积分

1. 解决 sudo rosdep init 问题

  1. 常见报错信息

    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.

  2. 原因: 由于raw.githubusercontent.com被墙,程序无法下载相应的文件。解决方法就是使raw.githubusercontent.com能够被正常访问。这个网站被墙的方式是dns污染,所以我们只要能够找到这个网站的正确ip就可以了 参考这个了

  3. 解决: 修改hosts文件

    • sudo gedit /etc/hosts
    • 把下面这些地址拷贝到hosts文件末尾,然后保存。

      192.30.253.118 gist.github.com
      185.199.110.153 github.io
      151.101.113.194 github.global.ssl.fastly.net
      52.216.227.168 github-cloud.s3.amazonaws.com
      52.74.223.119 github.com
      199.232.28.133 avatars1.githubusercontent.com
      199.232.28.133 avatars2.githubusercontent.com
      199.232.28.133 avatars0.githubusercontent.com
      199.232.28.133 avatars3.githubusercontent.com
      199.232.28.133 raw.githubusercontent.com
      199.232.28.133 user-images.githubusercontent.com
      199.232.28.133 avatars.githubusercontent.com
      199.232.28.133 github.map.fastly.net
      199.232.28.133 avatars7.githubusercontent.com
      54.239.31.69 aws.amazon.com
      54.239.30.25 console.aws.amazon.com
      54.239.96.90 ap-northeast-1.console.aws.amazon.com
      54.240.226.81 ap-southeast-1.console.aws.amazon.com
      54.240.193.125 ap-southeast-2.console.aws.amazon.com
      54.239.54.102 eu-central-1.console.aws.amazon.com
      177.72.244.194 sa-east-1.console.aws.amazon.com
      176.32.114.59 eu-west-1.console.aws.amazon.com
      54.239.31.128 us-west-1.console.aws.amazon.com
      54.240.254.230 us-west-2.console.aws.amazon.com
      54.239.38.102 s3-console-us-standard.console.aws.amazon.com
      54.231.49.3 s3.amazonaws.com
      52.219.0.4 s3-ap-northeast-1.amazonaws.com
      54.231.242.170 s3-ap-southeast-1.amazonaws.com
      54.231.251.21 s3-ap-southeast-2.amazonaws.com
      54.231.193.37 s3-eu-central-1.amazonaws.com
      52.218.16.140 s3-eu-west-1.amazonaws.com
      52.92.72.2 s3-sa-east-1.amazonaws.com
      54.231.236.6 s3-us-west-1.amazonaws.com
      54.231.168.160 s3-us-west-2.amazonaws.com
      52.216.80.48 github-cloud.s3.amazonaws.com
      54.231.40.3 github-com.s3.amazonaws.com
      52.216.20.171 github-production-release-asset-2e65be.s3.amazonaws.com
      52.216.228.168 github-production-user-asset-6210df.s3.amazonaws.com

  4. 再干一件事,执行sudo gedit /etc/resolv.conf,将原有的nameserver这一行注释,并添加以下两行:

    nameserver 8.8.8.8 #google域名服务器
    nameserver 8.8.4.4 #google域名服务器

  5. 再次执行sudo rosdep init,这次会报一个问题,就是文件已存在:

    ERROR: default sources list file already exists: /etc/ros/rosdep/sources.list.d/20-default.list
    Please delete if you wish to re-initialize

  6. 这时候直接删除这个文件sudo rm /etc/ros/rosdep/sources.list.d/20-default.list,再次执行sudo rosdep init,我至今操作过很多次,没有出现不成功的状态,如果实在不成功,试试换手机热点,多执行几次,最后输出如下信息就OK了:

    wrote /etc/ros/rosdep/sources.list.d/20-default.list
    Recommended: please run
    rosdep update

2. 解决 rosdep update 问题

  1. 常见报错信息就是各种The read operation timed out.
  2. 解决,直接从对应网址保存所有需要的文件,然后把网络路径改成本地文件路径:
    • 下载所有的文件,整理好文件夹,对于主要的yaml文件的路径都在20-default.list这个里面有,基本套路就是https://raw.githubusercontent.com/ros/rosdistro/master/XXX后面的xxx根据不同文件替换一下,打开index-v4.yaml能看到所有需要的其他子文件夹yaml文件和gz 压缩包:在这里插入图片描述

    • 直接输进浏览器地址栏,都能直接打开对应的yaml.gz文件,ctrl+s保存即可,最后形成这么一个文件夹,文件夹的名字自己随便起都可以,里面的子文件夹一定和index-v4.yaml保持一致,如下图所示(我整理好了,大家也可以直接用)。
      在这里插入图片描述

    1. 修改 index-v4.yaml的路径和20-default.list文件里面的路径:
      1. sudo gedit /usr/lib/python2.7/dist-packages/rosdistro/__init__.py ,比如我最后放那些yaml的文件夹放在/etc/ros/ros_github,将网址地址改为file:///etc/ros/ros_github/index-v4.yaml如下图所示:在这里插入图片描述

      2. 把里面指向网址的路径改为本地,比如我最后放那些yaml的文件夹放在/etc/ros/ros_github,修改如下:

        # os-specific listings first
        yaml file:///etc/ros/ros_github/osx-homebrew.yaml osx
        # generic
        yaml file:///etc/ros/ros_github/base.yaml
        yaml file:///etc/ros/ros_github/python.yaml
        yaml file:///etc/ros/ros_github/ruby.yaml
        gbpdistro file:///etc/ros/ros_github/fuerte.yaml fuerte
        # newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead

    2. 再次执行rosdep update命令,出现下面的结果,相信这次你没有苦苦等待:
      在这里插入图片描述

3. 小结

  • 这个办法是我在反复rosdep update都不成功的情况下才去尝试的,如果网络还行,在不修改以上文件的情况下,能够成功执行一半,那多试几次可能还是有戏,我试了不下10多次,甚至用了shell写了循环执行rosdep update的脚本,执行了几个小时都没成功。
  • 这个土办法的核心思路就是避开涉及raw.githubusercontent.com的东西,转为本地文件。
  • 当然我这里针对20-default.list这个文件还是选择了联网下,你也可以把这个也下载到本地,然后把他放在/etc/ros/rosdep/sources.list.d/下面。
  • 同样用我这个办法,我成功的在树莓派ubuntu mate 16.04上装了kinetic,并且在台式机ubuntu 16.04也装过kinetic,都能避免痛苦的等待。

猜你喜欢

转载自blog.csdn.net/sinat_25923849/article/details/107976434