编译 ORB_SLAM2 (一)

时间:2022-12-27 21:36:35

之前有记录关于ORB_SLAM的第一个版本的编译,每次就是要编译程序,都会遇到很多问题,并不是所谓的按照教程来就一定能编译成功,所以这一次编译也遇到了很多问题。百度的时候也看到网上有很多相似的问题,但是也有很多还没有解决的问题,恰好的我也遇到了,并且解决了。

首先默认电脑环境ubuntu14.04和ROS indigo已经装好。

1. 安装Pangolin,用于可视化和用户接口

git clone https://github.com/stevenlovegrove/Pangolin.git

cd Pangolin

    mkdir build

    cd build

cmake -DCPP11_NO_BOOST=1 ..

    make -j

如果出现Could NOT find GLEW错误 ,就是要安装一些依赖项

就是sudo apt-get install 以下这些依赖项

libx11-dev libxmu-dev libglu1-mesa-dev libgl2ps-dev libxi-dev g++ libzip-dev libpng12-dev libcurl4-gnutls-dev libfontconfig1-dev libsqlite3-dev libglew*-dev libssl-dev

2.安装BLAS和LAPACK

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

3 构建ORB_SLAM2库

git clone https://github.com/raulmur/ORB_SLAM2.git ORB_SLAM2
cd ORB_SLAM2
chmod +x build.sh
./build.sh

问题(1)

可能会出现在./build.sh 这一步,如果出现的错误大部分是跟openni.h和XnCppWrapper.h有关的话,请看这位大神的博客是可以解决问题的

www.cnblogs.com/liufuqiang/p/5618335.html

问题(2)

如果在编译ORB_SLAM2时出现卡住的情况,无论怎么重新编译都会无法通过,网上也查不到关于卡住怎么办 的解决办法

http://tieba.baidu.com/p/4475718587就像这个贴吧里说的这样,只能ctrl+c,如如下图

编译   ORB_SLAM2 (一)

如果编译的过程中卡住了 解决办法:把make -j   改为make -l,看一下make的用法:

Usage: make [options] [target] ...
Options:
  -b, -m                      Ignored for compatibility.
  -B, --always-make           Unconditionally make all targets.
  -C DIRECTORY, --directory=DIRECTORY
                              Change to DIRECTORY before doing anything.
  -d                          Print lots of debugging information.
  --debug[=FLAGS]             Print various types of debugging information.
  -e, --environment-overrides
                              Environment variables override makefiles.
  -f FILE, --file=FILE, --makefile=FILE
                              Read FILE as a makefile.
  -h, --help                  Print this message and exit.
  -i, --ignore-errors         Ignore errors from commands.
  -I DIRECTORY, --include-dir=DIRECTORY
                              Search DIRECTORY for included makefiles.
  -j [N], --jobs[=N]          Allow N jobs at once; infinite jobs with no arg.
  -k, --keep-going            Keep going when some targets can't be made.
  -l [N], --load-average[=N], --max-load[=N]
                              Don't start multiple jobs unless load is below N.
  -L, --check-symlink-times   Use the latest mtime between symlinks and target.
  -n, --just-print, --dry-run, --recon
                              Don't actually run any commands; just print them.
  -o FILE, --old-file=FILE, --assume-old=FILE
                              Consider FILE to be very old and don't remake it.
  -p, --print-data-base       Print make's internal database.
  -q, --question              Run no commands; exit status says if up to date.
  -r, --no-builtin-rules      Disable the built-in implicit rules.
  -R, --no-builtin-variables  Disable the built-in variable settings.
  -s, --silent, --quiet       Don't echo commands.
  -S, --no-keep-going, --stop
                              Turns off -k.
  -t, --touch                 Touch targets instead of remaking them.
  -v, --version               Print the version number of make and exit.
  -w, --print-directory       Print the current directory.
  --no-print-directory        Turn off -w, even if it was turned on implicitly.
  -W FILE, --what-if=FILE, --new-file=FILE, --assume-new=FILE
                              Consider FILE to be infinitely new.
  --warn-undefined-variables  Warn when an undefined variable is referenced.
这样就编译成功,如图:

编译   ORB_SLAM2 (一)

4.编译生成ROS节点:根据read.md

在 ~/.bashrc添加路径

export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:PATH/ORB_SLAM2/Examples/ROS

然后进入“Examples/ROS/ORB_SLAM2:执行

mkdir build
                      cd build
                      cmake .. -DROS_BUILD_TYPE=Release
                      make -j

可能出现的错误就是在  cmake .. -DROS_BUILD_TYPE=Release         如下图

编译   ORB_SLAM2 (一)

意思是cv_bridge找不到opencv 的依赖项,即使把package.xml文件中的cv_bridge去除,虽然可以cmake成功,但是依赖项没有了。后面的make 也不能成功,

所以就把CMakefile.txt文件中

