Ubuntu配置ORB-SLAM2過程當中的問題

https://www.imooc.com/article/details/id/29136python

1. 提示「CMAKE_CXX_COMPILER-NOTFOUNDlinux

具體形式:c++

Check for working CXX compiler: CMAKE_CXX_COMPILER-NOTFOUND sql

CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.express

Please set CMAKE_CXX_COMPILER to a valid compiler path or name.ubuntu

解決方法:bash

sudo apt-get install g++
2.(1)在ubuntu18.04系統上安裝opencv可是在安裝依賴包的過程當中,有一個依賴包,libjasper-dev在使用命令ui

sudo apt-get install libjaster-devthis

提示:沒法定位軟件包 libjasper-devgoogle

後來google到解決辦法,複製到這裏

sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
sudo apt update
sudo apt install libjasper1 libjasper-dev

成功的解決了問題,其中libjasper1是libjasper-dev的依賴包

(2)提示「ROS / OpenCV Ubuntu安裝「usr/include/c++/6/cstdlib:75:25: fatal error: stdlib.h: 沒有那個文件或目錄」」

解決辦法:

預編譯的問題,在編譯前加入命令屏蔽預編譯就好了

-D ENABLE_PRECOMPILED_HEADERS=OFF

3. 注意eigen 本人親測Eigen3.2.10

wget https://bitbucket.org/eigen/eigen/get/3.2.10.tar.bz2
tar -xjf 3.2.10.tar.bz2

改文件夾名字

cd eigen
mkdir build
cd build
cmake ..
make
sudo make install

4. ImportError: No module named catkin_pkg.package

注意Python版本 ros-melodic對應Python3

5. 編譯安裝python3.7時

提示「ModuleNotFoundError: No module named '_ctypes'

解決辦法

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get install build-essential python-dev python-setuptools python-pip python-smbus
sudo apt-get install build-essential libncursesw5-dev libgdbm-dev libc6-dev
sudo apt-get install zlib1g-dev libsqlite3-dev tk-dev
sudo apt-get install libssl-dev openssl
sudo apt-get install libffi-dev

安裝完libffi後在編譯安裝就不報錯了

6. 編譯./build_ros.sh

提示[rosbuild] rospack found package "ORB_SLAM2" at "", but the current   directory is "/home/angelo/ORB_SLAM2/Examples/ROS/ORB_SLAM2".  You should   double-check your ROS_PACKAGE_PATH to ensure that packages are found in the   correct precedence order.

解決辦法:輸入

sudo ln -s ~/ORB_SLAM2/Examples/ROS/ORB_SLAM2 /opt/ros/<ros版本名>/share/ORB_SLAM2

7. 編譯遇到找不到#include<Eigen/Dense>

解決辦法:進入usr/local/include/eigen3將eigen3中的Eigen文件遞歸地複製到上一層文件夾(直接放到include):由於在不少程序中include時常用#include <Eigen/Dense>而不是使用的#include <eigen3/Eigen/Dense>因此要作下處理,不然一些程序在編譯時會因找不到Eigen/Dense而報錯。

8. 編譯遇到libboost_system.so: 沒法添加符號: DSO missing from command line

解決辦法:在Examples/ROS/ORB_SLAM2/Cmakelist.txt 的文件後面加入兩句話:

target_link_libraries(Stereo boost_system boost_filesystem) 
target_link_libraries(RGBD boost_system boost_filesystem)

9.安裝Opencv的時候

提示

CMake Error at cmake/OpenCVDetectCXXCompiler.cmake:85 (list):

list GET given empty list

Call Stack (most recent call first):

CMakeLists.txt:109 (include)

CMake Error at cmake/OpenCVDetectCXXCompiler.cmake:86 (list):

list GET given empty list

Call Stack (most recent call first):

CMakeLists.txt:109 (include)

CMake Error at cmake/OpenCVDetectCXXCompiler.cmake:89 (math):

math cannot parse the expression: "*100 + ": syntax error, unexpected

exp_TIMES, expecting exp_OPENPARENT or exp_NUMBER (1)

Call Stack (most recent call first):

CMakeLists.txt:109 (include)

 解決辦法:

在文件opencv/cmake/OpenCVDetectCXXCompiler.cmake中,將「dumpversion」改成「dumpfullversion」

10.編譯ORB_SLAM2_ROS時

①提示如下錯誤:

/usr/bin/ld: CMakeFiles/Stereo.dir/src/ros_stereo.cc.o: undefined reference to symbol '_ZN5boost6system15system_categoryEv'
/usr/lib/x86_64-linux-gnu/libboost_system.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

解決方案:

將libboost_system.so與libboost_filesystem.so複製到ORB_SLAM2/lib下

locate boost_system locate boost_filesystem

而且將ORBSLAM2/Examples/ROS/ORBSLAM2下的Cmakelists.txt中加入庫目錄,具體爲 

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 ${PROJECT_SOURCE_DIR}/../../../lib/libboost_filesystem.so ${PROJECT_SOURCE_DIR}/../../../lib/libboost_system.so )

 ②提示如下內容

[rosbuild] rospack found package "ORB_SLAM2" at "", but the current directory is "/home/angelo/ORB_SLAM2/Examples/ROS/ORB_SLAM2". You should double-check your ROS_PACKAGE_PATH to ensure that packages are found in the correct precedence order.
Call Stack (most recent call first):
/opt/ros/kinetic/share/ros/core/rosbuild/public.cmake:177 (_rosbuild_check_package_location)
CMakeLists.txt:4 (rosbuild_init)

解決辦法:

這一般是由於沒有設置好 ORB_SLAM2 的環境變量或者先後設置存在衝突。請打開 ~/.bash.rc 文件,檢查如下設置是否正確:

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

 11.提示

error: static assertion failed: YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY

解決方法:

打開Thirdparty/g2o/g2o/solvers/linear_solver_eigen.h

typedef Eigen::PermutationMatrix<Eigen::Dynamic, Eigen::Dynamic, SparseMatrix::Index> PermutationMatrix;
改爲
typedef Eigen::PermutationMatrix<Eigen::Dynamic, Eigen::Dynamic, int> PermutationMatrix;

 12.編譯Build時,出現如下錯誤

../lib/libORB_SLAM2.so:對‘ORB_SLAM2::Frame::InitializeScaleLevels()’未定義的引用      collect2: error: ld returned 1 exit status     CMakeFiles/mono_kitti.dir/build.make:125: recipe for target '../Examples/Monocular/mono_kitti' failed

解決方法:將/ORB_SLAM2/src/Frame.cc中"inlier void Frame::InitializeScaleLeve " to " void Frame::InitializeScaleLevels()"

13.編譯Build時,出現如下錯誤

error: ‘FAST’ was not declared in this scope
                 FAST(cellImage,cellKeyPoints[i][j],fastTh,true);
                                                               ^

解決方法:在src/ORBextractor.cc中添加

#include <opencv2/opencv.hpp>

14.遇到

Could not find a configuration file for package "OpenCV" that is compatible
with requested version "2.4.3".

解決辦法:

將~/ORB_SLAM2/Examples/ROS/ORB_SLAM2中CMakeLists.txt的

find_package(OpenCV 2.3.9 REQUIRED) > find_package(OpenCV 3.2.0 REQUIRED)
相關文章
相關標籤/搜索