ORB SLAM2在Ubuntu 16.04上的运行配置

时间:2022-08-30 17:42:30

http://www.mamicode.com/info-detail-1773781.html

安装依赖

安装OpenGL

1. 安装opengl Library
$sudo apt-get install libgl1-mesa-dev
2. 安装opengl utility
$sudo apt-get install libglu1-mesa-dev
3. 安装opengl utility toolkit
$sudo apt-get install freeglut3-dev

安装GLEW

$sudo apt-get install libglew-dev

安装boost

$sudo apt-get install libboost-dev libboost-thread-dev libboost-filesystem-dev

安装编译基础库

$sudo apt-get install build-essential

安装Pangolin

1. 下载链接:https://github.com/stevenlovegrove/Pangolin
注:可以使用git进行clone,也可以直接download zip

2. 编译安装步骤
$cd Pangolin
$mkdir build
$cd build
$cmake ..
$make
$sudo make install
$make doc (生成文档)

安装OpenCV

必选依赖:sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
可选依赖:sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
源码下载链接:http://opencv.org/downloads.html (选择2.4.xx,3.x.xx版本都可以,新版本的ORBSLAM2已经支持OpenCV3.xx.xx)
编译安装步骤(以OpenCV2.4.xx为例):
$cd opencv-2.4.xx
$mkdir build
$cd build
$cmake ..
$make
$sudo make install

安装Eigen3

源码下载地址:http://eigen.tuxfamily.org/index.php?title=Main_Page
安装依赖:sudo apt-get install libxmu-dev libxi-dev
编译安装步骤:
$cd eigen
$mkdir build
$cd build
$cmake ..
$make
$sudo make install

安装BLAS and LAPACK库

sudo apt-get install libblas-dev
sudo apt-get install liblapack-dev

编译ORB SLAM2

1. 下载源码

git clone https://github.com/raulmur/ORB_SLAM2.git ORB_SLAM2

2. 编译

$cd ORB_SLAM2
$chmod +x build.sh
$./build.sh

3. 16.04上编译错误解决

1) OpenCV找不到

错误信息:

Configuring and building Thirdparty/DBoW2 ...
mkdir: cannot create directory ‘build’: File exists
-- OpenCV ARCH: 
-- OpenCV RUNTIME: 
-- OpenCV STATIC: OFF
CMake Warning at /home/melanie/tools/opencv-2.4.13/cmake/OpenCVConfig.cmake:163 (message):
Found OpenCV Windows Pack but it has not binaries compatible with your
configuration.

You should manually point CMake variable OpenCV_DIR to your build of OpenCV
library.
Call Stack (most recent call first):
CMakeLists.txt:27 (find_package)

CMake Error at CMakeLists.txt:27 (find_package):
Found package configuration file:

/home/melanie/tools/opencv-2.4.13/cmake/OpenCVConfig.cmake

but it set OpenCV_FOUND to FALSE so package "OpenCV" is considered to be
NOT FOUND.

-- Configuring incomplete, errors occurred!
See also "/home/melanie/source/SmartCar/ORM_SLAM2/ORB_SLAM2/Thirdparty/DBoW2/build/CMakeFiles/CMakeOutput.log".
make: *** No targets specified and no makefile found. Stop.

解决方案:
因为我的OpenCV用源码编译安装的路径默认是/usr/local/share/OpenCV/,所以在这里手动给cmake指定OpenCV的路径
修改build.sh如下:
cd Thirdparty/DBoW2
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DOpenCV_DIR=/usr/local/share/OpenCV/
make

2)强制类型转换问题

错误信息:

/home/melanie/tools/eigen/Eigen/src/Core/AssignEvaluator.h:817:3: error: static assertion failed: YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY
EIGEN_CHECK_BINARY_COMPATIBILIY(Func,typename ActualDstTypeCleaned::Scalar,typename Src::Scalar);
^
CMakeFiles/ORB_SLAM2.dir/build.make:350: recipe for target ‘CMakeFiles/ORB_SLAM2.dir/src/Optimizer.cc.o‘ failed
make[2]: *** [CMakeFiles/ORB_SLAM2.dir/src/Optimizer.cc.o] Error 1
CMakeFiles/Makefile2:178: recipe for target ‘CMakeFiles/ORB_SLAM2.dir/all‘ failed
make[1]: *** [CMakeFiles/ORB_SLAM2.dir/all] Error 2
Makefile:83: recipe for target ‘all‘ failed
make: *** [all] Error 2

