ubuntu16.04 下配置运行 PL-SLAM

近期阅读了文献:PL-SLAM: a Stereo SLAM System through the Combination of Points and Line Segments

发现作者已将代码开源,于是自己尝试着跑了下,具体的流程可以参考:https://blog.csdn.net/xs1102/article/details/80757404

这边主要总结自己在编译运行时踩到的坑:

主要分几个大块:

一.安装OpenCV+contrib:

1.1make过程中遇到:

In file included from /home/hlx/opencv-3.1.0/build/modules/python2/pyopencv_generated_include.h:11:0,
                 from /home/hlx/opencv-3.1.0/modules/python/src2/cv2.cpp:12:
/home/hlx/opencv-3.1.0/opencv_contrib-3.1.0/modules/hdf/include/opencv2/hdf/hdf5.hpp:40:18: fatal error: hdf5.h: 没有那个文件或目录
compilation terminated.
modules/python2/CMakeFiles/opencv_python2.dir/build.make:300: recipe for target 'modules/python2/CMakeFiles/opencv_python2.dir/__/src2/cv2.cpp.o' failed
make[2]: *** [modules/python2/CMakeFiles/opencv_python2.dir/__/src2/cv2.cpp.o] Error 1
CMakeFiles/Makefile2:15472: recipe for target 'modules/python2/CMakeFiles/opencv_python2.dir/all' failed
make[1]: *** [modules/python2/CMakeFiles/opencv_python2.dir/all] Error 2
make[1]: *** 正在等待未完成的任务....

解决方法:locate找到hdf5.h   
在/usr/include/hdf5/serial/hdf5.h
在opencv_contrib-3.1.0/modules/hdf/include/opencv2/hdf/hdf5.hpp 文件中修改第40行
将#include 修改成#include "/usr/include/hdf5/serial/hdf5.h" 

1.2make过程中遇到

LAPACKE_H_PATH-NOTFOUND/lapacke.h: 没有那个文件或目录

解决方式:
sudo apt-get install liblapacke-dev checkinstall
modify the 
#include "LAPACKE_H_PATH-NOTFOUND/lapacke.h"
 into 
#include "lapacke.h"
 and make, It works in my Ubuntu.

二.编译STVO-PL

在make的时候:

/home/hlx/stvo-pl-master/src/matching.cpp: In function ‘int StVO::matchNNR(const cv::Mat&, const cv::Mat&, float, std::vector&)’:
/home/hlx/stvo-pl-master/src/matching.cpp:47:79: error: no matching function for call to ‘cv::BFMatcher::create(cv::NormTypes, bool)’
 r bfm = cv::BFMatcher::create(cv::NORM_HAMMING, false); // cross
                                                                     ^
