基于ubuntu1604的ROS安装

不同版本的都有对应的ROS版本,不要强行安装不对应的版本,否则遇到问题会很难找到解决方法 。此教程也只是基于和版本的ROS 。
一、基本流程
以下命令仅记录执行顺序,不要无脑复制执行,重在理解
#基本更新sudo apt updatesudo apt upgrade##添加ROS下载源sudo touch /etc/apt/sources.list.d/ros-latest.list#阿里ros源,将以下语句复制进ros-latest.list即可deb https://mirrors.aliyun.com/ros/ubuntu/ xenial main#设置秘钥sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654#继续执行,curl未安装的先安装curlcurl -sSL 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xC1CF6E31E6BADE8868B172B4F42ED6FBAB17C654' | sudo apt-key add -安装ROS完整版,大概2G多,需要等一会儿,ros安装路径在/opt/ros/kinetic/sudo apt install ros-kinetic-desktop-full
二、
以上过程较为容易,有不同之处百度下即可解决 。下面要进行初始化,可能会有一些问题,但耐心仔细地跟着网上的教程走一般也能搞定 。首先看问题:
sudo rosdep init
大概率会报以下错误:
上面的命令其实就是从指定的地址下载一个文件,如图中所示,但由于国内科学上网的问题没法下载下来,方法也很简单,将需要的文件转移到一个能访问的地址就可以了,或者更直接一点,把文件及源码直接克隆到本地 。
git clone https://github.com/ros/rosdistro.git
如果这个也没法克隆,就先利用码云从导过来,再克隆到本地,以下是从导入到码云的一个库(不保证能用多久)

基于ubuntu1604的ROS安装

文章插图
https://gitee.com/lxhqddlx/rosdistro.git
克隆完成后,修改原来需要下载的文件,因为那个文件作用也是指定其他文件地址,很不幸也是几个访问不到的地址,所以也要改为本地地址(或能访问到的网络地址) 。
cd rosdistro/rosdep/sources.list.d/vim 20-default.list
20-.list这个文件在执行完 init后会被放到/etc/ros//.list.d/下 。
可以看到其内容是关于几个yaml文件网络位置的,我们已经将整套源码包括这几个文件克隆到本地了,所以可以改成本地地址(只需要替换网络位置部分即可) 。修改前:
# os-specific listings firstyaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx# genericyaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yamlyaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yamlyaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yamlgbpdistro 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 rosdep updateyaml file:///home/lxh/rosdistro/rosdep/osx-homebrew.yaml osx# genericyaml file:///home/lxh/rosdistro/rosdep/base.yamlyaml file:///home/lxh/rosdistro/rosdep/python.yamlyaml file:///home/lxh/rosdistro/rosdep/ruby.yamlgbpdistro file:///home/lxh/rosdistro/releases/fuerte.yaml fuerte# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
根据以上经验,只要涉及到无法访问的地址的文件都要改,大概还有一下几个文件需要修改: