目录
一、安装步骤
1. 设置sources.list
通常使用:
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
但个人推荐使用下面清华源,稳定且下载速度会更快
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
2. 添加密钥
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
3. 更新软件包
sudo apt-get update
4. 安装ROS kinetic完整版
sudo apt-get install ros-kinetic-desktop-full
5. 初始化rosdep
sudo rosdep init
rosdep update
6. 配置ROS环境
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
二、常见问题及解决方案
1. rosdep初始化失败
报错如下:
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.
这类问题是由于源和网络导致的,无法成功验证 SSL 证书,我们可以通过切换源和网络解决,但有时候我们会受限于工作环境而无法更改网络,这里推荐一种跳过SSL验证的方法
解决方案
方法一:
打开sources_list.py文件
sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/sources_list.py
在顶部直接插入两行代码取消SSL验证
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
方法二:
通过IPAddress.com首页,输入raw.githubusercontent.com查询到真实IP地址,然后打开 /etc/hosts 文件
sudo gedit /etc/hosts
添加以下内容保存即可
查询到的IP raw.githubusercontent.com
2. rosdep更新失败
报错如下:
<urlopen error <urlopen error [Errno 111] Connection refused>
同样是由于网络连接问题导致的,可以通过添加google域名服务器解决
解决方案
方法一:
sudo gedit /etc/resolv.conf
将原有的nameserver这一行注释,并添加以下两行:
nameserver 8.8.8.8 #google域名服务器
nameserver 8.8.4.4 #google域名服务器
方法二(终极解决方案):
如果上述方法都没有效果,说明你当前使用的网络确实很难连上 githubusercontent,这个时候甭管是增大超时时间(DOWNLOAD_TIMEOUT)、还是将 githubusercontent 改为 github 、或是将 yaml 文件下载到本地等等这些方法基本都很难有所作用,这里只有祭出我们的终极解决方案:
执行rosdep update实际上是在/home/xxx/.ros/rosdep/sources.cache(xxx是你的用户名)产生一个文件夹,里面有一堆缓存文件,从其他装好ROS的电脑中将这个文件拷贝过来,就不需要再rosdep了。
拷贝后别忘了手动在 ~/.bashrc 中添加路径:
source /opt/ros/kinetic/setup.bash
即可正常使用。
三、ROS卸载
使用apt-get方式安装的ros,可直接运行下列命令卸载:
sudo apt-get remove ros-*