ORB SLAM2 Run configuration on Ubuntu 16.04

Source: Internet
Author: User
Tags create directory scalar usleep git clone

Install dependent installation OpenGL

1. Installing the OpenGL Library
$sudo Apt-get Install Libgl1-mesa-dev
2. Install OpenGL Utility
$sudo Apt-get Install Libglu1-mesa-dev
3. Install OpenGL Utility Toolkit
$sudo Apt-get Install Freeglut3-dev

Installing Glew

$sudo Apt-get Install Libglew-dev

Install boost

$sudo apt-get Install Libboost-dev Libboost-thread-dev Libboost-filesystem-dev

Install the build base library

$sudo Apt-get Install Build-essential

Installing Pangolin

1. Download Link: Https://github.com/stevenlovegrove/Pangolin
Note: You can use Git for clone, or you can directly download zip

2. Compiling the installation steps
$CD Pangolin
$mkdir Build
$CD Build
$cmake:
$make
$sudo make Install
$make doc (Generate document)

Installing OPENCV

Required dependencies: sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev Libswscale-dev
Optional dependencies: sudo apt-get install Python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev Libtiff-dev Libjasper-dev Lib Dc1394-22-dev
SOURCE Download Link: http://opencv.org/downloads.html (select 2.4.xx,3.x.xx version can be, the new version of the ORBSLAM2 has been supported OpenCV3.xx.xx)
Compile the installation steps (take opencv2.4.xx as an example):
$CD opencv-2.4.xx
$mkdir Build
$CD Build
$cmake:
$make
$sudo make Install

Installing Eigen3

Source: Http://eigen.tuxfamily.org/index.php?title=Main_Page
Installation dependency: sudo apt-get install Libxmu-dev Libxi-dev
To compile the installation steps:
$CD Eigen
$mkdir Build
$CD Build
$cmake:
$make
$sudo make Install

Installing Blas and LAPACK libraries

sudo apt-get install Libblas-dev
sudo apt-get install Liblapack-dev

Compile The Orb SLAM21. Download source code

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

2. Compiling

$CD orb_slam2
$chmod +x build.sh
$./build.sh

3.16.04 on Compile Error resolution 1) OPENCV not found

Error message:

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 had not binaries compatible with your
Configuration.

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 the package "OpenCV" was 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.

Solution:
Because my OpenCV the path that is installed by the source code compiles the default is the/usr/local/share/opencv/, so here manually assigns the OpenCV path to the CMake
Modify the build.sh as follows:
CD Thirdparty/dbow2
mkdir Build
CD Build
CMake. -dcmake_build_type=release -dopencv_dir=/usr/local/share/opencv/
Make

2) Forced type conversion problem

Error message:

/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

Solution:

Open Thirdparty/g2o/g2o/solvers/linear_solver_eigen.h, and the following code
Template <typename matrixtype>
Class Linearsolvereigen:public Linearsolver<matrixtype>
{
Public
typedef eigen::sparsematrix<double, eigen::colmajor> Sparsematrix;
typedef eigen::triplet<double> Triplet;
typedef Eigen::P Ermutationmatrix<eigen::D ynamic, Eigen::D ynamic, sparsematrix::index> Permutationmatrix;

Modified to:

Template <typename matrixtype>
Class Linearsolvereigen:public Linearsolver<matrixtype>
{
Public
typedef eigen::sparsematrix<double, eigen::colmajor> Sparsematrix;
typedef eigen::triplet<double> Triplet;
typedef Eigen::P Ermutationmatrix<eigen::D ynamic, Eigen::D ynamic, int> Permutationmatrix;

3) Usleep Not defined:

Error message:

/home/melanie/source/smartcar/orm_slam2/orb_slam2/src/viewer.cc:159:28:error: ' Usleep ' is 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

Solution:

Add include at the beginning of the source file
#include <unistd.h>

Files that require additional unistd.h are:
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 Error

Cuda-related errors occur when a Cuda-installed machine is compiled, and the modified build.sh are as follows:
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 Run configuration on Ubuntu 16.04

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.