解决ROS初始化时rosdep init报错,rosdep update报错

本文转载自: [link]
(https://blog.csdn.net/super_sean/article/details/105433250)

背景:

ubuntu上安装ROS,不管是在ubuntu16.04上装kinetic,还是在18.04上装melodic,安装完毕后,进行初始化时,反复失败,试遍了网上公开的方法,都没能解决。最后,通过本地创建配置文件的方法,终于搞定。

更新:

最近按照1-3步修改后的状态,执行rosdep update时,在执行gbpdistro file:///etc/ros/rosdistro/master/releases/fuerte.yaml fuerte时,老是报错,返回错误11。原因是解析https://raw.githubusercontent.com的IP地址时,DNS服务被污染,导致得不到正确的IP地址而报错,需要更改一下本机的DNS服务器地址。具体参照下面第4步。


1.执行 sudo rosdep init 失败

反复尝试一下,一般情况下反复个几次,init这步就可以成功。

如果反复不成功,根据提示错误,可以先参考下面链接提供的方法尝试一下

https://www.cnblogs.com/xuhaoforwards/p/9399744.html

上面的操作都不成功,可以参考下面。

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

操作起来就是:直接创建目录/etc/ros/rosdep/sources.list.d/,并在此目录下创建20-default.list这个文件。创建这个文件需要高级权限。

  1. 执行rosdep update失败

这步的操作失败原因是从raw.githubusercontent.com/下载文件失败,主要是防火墙限制了对这个网站的访问,能科学上网的同学就不用往下看了。

在我所处的网络中,是偶尔能够访问raw.githubusercontent.com/的,但是不持久-_-!!,所以一直无法完整的坚持下来。

(1)可以先参考下面链接的方法,将python脚本的超时时间写长一点比如120s,然后反复尝试。但是单纯使用这个方法,对我没用。

https://www.cnblogs.com/zxzmnh/p/11758103.html
(不推荐;from转载者)

(2)如果单纯上面的操作对你也没用,请继续往下看。分析了前面链接提到的sources_list.py、gbpdistro_support.py、rep3.py几个脚本,发现主要在打开20-default.list里的链接时失败,也就是无法下载20-default.list列举的几个配置文件。有了这个发现,下面的事情就是,把这些文件下载到本地,然后修改20-default.list脚本文件就可以了。

(推荐;from转载者)

具体操作如下:

a.将20-default.list中的链接在浏览器中打开,然后创建一个同名文件,最好连目录结构一起建好,这样后面改脚本比较容易。我是直接建在了/etc/ros/建了相应的目录。

也可以从下面云盘中直接下载,解压到/etc/ros目录下。需要超级权限。

链接: https://pan.baidu.com/s/19OCXIUgZ1RNHV33noc1auw

提取码: tnn9

b.修改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
gbpdistro 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

退出保存后,执行rosdep update。

在更新过程中,还有部分配置信息会从raw.githubusercontent.com上下载,但是反复几次,基本上就可以成功了。

(3)经过上面两步,还是失败,请继续往下看。(还未尝试;from转载者)

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。如果一次不成功,再执行个一两次,应该就会出现下面成功完成的这些打印。

(4)(还未尝试;from转载者)

如果执行到第3步还是报错,很可能是本机的DNS服务被污染了,无法获得https://raw.githubusercontent.com这个网址的正确IP,导致连接失败。这时你需要更新一下DNS服务器设置,选择一个外部的DNS服务器。以ubuntu MATE 16.04为例,路径如下:

系统–>系统管理–>网络–>DNS,在这个界面下,先解锁,然后在DNS服务器栏,点击Add,在对话框中填上8.8.8.8(google的DNS服务器),把它放到一位(可以点着上下拖动),然后锁定,关闭。

其他修改DNS服务器地址的方式就不一一列举了,搜一下一堆攻略。

回到terminal,执行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
  • 1
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
### 回答1: 在Ubuntu 16.04上使用ROS,执行"rosdep init"命令可能会遇到报错。这个问题通常是由于网络连接问题导致的。要解决这个问题,可以按照以下步骤进行操作: 1. 首先,确保您的网络连接是正常的,可以尝试更换网络连接方式(例如使用有线连接代替无线连接)并重试命令。 2. 如果更换网络连接方式仍然无法解决问题,可以尝试使用以下命令来更新ROS的依赖项: ``` sudo apt-get update sudo apt-get install python-rosdep ``` 3. 如果上述步骤仍然无法解决问题,可以尝试手动初始化rosdep。首先,通过以下命令创建一个rospkg目录: ``` sudo mkdir /etc/ros/rosdep/sources.list.d ``` 4. 然后,使用以下命令创建一个rosdep源列表文件: ``` sudo sh -c 'echo "yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml" > /etc/ros/rosdep/sources.list.d/20-default.list' ``` 5. 最后,执行以下命令来初始化rosdep: ``` rosdep init ``` 通过执行上述步骤,您应该能够成功初始化rosdep,并继续使用ROS。希望这些信息对您有所帮助! ### 回答2: 当使用`ubuntu 16.04`系统上的`rosdep init`命令,可能会遇到报错。这个错误通常是由于`rosdep`工具中的源文件问题引起的。 要解决这个问题,可以按照以下步骤进行操作: 1. 打开终端,输入以下命令来编辑`rosdep`源文件: ``` sudo nano /etc/ros/rosdep/sources.list.d/20-default.list ``` 2. 在打开的文件中,你会看到一些URL链接。这些链接是`rosdep`工具用来下载依赖关系的源文件。 3. 将所有的URL链接注释掉,或者将它们删除。你可以在前面添加一个井号(#)来注释掉链接。 4. 在文件的末尾,添加以下源文件链接: ``` yaml http://packages.ros.org/ros/rosdep/ubuntu.yaml ``` 5. 保存文件并退出编辑器。 6. 运行以下命令来更新`rosdep`工具的源文件: ``` sudo rosdep update ``` 7. 现在你可以尝试再次运行`rosdep init`命令,应该不会再出现错误。 这些步骤将修复`ubuntu 16.04`系统上`rosdep init`命令的报错问题,并正确初始化`rosdep`工具。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值