亲测解决:Ubuntu18.04安装Melodic Ros遇到的困难及sudo rosdep init error

本文主要解决sudo rosdep init error带来的错误

Ubuntu版本:18.04
对应的Ros版本:Melodic
参考了以下几篇,其实还有好多,这几篇写得较清晰:
https://blog.csdn.net/haiyinshushe/article/details/84256137
https://blog.csdn.net/zhangrelay/article/details/80241758
https://blog.csdn.net/u013468614/article/details/102917569
https://blog.csdn.net/qq_41450811/article/details/99079041
推荐这篇!!!!


按照官网给定安装步骤,第一步配置就是用的国外的源,我们公司的网有限制,搞了好久都没弄好,最后 【换成了自己手机热点】,这里说一下,
执行sudo apt-get install ros-melodic-desktop-full之前的问题基本都是源的问题,换个国内的源就好
我用的这个:

sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'

之后遇到的大的困难:

sudo rosdep init error

执行sudo rosdep init报错:

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.

原因应该就是githubusercontent 在国外,普通人不能访问,如果你不是普通人,这些问题应该都不会存在,你懂我意思吧

解决办法:

第一步. 手动创建20-default.list

直接在/etc目录下新建/ros/rosdep/sources.list.d/20-default.list文件(/etc下并没有/ros目录,需要依次逐级新建
在这里插入图片描述
然后将https://raw.githubusercontent.com/ros/rosdistro/master/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

第二步. 取消SSL验证

上一步完了执行sudo rosdep init 还是会报错不用管他,因为他会在创建这样一个文件:
/usr/lib/python2.7/dist-packages/rosdep2/sources_list.py

你只需要加入这两句在代码开头的import处就可以取消SSL验证:

import ssl
ssl._create_default_https_context = ssl._create_unverified_context

在这里插入图片描述
然后继续执行 rosdep update可能就好了

但是!!!!
有可能仍然会报错,我看了https://zhuanlan.zhihu.com/p/77483614这篇文章的评论,把上一步的20-default.list文件中的所有的 githubusercontent 改为 github 如下:

# os-specific listings first
yaml https://raw.github.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx
# generic
yaml https://raw.github.com/ros/rosdistro/master/rosdep/base.yaml
yaml https://raw.github.com/ros/rosdistro/master/rosdep/python.yaml
yaml https://raw.github.com/ros/rosdistro/master/rosdep/ruby.yaml
gbpdistro https://raw.github.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

再试试rosdep update就可以了

或者

打开hosts文件 sudo gedit /etc/hosts
在文件末尾添加
151.101.84.133 raw.githubusercontent.com
保存后退出再尝试


哦对了我的 软件与更新 里面现在是这样的
在这里插入图片描述
在这里插入图片描述


我一开始用17.10版本的Ubuntu,安装到sudo apt-get update就死活会有一些错,最后放弃试了16.04还是有类似的错,第二天我才反应过来是公司的网络的问题,换了18.04用自己的热点(限速只有69K真的难),然后搞了一天终于搞出来了。
所以还是值得写写让后来的朋友们借鉴一下,由于Ubuntu安装在另一台电脑上,截个图写这篇文章真的费了好大劲。

  • 8
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值