rosdep init/update失败(转载)

2023-12-28 03:15:46

sudo rosdep init
rosdep update

如果你直接成功了,可直接跳过当我没说(不过90%的几率你都会失败的啦)

由于http://raw.githubusercontent.com这个网址墙的很厉害,大概率你是成功不了的,这里推荐一种本地化安装的方法

1. 下载rosdistro

git clone https://github.com/ros/rosdistro.git

(如果git都失败了...,可以百度github镜像网站,镜像站下载很方便)

将rosdistro存放在/home/yourname/rosdistro

2. 配置20-default.list文件

运行

sudo rosdep init

重新生成/etc/ros/rosdep/sources.list.d/20-default.list. 没有则手动创建/etc/ros/rosdep/sources.list.d/20-default.list.

如果sudo rosdep init成功,直接跳过以下创建文件步骤

进入到/etc/ros/目录下

cd /etc/ros

创建rosdep文件

sudo mkdir rosdep && cd rosdep

创建sources.list.d文件

sudo mkdir sources.list.d && cd sources.list.d

创建20-default.list文档

sudo gedit 20-default.list

将20-default.list里面内容修改为下面的代码,注意内容/home/zjl修改为自己的记录路径

# os-specific listings first
yaml file:///home/zjl/rosdistro/rosdep/osx-homebrew.yaml osx

# generic
yaml file:///home/zjl/rosdistro/rosdep/base.yaml
yaml file:///home/zjl/rosdistro/rosdep/python.yaml
yaml file:///home/zjl/rosdistro/rosdep/ruby.yaml
gbpdistro file:///home/zjl/rosdistro/releases/fuerte.yaml fuerte

# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead

3. 编辑以下文件

/etc/ros/rosdep/sources.list.d/20-default.list
    /usr/lib/python2.7/dist-packages/rosdep2/gbpdistro_support.py
    /usr/lib/python2.7/dist-packages/rosdep2/rep3.py
    /usr/lib/python2.7/dist-packages/rosdistro/__init__.py

搜索文件中的?https://raw.githubusercontent.com/ros/rosdistro/master字段,将其替换为file:///home/yourname/rosdistro(后面的部分保持不变,最好备份一下)

例如:

//进行如下修改
#DEFAULT_INDEX_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml'
DEFAULT_INDEX_URL = 'file:///home/zjl/rosdistro/index-v4.yaml

注:最好每个文件都确定一下是否只有一个

例如:我的电脑查找

最后发现不止一个?init.py ,这时最好两个都要修改

4. rosdep update

接下来就可以愉快的rosdep update啦

由于是本地安装就不会失败啦

附上成功截图

五 . 添加环境变量

echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc

最后安装个实用插件

sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential

六 . 测试

运行

roscore

若出现下图,并无报错,就安装好啦

?//

/

这个解决方法是我在群里看到的,近期装了很多次ros都能完美解决,特地转载出来分享给大家,也给自己mark一下。

安装ROS的过程中,很多同学在执行上述指令时会提示以下错误:

 
  1. ERROR: cannot download default sources list from:

  2. https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list

  3. Website may be down.

通常的解决办法是用手机热点

或者查询?

https://raw.githubusercontent.com的实际IP地址,但是也有可能会失效。

偶然的机会看到一教程的解决方案。

博主的思路是新思路:将相关资源备份到 gitee,修改?rosdep?源码,重新定位资源。成功率是百分百。

整理修改后提供解决ROS rosdep?init/update报错的方法(终极版)。

步骤1

进入到?sources.list.d?文件夹(如果没有,则用mkdir指令新建)

修改?gedit?20-default.list

 
  1. cd /etc/ros/rosdep/sources.list.d

  2. sudo gedit 20-default.list

将里面所有的?

raw.githubusercontent.com/ros/rosdistro/master
替换成

gitee.com/wybros/rosdistro/raw/master?

修改前:

 
  1. # os-specific listings first

  2. yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx

  3. # generic

  4. yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml

  5. yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml

  6. yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml

  7. gbpdistro https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml fuerte

  8. # newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead

修改后:

 
  1. # os-specific listings first rosdep update

  2. yaml https://gitee.com/wybros/rosdistro/raw/master/rosdep/osx-homebrew.yaml osx

  3. # generic

  4. yaml https://gitee.com/wybros/rosdistro/raw/master/rosdep/base.yaml

  5. yaml https://gitee.com/wybros/rosdistro/raw/master/rosdep/python.yaml

  6. yaml https://gitee.com/wybros/rosdistro/raw/master/rosdep/ruby.yaml

  7. gbpdistro https://gitee.com/wybros/rosdistro/raw/master/releases/fuerte.yaml fuerte

  8. # newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead

步骤2

进入到?rosdep2?文件夹,

修改?gbpdistro_support.py

 
  1. cd /usr/lib/python2.7/dist-packages/rosdep2/

  2. sudo gedit gbpdistro_support.py

将里面所有的?

raw.githubusercontent.com/ros/rosdistro/master
替换成

gitee.com/wybros/rosdistro/raw/master?

修改后如下

 
  1. FUERTE_GBPDISTRO_URL = 'https://gitee.com/wybros/rosdistro/raw/' \

  2. 'master/releases/fuerte.yaml'

步骤3

进入到?rosdep2?文件夹,

修改?rep3.py

 
  1. cd /usr/lib/python2.7/dist-packages/rosdep2/

  2. sudo gedit rep3.py

将里面所有的?

raw.githubusercontent.com/ros/rosdistro/master
替换成

gitee.com/wybros/rosdistro/raw/master?

修改后如下

REP3_TARGETS_URL = 'https://gitee.com/wybros/rosdistro/raw/master/releases/targets.yaml'

步骤4

进入到?rosdep2?文件夹,

修改?sources_list.py

 
  1. cd /usr/lib/python2.7/dist-packages/rosdep2/

  2. sudo gedit sources_list.py

将里面所有的?

raw.githubusercontent.com/ros/rosdistro/master
替换成

gitee.com/wybros/rosdistro/raw/master?

修改后如下

DEFAULT_SOURCES_LIST_URL = 'https://gitee.com/wybros/rosdistro/raw/master/rosdep/sources.list.d/20-default.list'

步骤5

进入到?rosdistro?文件夹

修改?__init__.py

 
  1. cd /usr/lib/python2.7/dist-packages/rosdistro/

  2. sudo gedit __init__.py

将里面所有的?

raw.githubusercontent.com/ros/rosdistro/master
替换成

gitee.com/wybros/rosdistro/raw/master?

修改后如下

DEFAULT_INDEX_URL = 'https://gitee.com/wybros/rosdistro/raw/master/index-v4.yaml'

最后

打开新终端执行

rosdep update

如果出现如下提示则表示成功!

图片

文章来源:https://blog.csdn.net/geniusChinaHN/article/details/135257548
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。