本文主要解决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: 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 在国外,普通人不能访问,如果你不是普通人,这些问题应该都不会存在,你懂我意思吧
直接在/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
上一步完了执行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
但是!!!!
有可能仍然会报错,我看了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安装在另一台电脑上,截个图写这篇文章真的费了好大劲。