配置ORB_SLAM2常见错误

1.usleep未定义

解决方案:

在source文件的开头增加include
#include

需要增加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
(红色部分是必须要添加的,非红色看报错情况)

2.强制类型转换问题 

解决方案:

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

修改为:

template
class LinearSolverEigen: public LinearSolver
{
public:
typedef Eigen::SparseMatrix SparseMatrix;
typedef Eigen::Triplet Triplet;
typedef Eigen::PermutationMatrixint>

PermutationMatrix;

3.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/lib/OpenCV/,所以在这里手动给cmake指定OpenCV的路径
修改build.sh如下:
cd Thirdparty/DBoW2
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DOpenCV_DIR=/usr/local/lib/OpenCV/
make

 

你可能感兴趣的:(c++,slam)