问题分析
安装ros 执行sudo rosdep init 或者rosdep update出错的主要原因:https://raw.githubusercontent.com网站国内访问受限。
最新解决方案
原理
既然网站服务器访问受限,不如把服务器中的文件拷贝下来,在本地进行 init和update.
第一步 下载服务器中的文件
打开终端,输入下面指令:
git clone https://github.com/ros/rosdistro.git
最终会得到所用的文件,文件路径为(注意user替换为自己的用户名):
/home/user/rosdistro
第二步 修改文件
- 20-default.list文件,将服务器地址更换为本地。
sudo gedit /home/user/rosdistro/rosdep/sources.list.d/20-default.list
# os-specific listings first
yaml file:///home/yourname/rosdistro/rosdep/osx-homebrew.yaml osx
# generic
yaml file:///home/user/rosdistro/rosdep/base.yaml
yaml file:///home/user/rosdistro/rosdep/python.yaml
yaml file:///home/user/rosdistro/rosdep/ruby.yaml
gbpdistro file:///home/user/rosdistro/releases/fuerte.yaml fuerte
# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
- gbpdistro_support.py 文件,同理。
sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/gbpdistro_support.py
FUERTE_GBPDISTRO_URL = 'file:///home/user/rosdistro/releases/fuerte.yaml'
- rep3.py文件
sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/rep3.py
REP3_TARGETS_URL = 'file:///home/user/rosdistro/releases/targets.yaml'
- _init_.py文件
sudo gedit /usr/lib/python2.7/dist-packages/rosdistro/__init__.py
DEFAULT_INDEX_URL = 'file:///home/user/rosdistro/index-v4.yaml'
第三步 创建20-default.list文件,模拟 执行rosdep init的过程
sudo mkdir -p /etc/ros/rosdep/sources.list.d
cd /etc/ros/rosdep/sources.list.d
sudo touch 20-default.list
sudo gedit 20-default.list
复制以下内容,保存退出。
#os-specific listings first
yaml file:///home/user/rosdistro/rosdep/osx-homebrew.yaml osx
#generic
yaml file:///home/user/rosdistro/rosdep/base.yaml
yaml file:///home/user/rosdistro/rosdep/python.yaml
yaml file:///home/user/rosdistro/rosdep/ruby.yaml
gbpdistro file:///home/user/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命令
rosdep update
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit file:///home/user/rosdistro/rosdep/osx-homebrew.yaml
Hit file:///home/user/rosdistro/rosdep/base.yaml
Hit file:///home/user/rosdistro/rosdep/python.yaml
Hit file:///home/user/rosdistro/rosdep/ruby.yaml
Hit file:///home/user/rosdistro/releases/fuerte.yaml
Query rosdistro index file:///home/user/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/user/.ros/rosdep/sources.cache
至此问题解决。