解决方案:

打开Thirdparty/g2o/g2o/solvers/linear_solver_eigen.h,将以下代码
template <typename MatrixType>
class LinearSolverEigen: public LinearSolver<MatrixType>
{
public:
typedef Eigen::SparseMatrix<double, Eigen::ColMajor> SparseMatrix;
typedef Eigen::Triplet<double> Triplet;
typedef Eigen::PermutationMatrix<Eigen::Dynamic, Eigen::Dynamic, SparseMatrix::Index> PermutationMatrix;

修改为:

template <typename MatrixType>
class LinearSolverEigen: public LinearSolver<MatrixType>
{
public:
typedef Eigen::SparseMatrix<double, Eigen::ColMajor> SparseMatrix;
typedef Eigen::Triplet<double> Triplet;
typedef Eigen::PermutationMatrix<Eigen::Dynamic, Eigen::Dynamic, int> PermutationMatrix;

3)usleep未定义:

错误信息:

/home/melanie/source/SmartCar/ORM_SLAM2/ORB_SLAM2/src/Viewer.cc:159:28: error: ‘usleep’ was not declared in this scope
usleep(3000);
^
CMakeFiles/ORB_SLAM2.dir/build.make:494: recipe for target ‘CMakeFiles/ORB_SLAM2.dir/src/Viewer.cc.o‘ failed
make[2]: *** [CMakeFiles/ORB_SLAM2.dir/src/Viewer.cc.o] Error 1
CMakeFiles/Makefile2:178: recipe for target ‘CMakeFiles/ORB_SLAM2.dir/all‘ failed
make[1]: *** [CMakeFiles/ORB_SLAM2.dir/all] Error 2
Makefile:83: recipe for target ‘all‘ failed
make: *** [all] Error 2

解决方案:

在source文件的开头增加include
#include <unistd.h>

需要增加unistd.h的文件有:
Examples/Monocular/mono_euroc.cc
Examples/Monocular/mono_kitti.cc
Examples/Monocular/mono_tum.cc
Examples/RGB-D/rgbd_tum.cc
Examples/Stereo/stereo_euroc.cc
Examples/Stereo/stereo_kitti.cc
src/LocalMapping.cc
src/LoopClosing.cc
src/System.cc
src/Tracking.cc
src/Viewer.cc

4) CUDA错误

安装了CUDA的机器编译的时候会出现CUDA相关错误,修改build.sh如下:
cd Thirdparty/DBoW2
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DOpenCV_DIR=/usr/local/share/OpenCV/ -DCUDA_USE_STATIC_CUDA_RUNTIME=OFF
make -j
......
echo "Configuring and building ORB_SLAM2 ..."

mkdir build
cd build
-cmake .. -DCMAKE_BUILD_TYPE=Release
+cmake .. -DCMAKE_BUILD_TYPE=Release -DCUDA_USE_STATIC_CUDA_RUNTIME=OFF
make -j