cmake_minimum_required(VERSION 2.4.)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake) rosbuild_init() IF(NOT ROS_BUILD_TYPE)
SET(ROS_BUILD_TYPE Release)
ENDIF() MESSAGE("Build type: " ${ROS_BUILD_TYPE}) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O3 -march=native ")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O3 -march=native") # Check C++ or C++0x support
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
add_definitions(-DCOMPILEDWITHC11)
message(STATUS "Using flag -std=c++11.")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
add_definitions(-DCOMPILEDWITHC0X)
message(STATUS "Using flag -std=c++0x.")
else()
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif() LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../../../cmake_modules) find_package(OpenCV 2.4. REQUIRED)
find_package(Eigen3 3.1. REQUIRED)
find_package(Pangolin REQUIRED) include_directories(
${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/../../../
${PROJECT_SOURCE_DIR}/../../../include
${Pangolin_INCLUDE_DIRS}
) set(LIBS
${OpenCV_LIBS}
${EIGEN3_LIBS}
${Pangolin_LIBRARIES}
${PROJECT_SOURCE_DIR}/../../../Thirdparty/DBoW2/lib/libDBoW2.so
${PROJECT_SOURCE_DIR}/../../../Thirdparty/g2o/lib/libg2o.so
${PROJECT_SOURCE_DIR}/../../../lib/libORB_SLAM2.so
) # Node for monocular camera
rosbuild_add_executable(Mono
src/ros_mono.cc
) target_link_libraries(Mono
${LIBS}
) # Node for stereo camera
rosbuild_add_executable(Stereo
src/ros_stereo.cc
) target_link_libraries(Stereo
${LIBS}
) # Node for RGB-D camera
rosbuild_add_executable(RGBD
src/ros_rgbd.cc
) target_link_libraries(RGBD
${LIBS}
)

改写为

cmake_minimum_required(VERSION 2.8.3)  #版本不同
project(orb_slam2)
find_package(catkin REQUIRED COMPONENTS
roscpp
sensor_msgs
image_transport
message_filters
cv_bridge
cmake_modules) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O3 -march=native ")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O3 -march=native")
# Check C++11 or C++0x support
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
add_definitions(-DCOMPILEDWITHC11)
message(STATUS "Using flag -std=c++11.")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
add_definitions(-DCOMPILEDWITHC0X)
message(STATUS "Using flag -std=c++0x.")
else()
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../../../cmake_modules)
find_package(OpenCV 2.4.3 REQUIRED)
find_package(Eigen3 3.1.0 REQUIRED)
find_package(Pangolin REQUIRED)
catkin_package()
include_directories(
${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/../../../
${PROJECT_SOURCE_DIR}/../../../include
${Pangolin_INCLUDE_DIRS}
)
set(LIBS
${catkin_LIBRARIES}
${OpenCV_LIBS}
${EIGEN3_LIBS}
${Pangolin_LIBRARIES}
${PROJECT_SOURCE_DIR}/../../../Thirdparty/DBoW2/lib/libDBoW2.so
${PROJECT_SOURCE_DIR}/../../../Thirdparty/g2o/lib/libg2o.so
${PROJECT_SOURCE_DIR}/../../../lib/libORB_SLAM2.so
)
# Node for monocular camera
add_executable(mono
src/ros_mono.cc
)
target_link_libraries(mono
${LIBS}
)
# Node for RGB-D camera
add_executable(rgbd
src/ros_rgbd.cc
)
target_link_libraries(rgbd
${LIBS}
)
# Node for stereo camera
add_executable(stereo
src/ros_stereo.cc
)
target_link_libraries(stereo
${LIBS}
)

把manifest.xml文件内容

<package>
<description brief="ORB_SLAM2"> ORB_SLAM2 </description>
<author>Raul Mur-Artal</author>
<license>GPLv3</license>
<depend package="roscpp"/>
<depend package="tf"/>
<depend package="sensor_msgs"/>
<depend package="image_transport"/>
<depend package="cv_bridge"/> </package>

删除改为package.xml  内容为

<package>
<name>orb_slam2</name>
<version>0.0.1</version>
<description>ORB_SLAM2</description>
<author>Raul Mur-Artal</author>
<maintainer email="raulmur@unizar.es">Raul Mur-Artal</maintainer>
<license>GPLv3</license>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>tf</build_depend>
<build_depend>sensor_msgs</build_depend>
<build_depend>image_transport</build_depend>
<build_depend>message_filters</build_depend>
<build_depend>cv_bridge</build_depend>
<build_depend>cmake_modules</build_depend>
<run_depend>roscpp</run_depend>
<run_depend>tf</run_depend>
<run_depend>sensor_msgs</run_depend>
<run_depend>image_transport</run_depend>
<run_depend>message_filters</run_depend>
<run_depend>cv_bridge</run_depend>
</package>

就可以编译成功,如果出现卡住,仍然换成make -l

编译   ORB_SLAM2 (一)

我只是记录下一些问题,大神请忽略

编译 ORB_SLAM2 (一)的更多相关文章

  1. ubuntu16&period;04下用笔记本摄像头和ROS编译运行ORB&lowbar;SLAM2的单目AR例程

    要编译ORB_SLAM2的ROS例程首先需要安装ROS,以及在ROS下安装usb_cam驱动并调用,最后搭建ORB_SLAM2. 1.ROS的安装 我的电脑安装的是ubuntu16.04系统,所以我安 ...

  2. ORB-SLAM2的编译运行以及TUM数据集测试

    ORB-SLAM2的编译运行以及TUM数据集测试 徐大徐 2018.02.06 17:04 字数 1838 阅读 2167评论 0喜欢 2 近段时间一直在学习高翔博士的<视觉SLAM十四讲&gt ...

  3. 软件篇-02-基于ZED 2和ORB&lowbar;SLAM2的SLAM实践

    时隔两周,我又回来了. ​ 本期内容如题,ZED 2的SDK功能还是挺多的,包括轨迹跟踪,实时建图等等.虽然由于是商业产品,我看不到他们的源代码,但是根据使用情况来看,ZED 2内部是采用了IMU和光 ...

  4. Ubuntu16&period;04&plus;Ros&plus;Usb&lowbar;Cam ORB SLAM2

    转载自:https://www.jianshu.com/p/dbf39b9e4617亲测可用 1.其中编译ORB_SLAM2的   ./build.sh 和 ./build_ros.sh之前需要修改文 ...

  5. ORB-SLAM2 运行 —— ROS &plus; Android 手机摄像头

    转载请注明出处,谢谢 原创作者:Mingrui 原创链接:https://www.cnblogs.com/MingruiYu/p/12404730.html 本文要点: ROS 配置安装 解决 sud ...

  6. ORB&lowbar;SLAM3 -- 配置安装

    安装环境 Ubuntu20.04 ORB_SLAM3依赖项安装 opencv3 ORB_SLAM3可用opencv3或opencv4编译,作者这里安装测试了opencv3 Step1: 安装openc ...

  7. ORB&lowbar;SLAM2 Ubuntu16&period;04编译错误

    Ubuntu14.04一切正常,迁移到Ubuntu16.04后编译报错,提示: /usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h:745:3: ...

  8. ORB&lowbar;SLAM2之Pangolin的安装与问题处理

    前言 本篇博客中,我们主要介绍了在安装ORB_SLAM2所需的第三方库Pangolin的过程中遇到的一些问题及解决方法. 1.Pangolin是什么? Pangolin是一个用于OpenGL显示/交互 ...

  9. ORB&lowbar;SLAM2安装

    进入工程目录,我们发现有两个sh文件,一个是build.sh另一个是build_ros.sh. 这两个都可以进行ORB_SLAM2的安装,我们先来看一下build.sh echo "Conf ...

随机推荐

  1. jQuery DataTables &amp&semi;&amp&semi; Django serializer

    jQuery DataTables https://www.datatables.net 本文参考的官方示例 http://datatables.net/release-datatables/exam ...

  2. HTML5 文件异步上传 — h5uploader&period;js

    原文地址:http://imziv.com/blog/article/read.htm?id=62 之前写过一篇H5异步文件上传的文章, 但是很多朋友看着我的这个教程还是出现很多问题,文章写的不是很好 ...

  3. cmd命令行给main传参数

    int main(int argc, char **argv) { cout << "arguments passed to main() : " << e ...

  4. &amp&semi;&amp&semi;运算符和&vert;&vert;运算符的优先级问题

    package priority; public class TestAndOrPriority { /* * &&的优先级高就不代表 他会先运行 ||的右边 而是说会把右边用&amp ...

  5. VS 2013 编译和使用 Boost

    以 1.58.0 版本 boost 为例, 当前系统版本为 Windows 8.1 x64   1 编译boost  当前解压路径 "D:\Libraries\boost_1_58_0&qu ...

  6. 正则语言引擎:一个简单LEX和YACC结合运用的实例

    本文先描述了LEX与YACC的书写方法.然后利用LEX与YACC编写了一个简单正则语言的引擎(暂时不支持闭包与或运算),生成的中间语言为C语言. 正则引擎应直接生成NFA或DFA模拟器的输入文件,但在 ...

  7. google C&plus;&plus;编程风格指南之头文件的包括顺序

    google C++编程风格对头文件的包括顺序作出例如以下指示: (1)为了加强可读性和避免隐含依赖,应使用以下的顺序:C标准库.C++标准库.其他库的头文件.你自己project的头文件.只是这里最 ...

  8. 一、使用官方工具建立空springboot

          自己搭过springboot,看的官网,一点点自己弄,集成druid,做了些例子,从0到1弄了一下午. 当时没看到有工具可用,可以把依赖都加上,简称STS.       下载地址: htt ...

  9. 源码解读 Laravel PHP artisan config&colon;cache

    来源 https://laravel-china.org/articles/5101/source-code-reading-laravel-php-artisan-configcache 源码在哪 ...

  10. 关于egret&period;Tween传递参数的问题

    参考: setTimeOut传参数(转) setTimeout传参数 CSDN 一.延迟后执行,并输出参数 for(let i=0;i<10;i++){ egret.Tween.get(this ...