之前有记录关于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,如如下图

如果编译的过程中卡住了 解决办法:把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.
这样就编译成功,如图:

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         如下图

意思是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 (一)的更多相关文章

  1. ubuntu16.04下用笔记本摄像头和ROS编译运行ORB_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十四讲> ...

  3. 软件篇-02-基于ZED 2和ORB_SLAM2的SLAM实践

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

  4. Ubuntu16.04+Ros+Usb_Cam ORB SLAM2

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

  5. ORB-SLAM2 运行 —— ROS + Android 手机摄像头

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

  6. ORB_SLAM3 -- 配置安装

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

  7. ORB_SLAM2 Ubuntu16.04编译错误

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

  8. ORB_SLAM2之Pangolin的安装与问题处理

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

  9. ORB_SLAM2安装

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

随机推荐

  1. Nginx反向代理实现Tomcat多个应用80端口访问

    应用背景 一般我们在开发时,一个工程里会有多个Web应用,比如一个前台一个后台,那我们就需要配置2个Tomcat服务器,比如一个是http://localhost:8080,一个是http://loc ...

  2. jquery 分页控件1

    jquery 分页控件(一) 以前一直都是用别人的分页控件,虽然用得很爽,但总觉的还是自己写个小插件比较好,这个插件效果.代码等都有参照别人完成的控件.即便功能并不是那么完善,扩展性也不好,bug或许 ...

  3. [google面试CTCI] 1-8.判断子字符串

    [字符串与数组] Q:Assume you have a method isSubstring which checks if one word is a substring of another G ...

  4. 使用Jquery+EasyUI进行框架项目开发案例讲解之一---员工管理源码分享

    使用Jquery+EasyUI进行框架项目开发案例讲解之一---员工管理源码分享 使用Jquery+EasyUI 进行框架项目开发案例讲解之一 员工管理源码分享    在开始讲解之前,我们先来看一下什 ...

  5. MySql数据库连接操作

    主要封装为MySqlHelper类 namespace CiWong.LearningLevelApi.MySqlHelp { /// <summary> /// MySqlHelper ...

  6. HDU 4618 - Palindrome Sub-Array(2013MUTC2-1008)(DP)

    d(i,j,k)表示左上角坐标为(i,j),k为正方形边长 d(i,j,k)=1,如果d(i+1,j+1,k-2)=0,且上下两个外围的相等且回文,左右两个外围的相等且回文:否则d(i,j,k)=0 ...

  7. jquery validate 验证

    JSP中引入 <link href="themes/gray/easyui.css" rel="stylesheet" type="text/c ...

  8. Java 多线程系列

    要编写线程安全的代码,其核心在于要对状态访问操作进行管理,特别是对共享的(Shared)和可变的(Mutable)状态的访问. Java中的主要同步机制是关键字synchronized,它提供了一种独 ...

  9. 进程间通讯之mmap文件共享

    进程间通讯之mmap文件共享 引文: 个人名言:“同一条河里淹死两次的人,是傻子,淹死三次及三次以上的人是超人”.经历过上次悲催的面试,决定沉下心来,好好的补充一下基础知识点.本文是这一系列第一篇:进 ...

  10. 【汇编语言】DEBUG的使用

    在masm for windows中,需要先生存exe文件,然后再点调试按钮. 常用的命令有: R命令:查看.改变CPU寄存器的内容:如果要修改某个寄存器的内容,可以在r的后面接上空格和寄存器名.如: ...