rosdep update出错解决办法(2021)

ROS安装方法:ros安装后,初始化时rosdep update出错解决办法(2021-06-30)

初始化时rosdep update出错解决办法

2021年以前,通过科学上网、手机开热点等方式,还是可以安装上ROS的,但从2021年开始,突然发觉ubuntu上安装ROS愈发困难,科学上网、手机开热点等方式基本也不能成功安装ROS,不是timeout就是website refuse。因此在分析ROS安装方式后,尝试不通过访问github.com的方式安装ROS。经过亲测,发现同样可行。但前提是,你已经获得了ROS的相关安装文件。下载路径:https://github.com/ros/rosdistro。
下面开始对安装ROS过程中最后两步出现的问题,说明解决方法。

1.执行 sudo rosdep init 失败

原理分析:
sudo rosdep init 操作最主要的工作就是从https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list,下载文件20-default.list,并把它放到/etc/ros/rosdep/sources.list.d/这个目录下。
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

2. 执行rosdep update失败

原理分析:
rosdep update 操作最主要的工作就是根据从20-default.list 文件的內容下载相应文件,但是因为网络问题,从raw.githubusercontent.com/下载文件通常失败,采用科学上网可以成功,但也可能要尝试很多次。

基于上述分析,既然无法直接从网络上下载文件,那么可以把相关文件下载到本地,然后直接从本地获取。

修改20-default.list脚本文件,需要超级权限。可以跟前面的脚本内容做下对比。脚本内容如下:

# 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
yaml file:///etc/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

退出保存后。
sudo 打开/usr/lib/python2.7/dist-packages/rosdistro/init.py这个文件,按照下面的代码进行修改。

# index information

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

保存后,执行rosdep update。
如果一次不成功,再执行个一两次,应该就可以成功,执行結果如下:

reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit file:///etc/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit file:///etc/ros/rosdistro/master/rosdep/base.yaml
Hit file:///etc/ros/rosdistro/master/rosdep/python.yaml
Hit file:///etc/ros/rosdistro/master/rosdep/ruby.yaml
Hit file:///etc/ros/rosdistro/master/releases/fuerte.yaml
Query rosdistro index file:///etc/ros/rosdistro/master/index-v4.yaml
Skip end-of-life distro "ardent"
Skip end-of-life distro "bouncy"
Skip end-of-life distro "crystal"
Add distro "dashing"
Add distro "eloquent"
Add distro "foxy"
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"
Add distro "noetic"
updated cache in /home/xxxx/.ros/rosdep/sources.cache

你可能感兴趣的:(自动驾驶)