Ubuntu14.04下配置LSD-SLAM

本文记录了LSD-SLAM在Ubuntu14.04下的安装过程。
安装环境:

  1. Trusty (Ubuntu 14.04) amd64
  2. ROS Indigo Igloo
  3. ORB-SLAM

文章目录


##1 准备工作##
首先,安装若干必备工具:

#sudo apt-get install vim git cmake -y

接下来将安装 ROS Indigo Igloo

##2 ROS Indigo Igloo 的安装和配置##
下面我将给出 ROS Indigo Igloo 在 Trusty (Ubuntu 14.04) 上的安装和测试过程。
点击[这里](http://wiki.ros.org/indigo/Installation/Ubuntu/“optional title here”),查看 ROS 官网的 ROS Indigo Igloo 安装手册。
###2.1 配置Ubuntu软件中心###
配置Ubuntu要求允许接受"restricted," “universe,” and "multiverse."的软件源,可以根据下面的链接配置:
https://help.ubuntu.com/community/Repositories/Ubuntu

一般地,这是系统默认设置,如下图所示:

ROS Indigo ONLY supports Saucy (Ubuntu13.10) and Trusty (Ubuntu14.04) for debian packages.这里写图片描述

###2.2 设置sources.list(软件源)###
设置你的计算机从packages.ros.org接收软件包。

添加ROS官方软件源:

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

一般地,ROS官方源速度很慢或者连接不上,推荐使用清华 TUNA Mirror 。
设置清华大学TUNA源:

sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'

所有 [Mirrors](http://wiki.ros.org/ROS/Installation/UbuntuMirrors/“optional title here”)

###2.3 设置的密钥###

sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116

如果你在连接秘钥服务器时遇到问题,你可以在上面的命令中替换链接为hkp://pgp.mit.edu:80或者hkp://keyserver.ubuntu.com:80

###2.4 安装###
首先,更新Debian包索引

sudo apt-get update

If you are using Ubuntu Trusty 14.04.2 and experience dependency issues during the ROS installation, you may have to install some additional system dependencies.

Do not install these packages if you are using 14.04, it will destroy your X server:

sudo apt-get install xserver-xorg-dev-lts-trusty mesa-common-dev-lts-trusty libxatracker-dev-lts-trusty libopenvg1-mesa-dev-lts-trusty libgles2-mesa-dev-lts-trusty libgles1-mesa-dev-lts-trusty libgl1-mesa-dev-lts-trusty libgbm-dev-lts-trusty libegl1-mesa-dev-lts-trusty

Do not install the above packages if you are using 14.04, it will ***destroy*** your X server

Alternatively, try installing just this to fix dependency issues:

sudo apt-get install libgl1-mesa-dev-lts-trusty

For more information on this issue see this [answers.ros.org thread](http://answers.ros.org/question/203610/ubuntu-14042-unmet-dependencies/“optional title here”) or this [launchpad issue](https://bugs.launchpad.net/ubuntu/trusty/+source/mesa/+bug/1424059/“optional title here”)


X server is an application that manages one or more graphics displays and one or more input devices (keyboard, mouse, etc.) connected to the computer.

It works as a server and can run on the local computer or on another computer on the network. Services can communicate with the X server to display graphical interfaces and receive input from the user.

It’s worth noting, a common component used with an X server is the Window Manager, an application that manages the resizing and moving of windows and decorative elements of windows such as title bars, minimize, and close buttons.

The X server can be started with the ‘startx’ command, or more commonly, from a display manager such as gdm.

  • ~/.xinitrc is a shell script used by xinit, that starts the X server when not using a display manager, to define some application to start automatically in the X server.
  • /etc/X11/xorg.conf is a configuration file used to give the X server information about the hardware components used, but now the X server can avoid using it, because it is capable of autoconfiguring itself.

-在安装之前,请认真阅读上述引用。安装ROS完整版后可能会导致 X server 损坏,在重新启动Ubuntu后出现The system is running in low-graphics mode的错误,导致无法进入Ubuntu桌面。请尝试点击 [answers.ros.org thread](http://answers.ros.org/question/203610/ubuntu-14042-unmet-dependencies/“optional title here”) 或者 [launchpad issue](https://bugs.launchpad.net/ubuntu/trusty/+source/mesa/+bug/1424059/“optional title here”) 解决问题。

ROS含有多种库和工具。官网提供了4种默认配置的安装供你选择。你也可以依据自己需求进行个性化安装。


  • (1) 桌面完整版
    Desktop-Full Install: (Recommended) : ROS, rqt, rviz, robot-generic libraries, 2D/3D simulators and 2D/3D perception

Indigo uses Gazebo 2 which is the default version of Gazebo on Trusty and is recommended. If you would like to instead use a newer version of Gazebo (5, 6 or 7), refer to these instructions on the Gazebo site. Note that installing a newer version of Gazebo will require you to build dependent packages (such as turtlebot_gazebo) to be built from source. See also Using a specific Gazebo version with ROS.

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

  • (2) 桌面版
    Desktop Install: ROS, rqt, rviz, and robot-generic libraries
sudo apt-get install ros-indigo-desktop

  • (3) 基础版
    ROS-Base: (Bare Bones) ROS package, build, and communication libraries. No GUI tools.
sudo apt-get install ros-indigo-ros-base

  • (4) 个性化安装
    Individual Package: You can also install a specific ROS package (replace underscores with dashes of the package name):
sudo apt-get install ros-indigo-PACKAGE

PACKAGE指包的名称

e.g.

sudo apt-get install ros-indigo-slam-gmapping

搜索可用包:

apt-cache search ros-indigo

我们使用 Desktop-Full Install

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

###2.5 初始化 rosdep###
在使用ROS之前,我们需要首先初始化rosdeprosdep帮助你轻松地进行系统依赖项源码的编译和安装,并且它是ROS核心组件运行的必要成分。

sudo rosdep init

rosdep初始化后如下图,写入/etc/ros/rosdep/sources.list.d/20-default.list
这里写图片描述

更新ROS软件包

rosdep update

###2.6 设置环境###
使用apt-get方式在 Ubuntu上安装 ROS,在使用前需要激活/opt/ros/indigo/目录下的setup.bash文件来添加 ROS 环境变量。

我们安装的是ROS Indigo Igloo,命令如下:

source /opt/ros/indigo/setup.bash

在每次打开一个新的 shell 时,我们都需要使用上述命令激活setup.bash文件。这样很繁琐。
因此,可以添加 ROS 的环境变量,这样,当我们打开新的shell时,我们的bash会话中会自动添加环境变量。

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

source ~/.bashrc #(使环境变量设置立即生效)

Tips:
使用下面命令可以在不同的 ROS distribution (ROS 发行版)间切换

$ source /opt/ros/<distro>/setup.bash

使用 ROS distribution 的短名称替换 <distro>

如果我们想切换到 ROS Kinetic Kame :

$ source /opt/ros/kinetic/setup.bash

###2.7 安装 rosinstall###
rosinstall是 ROS 包中常用的命令行工具。它可以帮助我们轻松地下载许多 ROS 包源码并建立依赖关系,并且只需要一行命令。

sudo apt-get install python-rosinstall

其他的常用项

sudo apt-get install python-rosinstall-generator python-wstool -y

###2.8 测试 ROS ###
运行 roscore 是使用 ROS 的首要步骤。

roscore

我们可以看到

... logging to ~/.ros/log/9cf88ce4-b14d-11df-8a75-00251148e8cf/roslaunch-machine_name-13039.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://machine_name:33919/
ros_comm version 1.4.7

SUMMARY
======

PARAMETERS
 * /rosversion
 * /rosdistro

NODES

auto-starting new master
process[master]: started with pid [13054]
ROS_MASTER_URI=http://machine_name:11311/

setting /run_id to 9cf88ce4-b14d-11df-8a75-00251148e8cf
process[rosout-1]: started with pid [13067]
started core service [/rosout]

如图所示
这里写图片描述

说明 ROS 已经成功安装并配置

###2.9 创建 ROS 工作空间

有两种方式创建 ROS 工作空间:catkinrosbuild

  • ROS Groovy 以及更新的版本请使用 catkin
  • ROS Fuerte 以及以前的版本请使用 rosbuild

我们开始创建 catkin workspaces

mkdir -p ~/catkin_ws/src

cd ~/catkin_ws/

catkin_make

The catkin_make command is a convenience tool for working with catkin workspaces. Running it the first time in your workspace, it will create a CMakeLists.txt link in your ‘src’ folder. Additionally, if you look in your current directory you should now have a ‘build’ and ‘devel’ folder. Inside the ‘devel’ folder you can see that there are now several setup.*sh files. Sourcing any of these files will overlay this workspace on top of your environment. To understand more about this see the general catkin documentation: catkin. Before continuing source your new setup.*sh file:

source devel/setup.bash

To make sure your workspace is properly overlayed by the setup script, make sure ROS_PACKAGE_PATH environment variable includes the directory you’re in.

slam1a@slam1a-vm:~/catkin_ws$ echo $ROS_PACKAGE_PATH

/home/slam1a/catkin_ws/src:/opt/ros/indigo/share:/opt/ros/indigo/stacks

出现上述结果,说明我们的 catkin workspaces 已经创建好了,并且 ROS_PACKAGE_PATH也已经配置好了。

接下来的所有工作都在 ~/catkin_ws/src 目录下完成,即在 catkin workspaces

=======================================================

##3 ORB-SLAM依赖项的安装##
除了 ROS 外,ORB-SLAM 还依赖于其他若干第三方库:BoostOpenCVEigen3g2oDBoW2g2oDBoW2 已经包含在 ORB-SLAM 项目下的 Thirdparty/ 目录下。
下面我们将依次安装其它各第三方库。

###3.1 Boost###
使用 Boost 管理 ORB-SLAM 多线程。

sudo apt-get install libboost-all-dev

###3.2 OpenCV###
OpenCV 版本最低要求为2.4.3,建议采用 OpenCV 2.4.13 或者 OpenCV 3.2.0。
OpenCV 官网 或者 OpenCV GitHub 下载 OpenCV2.4.13。
也可以直接点击这里下载

然后安装依赖项:
安装编译工具

sudo apt-get install build-essential -y

安装依赖包

sudo apt-get install libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev -y

安装可选包

sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev -y

sudo apt-get install libgtk2.0-dev -y

sudo apt-get install pkg-config -y

进入 ~/catkin_ws/src

从GitHub下载opencv2.4.13,这不是一个 git repository,使用wget。
将下载的OpenCV解压~/catkin_ws/src目录下。

cd ~/catkin_ws/src

wget https://github.com/Itseez/opencv/archive/2.4.13.zip

unzip 2.4.13.zip

进入OpenCV的目录下。
编译安装OpenCV 2.4.13 源码。

cd opencv-2.4.13/

mkdir build

cd build

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local .. 

make

sudo make install

安装完毕。

下面进行测试。
测试实例

//文件名字lena.cpp
#include <stdio.h>
#include <opencv2/opencv.hpp>
using namespace cv;

int main( )
{
    Mat image;

    //按照自己的目录,或者将
    image = imread("lena.png", 1 );
    if ( !image.data )
    {
        printf("No image data \n");
        return -1;
    }
    namedWindow("Display Image", WINDOW_AUTOSIZE );
    imshow("Display Image", image);
    waitKey(0);
    return 0;
}

lena.png

将上述 lena.cpplena.png 文件放入同一目录下,编译

g++ lena.cpp -o lena.o  `pkg-config --cflags --libs opencv`

运行

./lena.o

效果如下
这里写图片描述

OpenCVC 已经成功安装。

###3.3 Eigen3###
最低要求版本为3.1.0。在http://eigen.tuxfamily.org 下载 Eigen3.2.10 压缩文件,并解压。

进入~/catkin_ws/src/

cd ~/catkin_ws/src/
wget https://bitbucket.org/eigen/eigen/get/3.2.10.tar.bz2
tar -xjf 3.2.10.tar.bz2

得到eigen-eigen-b9cd8366d4e8目录,重命名eigen-3.2.10

mv eigen-eigen-b9cd8366d4e8/ eigen-3.2.10

编译安装eigen3.2.10

cd eigen-3.2.10/

mkdir build

cd build

cmake ..

make

sudo make install

Eigen3.2.10 安装完毕

猜你喜欢

转载自blog.csdn.net/RadiantJeral/article/details/82664765
今日推荐