Ubuntu安装ROS流程,以及rosdep init和rosdep update解决办法

Ubuntu安装ROS,按照步骤来保你安装成功


一共分为六步,按如下操作就行,最后介绍rosdep init和rosdep update解决办法

一、添加软件源
直接选择国内中科大USTC的,速度快

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 apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F42ED6FBAB17C654

三、安装ROS

sudo apt-get update
sudo apt-get install ros-melodic-desktop-full
sudo apt-get install ros-melodic-rqt*

这三行代码一步一步来
四、初始化rosdep(重点在这)

sudo rosdep init
rosdep update

五、设置环境变量

echo ''source /opt/ros/kinetic/setup.bash'' >> ~/.bashrc
source ~/.bashrc

六、安装rosinstall
rosinstall 是一个经常使用的命令行工具,可以从一个命令下载许多个ROS包的源树。

sudo apt-get install python-rosinstall

对于很多人来说在第四步都会出现错误,我也安装了好多次ROS,每次都是卡在这,每次都费老大劲才搞定,下定决心写一篇解决办法,以便随后安装再次遇到同样的问题。下面方法不讲原理,只写操作步骤。

重点一:sudo rosdep init失败解决办法
运行sudo rosdep init时,一般会出现如下错误:
在这里插入图片描述
解决方案:
1.打开新终端依次运行以下代码

sudo mkdir -p /etc/ros/rosdep/sources.list.d
cd /etc/ros/rosdep/sources.list.d
sudo gedit 20-default.list

2.复制以下内容到打开的文件中

# 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这一步就相当于完成了,但是运行下一步rosdep update一般还会出错,请看下面。

重点二:rosdep update失败解决办法
运行rosdep update时,一般会出现如下错误:

解决办法:
1.从云盘下载这个文件,并在windows下解压好,或者你在ubuntu下解压也行。
链接: https://pan.baidu.com/s/19OCXIUgZ1RNHV33noc1auw

提取码: tnn9
2.将解压好的rosdistro这个文件夹 移动到 /etc/ros目录下。

sudo mv ~/下载/rosdistro /etc/ros

我的rosdistro这个文件夹是放在我的“下载”里面,你们根据你们的实际情况可修改一下上面程序。
3.重新修改20-default.list脚本文件

cd /etc/ros/rosdep/sources.list.d
sudo gedit 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

4.接着执行以下操作

sudo gedit /usr/lib/python2.7/dist-packages/rosdistro/__init__.py

找到index information,按照以下进行修改

# 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。如果一次不成功,再执行个一两次
5.若还不成功,执行最后一步

sudo gedit /etc/hosts

打开hosts文件后,在最后一行加入如下内容:
151.101.84.133 raw.githubusercontent.com
在这里插入图片描述保存后退出,重新执行rosdep update,就会成功了,成功安装会出现如下打印:
在这里插入图片描述
本文主要参考如下博主的文章:
[1] https://blog.csdn.net/super_sean/article/details/105433250 这篇对我帮助很大。
[2] https://blog.csdn.net/r1141207831/article/details/105676468
[3] https://blog.csdn.net/weixin_42306148/article/details/116787379?spm=1001.2014.3001.5501
[4] https://blog.csdn.net/Kenny_GuanHua/article/details/116845781
这篇是我朋友给我的方法,在我刚想用这个的时候,发现我的方法已经安装成功了。

  • 4
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值