ubuntu16.04安装ROS Kinetic很多次了,但是这一次安装的步骤却不顺利,特此记录。
打开 Ubuntu 的设置 -> 软件与更新 -> Ubuntu软件 ->勾选main ,universe , restricted, multiverse四项。
source.list 是ubuntu系统保存软件源地址的文件,位于/etc/apt目录下,在这一步中我们需要将ROS的软件源地址添加到该文件中,确保后续安装可以正确找到ROS相关软件的下载地址。
打开终端,输入如下命令,即可添加ROS官方的软件源镜像:
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.ustc.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
中山大学:
sudo sh -c '. /etc/lsb-release && echo "deb http://mirror.sysu.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
易科机器人实验室:
sudo sh -c '. /etc/lsb-release && echo "deb http://ros.exbot.net/rospackage/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
1.先确保之前的软件源的修改得以更新:
sudo apt-get update
2.ROS系统非常大,包含众多的功能包、函数库和工具,所以ROS 官方为用户提供了很多版本,此处选择最为推荐的桌面完整版:
sudo apt-get install ros-kinetic-desktop-full
rosdep是ROS中自带的工具,主要功能是为某些功能包安装系统依赖,同时也是某些ROS核心功能包必须用到的工具。初始化rosdep,这一步非常的关键,在你开始使用ros之前,你需要初始化rosdep,因为当你编译你的功能包,被要求运行ros中的一些核心组件的时候,rosdep可以让你轻松地安装源的系统依赖.完成以上步骤之后,需要使用以下命令进行初始化和更新:
sudo rosdep init
rosdep update
没有出错的话,直接到第6步设置环境变量。
报错如下:
执行命令 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.
全程sudo,建立一个文件夹 /etc/ros/rosdep/sources.list.d
然后, /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
# 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
也有人添加下面的内容(我使用的这个):
# 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.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
情况1:
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml
Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
Skip end-of-life distro "ardent"
Add distro "bouncy"
Add distro "crystal"
Skip end-of-life distro "groovy"
Skip end-of-life distro "hydro"
Add distro "indigo"
Skip end-of-life distro "jade"
Add distro "kinetic"
Add distro "lunar"
Add distro "melodic"
ERROR: error loading sources list:
<urlopen error <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)> (https://raw.githubusercontent.com/ros/rosdistro/master/melodic/distribution.yaml)
这种可能是没有ssl认证,执行以下操作:
sudo apt-get install ca-certificates
情况2:
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml
Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
Skip end-of-life distro "ardent"
Add distro "bouncy"
Add distro "crystal"
Skip end-of-life distro "groovy"
Skip end-of-life distro "hydro"
Add distro "indigo"
Skip end-of-life distro "jade"
Add distro "kinetic"
这里说:ERROR:unable to process source 或者什么什么timeout可能就是这种情况
这种情况,提示运行超时,你要考虑你的网速是否足够快。基本上到了这一步出错的问题都是网速的问题。有一次安装在学校连接校园网失败了,然后多执行了几次就搞定了;还有一次安装是连接的网线失败,然后看网上说用手机开热点这样网速更快,可以解决,然后试了一下,果然可以(如果开了热点不行,多试几次);写这个笔记的时候安装的这一次最惨了,开始是连接家里的网线,试了很多次没用,然后使用手机热点试了很多次也没用,然后用手机热点搞了一整天也没用,然后睡了,想着第二天早上网速可能会快点,然后第二天早上使用手机热点一次通过。总结一下就是:考虑你的网速是否足够快,最好使用手机热点,应该会更快。
由于会频繁的使用终端输入ROS 命令,所以在使用之前还需要对环境变量进行简单的设置。默认的是使用bash终端,在bash中设置ROS环境变量:
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
现在打开终端,输入roscore命令,就可以看到ROS运行起来了。
rosinstall也是ROS中的一个常用工具,可以下载和安装ROS中的功能包程序。这个工具不是比必须的,但是为了以后的方便,最好安装上:
sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential
用apt-get方式安装ROS的,卸载使用如下命令:
sudo apt-get remove ros-*
卸载成功的效果就是/opt下的ROS文件夹被删除,原先的ROS以及曾经安装在ROS中的package也没有了。
参考链接:
胡春旭:ROS机器人实战
安装ROS:sudo rosdep init报错,ERROR: cannot download default sources list from:
ROS常见问题(一) 安装ROS时sudo rosdep init指令报错 最全解决方法
ROS的 sudo rosdep init 的报错解决方案
ros入门(1)-安装ros与开发包