ubuntu 16.04下安裝和配置ros(ORB-SLAM-A)

書上和網上關於ubuntu下安裝ros的文章很多,但是很多介紹的不完整,並且ubuntu和ros之間其實是有版本對應關系的,並不是所有的ros都能安裝到所有的ubuntu上,(很多書上或者文章介紹用的都是hydro或者indigo,有的給出了ubuntu版本,有的沒有給出,而參考的人很多忽略了ubuntu版本,覺得都可以)而這一點,很多文章沒有提到,結果其他人參考的時候,無法安裝成功。

1. ubuntu和ros的版本對應關系

Ros發布時間 Ros版本 對應的linux版本
2016.3 ROS Kinetic Kame Ubuntu 16.04 (Xenial) / Ubuntu 15.10 (Wily)
2015.3 ROS Jade Turtle Ubuntu 15.04 (Wily) / Ubuntu LTS 14.04 (Trusty)
2014.7 ROS Indigo Igloo Ubuntu 14.04 (Trusty)
2013.9 ROS Hydro Medusa Ubuntu 12.04 LTS (Precise)
2012.12 ROS Groovy Galapagos Ubuntu 12.04 (Precise)

在這裏,我們選擇最新的ros和ubuntu組合進行安裝,ubuntu 16.04 64bit+ROS Kinetic。

ubuntu 16.04下安裝和配置ros(ORB-SLAM-A)_第1张图片

ubuntu 16.04下安裝和配置ros(ORB-SLAM-A)_第2张图片

2. 配置ubuntu的軟件中心,允許安裝不經認證的軟件

首先打开“软件和更新”对话框,具体可以在 Ubuntu 最左上角的搜索按钮中搜索。

打开后按照下图进行配置(确保你的"restricted", "universe," 和 "multiverse."前是打上勾的):

ubuntu 16.04下安裝和配置ros(ORB-SLAM-A)_第3张图片

3. 添加國內的ubuntu源

如163和阿裏雲的的源,這樣從國內下載軟件,速度會很快。

修改/etc/apt/sources.list文件

在頭部添加如下內容:

[html] view plain copy

  1. deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties    
  2. deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted    
  3. deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties    
  4. deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted    
  5. deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties    
  6. deb http://mirrors.aliyun.com/ubuntu/ xenial universe    
  7. deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe    
  8. deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse    
  9. deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse    
  10. deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse    
  11. deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties    
  12. deb http://archive.canonical.com/ubuntu xenial partner    
  13. deb-src http://archive.canonical.com/ubuntu xenial partner    
  14. deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted    
  15. deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties    
  16. deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe    
  17. deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse   

[html] view plain copy

  1. deb http://mirrors.163.com/ubuntu/ precise main restricted universe multiverse  
  2. deb http://mirrors.163.com/ubuntu/ precise-security main restricted universe multiverse  
  3. deb http://mirrors.163.com/ubuntu/ precise-updates main restricted universe multiverse  
  4. deb http://mirrors.163.com/ubuntu/ precise-proposed main restricted universe multiverse  
  5. deb http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse  
  6. deb-src http://mirrors.163.com/ubuntu/ precise main restricted universe multiverse  
  7. deb-src http://mirrors.163.com/ubuntu/ precise-security main restricted universe multiverse  
  8. deb-src http://mirrors.163.com/ubuntu/ precise-updates main restricted universe multiverse  
  9. deb-src http://mirrors.163.com/ubuntu/ precise-proposed main restricted universe multiverse  
  10. deb-src http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse  

保存後,更新源,執行sudo apt-get update即可。

然後修改“軟件和更新”中的源代碼下載的源,如上圖中的清華大學的源。

 

ubuntu 16.04下安裝和配置ros(ORB-SLAM-A)_第4张图片ubuntu 16.04下安裝和配置ros(ORB-SLAM-A)_第5张图片

4. 安裝ros

ubuntu 16.04下安裝和配置ros(ORB-SLAM-A)_第6张图片

4.1 添加ros源

打开一个控制台(Ctrl + Alt + T), 输入如下指令:

$ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

设置秘钥:

$ sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 0xB01FA11
然後執行sudo apt-get update刷新源的信息,否則後面就無法定位ros安裝包。

4.2 安裝ros系統

ROS kinetic 也有很多版本,這裏我們處於學習的目的,安裝完整版,即full版

sudo apt-get install ros-kinetic-desktop-full

報錯,如下:E 无法定位软件包 ros-kinetic-desktop-full,解決辦法:sudo apt-get update.

如果成功的話,會出現下圖所示的內容:

ubuntu 16.04下安裝和配置ros(ORB-SLAM-A)_第7张图片

需要下載500多MB的內容,剩下就是等待啦。根據網速的不同,等待的時間不等。

安装完成后,可以用下面的命令来查看可使用的包:

$ apt-cache search ros-kinetic

到现在,ros是安装完了,但是還不能使用。需要先進行初始化。

4.3 初始化ros系統

在开始使用ROS之前还需要初始化rosdep,它可以方便在需要编译某些源码的时候为其安装一些系统依赖,同时也是某些ROS核心功能组件所必需用到的工具。

$ sudo rosdep init
$ rosdep update

ubuntu 16.04下安裝和配置ros(ORB-SLAM-A)_第8张图片

然后初始化环境变量:

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

上面两句非常非常非常重要,很多小伙伴在日常的开发过程中,有的找不到 Package, 找不到node, 很多情况下都是没有添加source。

最后安装一个非常常用的插件:

$ sudo apt-get install python-rosinstall

好,到这里,所有安装就都完事啦。

为了保险,重启一下,测试一下ROS。

$ export | grep ROS

查看ROS相關環境變量是否設置成功。

ubuntu 16.04下安裝和配置ros(ORB-SLAM-A)_第9张图片

5. 配置ROS

5.1配置setup.bash

將/opt/ros/kinetic/setup.bash添加到bashrc中,以便於直接快速啓動相關命令,

source /opt/ros//setup.bash

ubuntu 16.04下安裝和配置ros(ORB-SLAM-A)_第10张图片

 

source /opt/ros/kinetic/setup.bash

5.2 創建ROS的工作空間

 

下面我们开始创建一个catkin 工作空间:

$ mkdir -p ~/catkin_ws/src

$ cd ~/catkin_ws/src

即使这个工作空间是空的(在'src'目录中没有任何软件包,只有一个CMakeLists.txt链接文件),你依然可以编译它: 

$ cd ~/catkin_ws/

$ catkin_make

catkin_make命令在catkin 工作空间中是一个非常方便的工具。如果你查看一下当前目录应该能看到'build'和'devel'这两个文件夹。在'devel'文件夹里面你可以看到几个setup.*sh文件。source这些文件中的任何一个都可以将当前工作空间设置在ROS工作环境的最顶层,想了解更多请参考catkin文档。接下来首先source一下新生成的setup.*sh文件:

$ source devel/setup.bash

要想保证工作空间已配置正确需确保ROS_PACKAGE_PATH环境变量包含你的工作空间目录,采用以下命令查看:

$ echo $ROS_PACKAGE_PATH

顯示爲:/home/oldking/catkin_ws/src:/opt/ros/kinetic/share

到此你的工作环境已经搭建完成,接下来可以学习 ROS文件系统教程.

 

附注释

ubuntu@ubuntu-System-Product-Name:~$ apt-cache search ros-kinetic
ros-kinetic-abb - ROS-Industrial support for ABB manipulators (metapackage).
ros-kinetic-abb-driver - ROS-Industrial nodes for interfacing with ABB robot controllers.
ros-kinetic-abb-irb2400-moveit-config - MoveIt package for the ABB IRB 2400.
ros-kinetic-default-cfg-fkie - The configuration node loads a given launch configuration and offers services to list or start the contained nodes.
ros-kinetic-delphi-esr-msgs - Message definitions for the Delphi ESR
ros-kinetic-delphi-srr-msgs - Message definitions for the Delphi SRR
ros-kinetic-dense-laser-assembler - Stores streaming data from a laser sensor in a dense representation.
ros-kinetic-zeroconf-msgs - General ros communications used by the various zeroconf implementations.
********************


 

你可能感兴趣的:(Linux,Ubuntu,SLAM)