ORB SLAM2在Ubuntu 16.04上的运行配置的更多相关文章

  1. Ubuntu 16&period;04上安装并配置Postfix作为只发送SMTP服务器

    如果大家已经在使用第三方邮件服务方案发送并收取邮件,则无需运行自己的邮件服务器.然而,如果大家管理一套云服务器,且其中安装的应用需要发送邮件通知,那么运行一套本地只发送SMTP服务器则更为理想. 如何 ...

  2. Ubuntu 16&period;04上thunderbird配置163邮箱出现&OpenCurlyDoubleQuote;配置无法被验证-请查看用户名或密码是否正确?”

    在Ubuntu 16.04 上用thunderbird配置163免费邮箱时出现的提示信息如图1: 图1 提示信息 网上有不少方法都说是将接收和发出的主机名分别改为 imap.ym.163.com 和 ...

  3. 如何在Ubuntu 16&period;04上安装配置Redis

    如何在Ubuntu 16.04上安装配置Redis Redis是一个内存中的键值存储,以其灵活性,性能和广泛的语言支持而闻名.在本指南中,我们将演示如何在Ubuntu 16.04服务器上安装和配置Re ...

  4. 在 Ubuntu 16&period;04上安装 vsFTPd

    在 Ubuntu 16.04上安装 vsFTPd Ubuntu vsFTPd 关于 vsFTPd vsFTPd 代表 Very Secure File Transfer Protocol Daemon ...

  5. (译)综合指南:通过Ubuntu 16&period;04上从Source构建来安装支持GPU的Caffe2

    (译)综合指南:通过Ubuntu 16.04上从Source构建来安装支持GPU的Caffe2 译者注: 原文来自:https://tech.amikelive.com/node-706/compre ...

  6. &lbrack;eShopOnContainers 学习系列&rsqb; - 03 - 在远程 Ubuntu 16&period;04 上配置开发环境

    直接把 md 粘出来了,博客园的富文本编辑器换成 markdown,没啥效果呀 ,先凑合吧.实在不行换地方   # 在远程 Ubuntu 16.04 上配置开发环境 ## 零.因 为什么要用这么麻烦的 ...

  7. 在 Ubuntu 16&period;04 上安装 Eclipse Oxygen

    2017 年 6 月 28 日,Eclipse 社区(the Eclipse Community)发布了 Eclipse Oxygen.本文记录了我在 Ubuntu 16.04 上安装 Eclipse ...

  8. Ubuntu 16&period;04上安装SkyEye及测试

    说明一下,在Ubuntu 16.04上安装SkyEye方法不是原创,是来自互联网,仅供学习参考. 一.检查支持软件包 gcc,make,vim(optional),ssh,subversionbinu ...

  9. 如何在Ubuntu 16&period;04上安装Apache Web服务器

    转载自:https://www.howtoing.com/how-to-install-the-apache-web-server-on-ubuntu-16-04 介绍 Apache HTTP服务器是 ...

随机推荐

  1. 了解开源的许可证GPL、LGPL、BSD、Apache 2&period;0的区别 【转】

    原文来自:http://blog.sina.com.cn/s/blog_6870d1e00100lhlv.html 你对开源有多少了解呢?如果你是软件开发者,要开源软件,不单单是开放源代码就可以了,选 ...

  2. vue 使用总结

    1.Vuejs组件 vuejs构建组件使用 Vue.component('componentName',{ /*component*/ }): 这里注意一点,组件要先注册再使用,也就是说: Vue.c ...

  3. Spring data redis的一个bug

    起因 前两天上线了一个新功能,导致线上业务的缓存总是无法更新,报错也是非常奇怪,redis.clients.jedis.exceptions.JedisConnectionException: Unk ...

  4. json 的循环输出

    json不能用for-of循环,会报错 可以用for-in循环: var json = {'a':'apple','b':'banana','c':'orange','d':'pear'}; for( ...

  5. Java并发编程(五)锁的使用(下)

    显式锁 上篇讲了使用synchronized关键字来定义锁,其实Java除了使用这个关键字外还可以使用Lock接口及其实现的子类来定义锁,ReentrantLock类是Lock接口的一个实现,Reen ...

  6. Maven 的这 7 个问题你思考过没有?

    在如今的互联网项目开发当中,特别是Java领域,可以说Maven随处可见.Maven的仓库管理.依赖管理.继承和聚合等特性为项目的构建提供了一整套完善的解决方案,可以说如果你搞不懂Maven,那么一个 ...

  7. Docker 部署Gitlab

    sudo docker run -d \ -h 192.168.16.88 \ -p 89:80 -p 23:22 \ --name gitlab \ --restart always \ --vol ...

  8. 遇到后缀名为whl的库的安装方法

    直接把whl文件改成zip文件,解压到site-packages里面,其中site-packages文件夹位于例如我的位置是e:/python34/lib/sit-packages即可,然后就可以用i ...

  9. C&plus;&plus; 多用户模式下同一个exe只能运行一次

    1.有时候会遇到多用户模式下一不小心会运行多个exe的问题,所以程序中添加一下代码解决这个问题: BOOL CtestDialogApp::InitInstance() { char exeFullP ...

  10. CentOS7&period;2安装RabbitMQ笔记

    身为.NET程序员,用着宇宙级IDE,干什么事都变得越来越懒了,Windows操作系统在手,能通过桌面点点点的方式何必找其他罪受呢..于是RabbitMQ自然而然也就跑在Windows上了,说实话Wi ...