关注微信公众号:XRobotSpace
关注微信公众号:依法编程
操作系统: ubuntu 18.04 / ubuntu 20.04
更新时间: 20211221
说明:
- ubuntu 20.04基本步骤类似,存在一些文件的路径有区别。
- 本方案仅供记录,这个问题通过ubuntu命令行添加代理方式能更好解决。
1. 问题描述
在Ubuntu 18.04 LTS 64bit 安装 ROS Melodic中,步骤初始化rosdep
时需要执行指令:
sudo rosdep init
rosdep update
但在执行时会因为网络问题出现错误提示。
1.1 错误-1
sudo: rosdep:找不到命令
解决办法:
sudo apt install python-rosdep
1.2 错误-2
ERROR: default sources list file already exists: /etc/ros/rosdep/sources.list.d/20-default.list Please delete if you wish to re-initialize
解决办法:
sudo rm /etc/ros/rosdep/sources.list.d/20-default.list
路径需根据具体位置修改正确。
1.3 错误-3
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.
1.4 错误-4
reading in sources list data from /etc/ros/rosdep/sources.list.d
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml]:
<urlopen error timed out> (https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml)
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml]:
<urlopen error timed out> (https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml)
ERROR: unable to process source
[https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml]:
<urlopen error timed out> (https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml)
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml]:
<urlopen error timed out> (https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml)
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml]:Failed to download target platform data for gbpdistro:<urlopen error timed out>
Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
ERROR: error loading sources list:
<urlopen error <urlopen error timed out> (https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml)>
2. 解决方案
2.0 将rosdistro
文件下载到本地
git clone https://github.com/ros/rosdistro.git
默认会在home/yourname/
下出现一个rosdistro文件夹,我习惯将文件夹复制到/opt目录下,根据实际情况修改。
2.1 修改第一个文件
sudo gedit /opt/rosdistro/rosdep/sources.list.d/20-default.list
修改全部内容为(注意修改/opt为你自己的rosdistro文件夹目录**,下同**):
# os-specific listings first
yaml file:///opt/rosdistro/rosdep/osx-homebrew.yaml osx
# generic
yaml file:///opt/rosdistro/rosdep/base.yaml
yaml file:///opt/rosdistro/rosdep/python.yaml
yaml file:///opt/rosdistro/rosdep/ruby.yaml
gbpdistro file:///opt/rosdistro/releases/fuerte.yaml fuerte
# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdi
2.2 修改第二个文件
sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/gbpdistro_support.py
修改部分内容:
FUERTE_GBPDISTRO_URL = 'file:///opt/rosdistro/releases/fuerte.yaml'
2.3 修改第三个文件
sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/rep3.py
修改部分内容为:
REP3_TARGETS_URL = 'file:///opt/rosdistro/releases/targets.yaml'
2.4 修改第四个文件
sudo gedit /usr/lib/python2.7/dist-packages/rosdistro/__init__.py
修改部分内容为:
DEFAULT_INDEX_URL = 'file:///opt/rosdistro/index-v4.yaml'
2.5 修改第五个文件
sudo gedit /etc/ros/rosdep/sources.list.d/20-default.list
说明:如果指令sudo rosdep init
没有执行,则不存在目录/etc/ros/rosdep/sources.list.d
,需要自己创建后再修改。
# sudo 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
如果指令sudo rosdep init
执行成功了,则存在目录/etc/ros/rosdep/sources.list.d
,可直接修改部分内容。
#os-specific listings first
yaml file:///opt/rosdistro/rosdep/osx-homebrew.yaml osx
#generic
yaml file:///opt/rosdistro/rosdep/base.yaml
yaml file:///opt/rosdistro/rosdep/python.yaml
yaml file:///opt/rosdistro/rosdep/ruby.yaml
gbpdistro file:///opt/rosdistro/releases/fuerte.yaml fuerte
#newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the
2.6 执行指令rosdep update
,运行通过
sudo rosdep init
rosdep update