In file included from /home/hlx/stvo-pl-master/src/matching.cpp:34:0:
/usr/local/include/opencv2/features2d.hpp:936:43: note: candidate: static cv::Ptr cv::DescriptorMatcher::create(const cv::String&)
     CV_WRAP static Ptr create( const String& descriptorMatch
                                           ^
/usr/local/include/opencv2/features2d.hpp:936:43: note:   candidate expects 1 argument, 2 provided
CMakeFiles/stvo.dir/build.make:206: recipe for target 'CMakeFiles/stvo.dir/src/matching.cpp.o' failed
make[2]: *** [CMakeFiles/stvo.dir/src/matching.cpp.o] Error 1
CMakeFiles/Makefile2:99: recipe for target 'CMakeFiles/stvo.dir/all' failed
make[1]: *** [CMakeFiles/stvo.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

解决方法:

stvo中的matching的第47行会提示只需一个变量但提供俩,可改为下行代码:
cv::Ptr bfm = cv::BFMatcher::create("cv::NORM_HAMMING");

三.g2o问题

g2o不建议用最新的,因为pl-slam是使用低版本的头文件,新版本中,g2o的指针需要使用std::unique_ptr传递。

下了高博github上的g2o,编译过过程中出现的问题:
/home/hlx/g2o-master/g2o/types/slam2d/edge_se2_pointxy_bearing.cpp:50:52: error: no matching function for call to ‘g2o::SE2::setRotation(Eigen::Rotation2D::Scalar)’
.....
make[2]: *** [g2o/types/slam2d/CMakeFiles/types_slam2d.dir/edge_se2_pointxy_bearing.cpp.o] Error 1
CMakeFiles/Makefile2:802: recipe for target 'g2o/types/slam2d/CMakeFiles/types_slam2d.dir/all' failed
make[1]: *** [g2o/types/slam2d/CMakeFiles/types_slam2d.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

解决方法:

发现是eigen不兼容问题,就卸载了Eigen3.3后安装了eigen3.2.10,目前已解决

四.mrpt问题

 在编译的时候遇到问题:
 /home/hlx/mrpt/apps/ReactiveNavigationDemo/reactive_navigator_demoMain.cpp:1042:102: error: ‘wxTE_AUTO_SCROLL’ was not declared in this scope

解决方法:

这是因为wxWeights高版本去掉了改定义,在头文件定义即可:
在reactive_navigator_demoMain.h文件中加入
#ifndef wxTE_AUTO_SCROLL
#define wxTE_AUTO_SCROLL 0
#endif

五.stvo问题:

5.1重装了Eigen和OpenCV之后,编译stvo的时候遇到了问题:
/home/hlx/stvo-pl-master/src/matching.cpp: In function ‘int StVO::matchNNR(const cv::Mat&, const cv::Mat&, float, std::vector&)’:
/home/hlx/stvo-pl-master/src/matching.cpp:47:79: error: no matching function for call to ‘cv::BFMatcher::create(cv::NormTypes, bool)’
 r bfm = cv::BFMatcher::create(cv::NORM_HAMMING, false); // cross
                                                                     ^
In file included from /home/hlx/stvo-pl-master/src/matching.cpp:34:0:
/usr/local/include/opencv2/features2d.hpp:936:43: note: candidate: static cv::Ptr cv::DescriptorMatcher::create(const cv::String&)
     CV_WRAP static Ptr create( const String& descriptorMatch
                                           ^
/usr/local/include/opencv2/features2d.hpp:936:43: note:   candidate expects 1 argument, 2 provided
CMakeFiles/stvo.dir/build.make:206: recipe for target 'CMakeFiles/stvo.dir/src/matching.cpp.o' failed
make[2]: *** [CMakeFiles/stvo.dir/src/matching.cpp.o] Error 1
CMakeFiles/Makefile2:99: recipe for target 'CMakeFiles/stvo.dir/all' failed
make[1]: *** [CMakeFiles/stvo.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

解决方法:
1.stvo中的matching的第47行会提示只需一个变量但提供俩,可改为下行代码:
 cv::Ptr bfm = cv::BFMatcher::create("cv::NORM_HAMMING"); // cross-check

六.编译的时候:

make的时候:
hlx@hlx-To-be-filled-by-O-E-M:~/pl-slam-master/build$ make
Scanning dependencies of target plslam
[ 12%] Building CXX object CMakeFiles/plslam.dir/src/mapHandler.cpp.o
In file included from /usr/local/include/g2o/config.h:18:0,
                 from /usr/local/include/g2o/types/slam3d/vertex_se3.h:30,
                 from /home/hlx/pl-slam-master/include/mapHandler.h:34,
                 from /home/hlx/pl-slam-master/src/mapHandler.cpp:23:
/usr/local/include/g2o/core/eigen_types.h:30:22: fatal error: Eigen/Core: 没有那个文件或目录
compilation terminated.
CMakeFiles/plslam.dir/build.make:62: recipe for target 'CMakeFiles/plslam.dir/src/mapHandler.cpp.o' failed
make[2]: *** [CMakeFiles/plslam.dir/src/mapHandler.cpp.o] Error 1
CMakeFiles/Makefile2:99: recipe for target 'CMakeFiles/plslam.dir/all' failed
make[1]: *** [CMakeFiles/plslam.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

解决方式

打开/usr/local/include/g2o/core/eigen_types.h文件,将
#include 改为#include 后解决

5.2

Scanning dependencies of target plslam
[ 12%] Building CXX object CMakeFiles/plslam.dir/src/mapHandler.cpp.o
In file included from /home/hlx/pl-slam-master/include/mapHandler.h:54:0,
                 from /home/hlx/pl-slam-master/src/mapHandler.cpp:23:
/home/hlx/pl-slam-master/../stvo-pl-master/include/stereoFrame.h:35:32: fatal error: opencv2/ximgproc.hpp: 没有那个文件或目录
compilation terminated.
CMakeFiles/plslam.dir/build.make:62: recipe for target 'CMakeFiles/plslam.dir/src/mapHandler.cpp.o' failed
make[2]: *** [CMakeFiles/plslam.dir/src/mapHandler.cpp.o] Error 1
CMakeFiles/Makefile2:99: recipe for target 'CMakeFiles/plslam.dir/all' failed
make[1]: *** [CMakeFiles/plslam.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

造成问题的原因是ximgproc模块在opencv的扩展模块opencv_contrib中,opencv在3.2版本之后引入了ximgproc模块,模块主要进行线特征的操作(分割,提取)

填坑完毕,在EuRoC上运行的效果是:
ubuntu16.04 下配置运行 PL-SLAM_第1张图片

你可能感兴趣的:(computer,version)