ROS安装sudo rosdep init失败解决方法(离线安装)

现象:

执行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.

原因:

raw.githubusercontent.com被墙了

解决方案:

  1. 修改主机host,增加域名解析记录(不一定成功)
  2. 翻墙
  3. 离线安装

本文使用解决方案3,离线安装步骤:

  1. 下载文件https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list,
    百度网盘下载链接
    20-default.list文件放到/etc/ros/rosdep/sources.list.d/目录下。
  2. 下载rosdistro
    git clone https://github.com/ros/rosdistro.git
    百度网盘下载链接
    下载后放到/etc/ros目录下
  3. 修改20-default.list文件,将https://raw.githubusercontent.com替换为本地目录地址
    # 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
  4. 修改以下三个文件,将https://raw.githubusercontent.com替换为本地目录地址
    1. /usr/lib/python2.7/dist-packages/rosdep2/gbpdistro_support.py
    2. /usr/lib/python2.7/dist-packages/rosdep2/rep3.py
    3. /usr/lib/python2.7/dist-packages/rosdistro/__init__.py

    gbpdistro_support.py

    #FUERTE_GBPDISTRO_URL = 'https://raw.githubusercontent.com/ros/rosdistro/' \
    # 'master/releases/fuerte.yaml'
    FUERTE_GBPDISTRO_URL = 'file:///etc/ros/rosdistro/' \
    'master/releases/fuerte.yaml'

    rep3.py

    #REP3_TARGETS_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/releases/targets.yaml'
    REP3_TARGETS_URL = 'file:///etc/ros/rosdistro/master/releases/targets.yaml'

    __init__.py

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