Install, compile and run PL-SLAM on ubuntu18.04

The author's open source code address: https://github.com/rubengooj/pl-slam
My environment: Ubuntu18.04, cmake3.10.2
There are many problems in the process of installing related libraries and projects, which are recorded here. The following As a whole, follow the installation process of README.md in the code. Since the compilation and installation of stvo-pl depends on MRPT, the order is adjusted. And the program operation requires wxWidgets, which should be installed before MRPT.

Note:
MRPT and stvo-pl are decompressed to the same folder as pl-slam, otherwise some environment variables need to be set to refer to the header files of the two project files, etc.

I configured the pl-slam operating environment on the laboratory computer (ubuntu20.04) before, but because I have run orb-slam2 and orb-slam3 on the laboratory computer before, I have been reporting errors when installing mrpt, and I cannot install it smoothly. , probably due to conflicting versions of some libraries. It is troublesome to reconfigure a pl-slam environment, so I configured the pl-slam environment on my computer, and finally ran successfully. The process was very tortuous, and there were many errors, most of which were caused by version conflicts of some libraries. The records are as follows.

1. Installation of various libraries

1. The author of OpenCV 3.xx
said on the github homepage that OpenCV can use the 3.xx version, but I tried opencv3.1.0, and finally when I run the source code, it will appear:

/home/hlx/stvo-pl-master/src/matching.cpp:47:79: error: no matching function for call to ‘cv::BFMatcher::create(cv::NormTypes, bool)
 r<cv::BFMatcher> bfm = cv::BFMatcher::create(cv::NORM_HAMMING, false); // cross

Line 47 of matching in stvo will prompt that only one variable is required but two are provided, which can be changed to the following code:

cv::Ptr<cv::DescriptorMatcher> bfm = cv::BFMatcher::create("cv::NORM_HAMMING");

But then the question is:

/home/fyh/PL_SLAM/stvo-pl-master/lib/libstvo.so:-1: error: undefined reference to `cv::ximgproc::createFastLineDetector(int, float, double, double, int, bool)'

The solution is to install opencv3.4.0+opencv_contrib-3.4.0 (be sure to remember the corresponding version), which should be caused by the opencv3.1.0 version.
Next install opencv3.4.0:
opencv3.4.0 source address: https://github.com/opencv/opencv/tree/3.4.0
opencv_contrib-3.4.0 source address: https://github.com/opencv/opencv_contrib/ tree/3.4.0
installation tutorial reference blog: http://t.csdn.cn/PVbyB

2. Eigen3 (3.2.9 or 3.2.10)
installation command:

sudo apt-get install libeigen3-dev

3. Boost
installation command:

sudo apt-get install libboost-dev

4. YAML (the version tested by the author is 0.5.2)
installation command:

sudo apt-get install libyaml-cpp-dev

5. g2o
It is not recommended to use the latest version of g2o, because pl-slam uses a lower version of the header file. In the new version, the pointer of g2o needs to be passed using std::unique_ptr.
The source code address of g2o: https://github.com/RainerKuemmerle/g2o.git , here I installed the version released in 20160424.
Installation dependencies:

sudo apt-get install libeigen3-dev libsuitesparse-dev qtdeclarative5-dev qt5-qmake libqglviewer-dev

Install g2o:

cd g2o
mkdir build
cd build
cmake …/
make
sudo make install

6. wxWidgets
needs to depend on wxWidgets when installing mrpt, so install wxWidgets before installing mrpt.
The mrpt version recommended by the author depends on wxWidgets version 2.8, but since wxWidgets2.8 is too old, enter in ubuntu18.04:

sudo add-apt-repository ppa:nilarimogard/webupd8 
sudo apt-get update
sudo apt-get install libwxgtk2.8-dev

Will appear:

正在读取软件包列表... 完成
正在分析软件包的依赖关系树       
正在读取状态信息... 完成       
E: 无法定位软件包 libwxgtk2.8-dev
E: 无法按照 glob ‘libwxgtk2.8-dev’ 找到任何软件包
E: 无法按照正则表达式 libwxgtk2.8-dev 找到任何软件包

Unable to install successfully. After testing, mrpt can also be installed normally after installing wxWidgets3.0 version, and can also run pl-SLAM.
It is recommended to use the command line to install:

sudo apt install libwxgtk3.0-gtk3-dev

7. mrpt (must use the version recommended by the author)
the address of the version recommended by the author: https://github.com/MRPT/mrpt/tree/0c3d605c3cbf5f2ffb8137089e43ebdae5a55de3
Install dependent libraries:

//安装依赖库,其中有些库如果已经安装,不必重复安装. 
$ sudo apt-get install build-essential pkg-config libdc1394-22-dev libjpeg-dev libsuitesparse-dev libftdi-dev freeglut3-dev zlib1g-dev libusb-1.0-0-dev libudev-dev libfreenect-dev  libavformat-dev libswscale-dev libassimp-dev libgtest-dev libpcap-dev
//进入MRPT码包
$ mkdir build
$ cd build 
$ cmake ..
$ make -j12
$ sudo make install

If multiple versions of opencv are installed, it is recommended to use cmake-gui ..the command to modify the address of the opencv library file in the cmake visual interface, use the opencv3.4.0 version, and then compile mrpt.

The following error occurred during the installation of MRPT:

CMake Error at cmakemodules/script_detect_gcc.cmake:16 (LIST):
  list GET given empty list
Call Stack (most recent call first):
  CMakeLists.txt:83 (include)


CMake Error at cmakemodules/script_detect_gcc.cmake:17 (LIST):
  list GET given empty list
Call Stack (most recent call first):
  CMakeLists.txt:83 (include)

The reason is: because the GCC version is too high,
so the operation: 1. Open the cmakemodules/script_detect_gcc.cmake file in the MRPT source file and replace "dumpversion" with "dumpfullversion"
Reference link: https://blog.csdn.net /qq_40679814/

Encountered problems when compiling:

 /home/hlx/mrpt/apps/ReactiveNavigationDemo/reactive_navigator_demoMain.cpp:1042:102: error: ‘wxTE_AUTO_SCROLL’ was not declared in this scope

Solution:

This is because the higher version of wxWeights removes the definition and defines it in the header file:
add it to the reactive_navigator_demoMain.h file

#ifndef wxTE_AUTO_SCROLL
#define wxTE_AUTO_SCROLL 0
#endif

2. Run stvo-pl

stvo-pl source code address: https://github.com/rubengooj/stvo-pl
Enter the stvo-pl folder, execute: ./build.sh, if there is no operation permission, just modify it sudo chmod 777 build.sh.

Error /usr/bin/ld: can not find -lg2o_ext_csparse solution:

cd /usr/local/lib
sudo ln -sv libg2o_csparse_extension.so libg2o_ext_csparse.so

Linux system dynamic link reference blog: https://blog.csdn.net/jc_benben/article/details/113945860

When executing the system, it keeps prompting that the g2o library cannot be found. After confirming that g2o has been installed, add the following two statements before find_package(G2O REQUIRED) in the CmakeList.txt file:

list( APPEND CMAKE_MODULE_PATH /home/xqs/3rdparty/g2o/cmake_modules ) 
set(G2O_ROOT /usr/local/include/g2o)

When running the program, a segfault occurs and exits the interface after a period of time after MRPT is turned on. You need to modify the CmakeList.txt:

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O3 -mtune=native -march=native")
修改为
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O3 -mtune=native")

If a segmentation fault occurs, it needs to be corrected in sceneRepresentation.cpp according to the following requirements.

I dig deeper and find that v_aux_ are always holding the same value
with v_aux, thus no need to differentiate them. Therefore, I replace
v_aux_ with v_aux and comment this line v_aux_ = v_aux; , so are the
other two variables v_auxgt_ and v_aux1_ .

insert image description here

3. Run pl-slam

pl-slam source code address: https://github.com/rubengooj/pl-slam
Enter the pl-slam folder, execute: ./build.sh, if you do not have the operation permission, just modify it sudo chmod 777 build.sh.

If you install multiple versions of opencv, remember buildto use it under the folder cmake-gui .., modify the file path of opencv in the cmake visual interface, and use opencv3.4.0 version.

problem appear:

Invalid vocabulary for points

Modify the vocabulary_p and vocabulary_l in the file to be the absolute address of your own computer /config/config/config_kitti.yaml.src/slamConfig.cpp

# Loop closure
#vocabulary_p          : "/home/ruben/code/pl-slam-dev/vocabulary/mapir_orb.yml"
#vocabulary_l          : "/home/ruben/code/pl-slam-dev/vocabulary/mapir_lsd.yml"

vocabulary_p          : "/home/xqs/PL-SLAM/stvo-pl/vocabulary/mapir_orb.yml"
vocabulary_l          : "/home/xqs/PL-SLAM/stvo-pl/vocabulary/mapir_lsd.yml"

If you run the kitti data set 00 sequence, it fails at frame 1600 and reports an error:

./plslam_dataset: symbol lookup error: /home/xqs/PL-SLAM/pl-slam/lib/libplslam.so: undefined symbol: _ZN3g2o30OptimizationAlgorithmLevenbergC1EPNS_6SolverE

After searching related blogs on the Internet, it was found that the g2o version that comes with ROS conflicts with the local version. This conflict can be checked through the ldd command that comes with linux. First, check the dependencies of the successful examples. The figure below shows the dependencies of the g2o sample file that can be used normally:
insert image description here
Dependencies of the error file:
You can see that for some reason, this program is linked to the g2o library file that comes with ROS.
Solution: Move the library files in the ros directory to other folders, so that the system cannot retrieve them, and only link to the library files in the usr directory. The specific operation steps are as follows:
1. First enter the ros directory: cd /opt/ros/melodic
2. Create a backup directory with administrator privileges: mkdir back_lib
3. Enter the following command in the terminal to move the library files to the backup directory: sudo mv ./lib/libg2o*.* ./back_lib/ .
4. Check whether the move is successful: ls back_lib
5. Recompile the program and check its dependencies, you can see that the program is linked to the correct library file and executed normally.
Reference blog link: https://blog.csdn.net/mclinrv/article/details/120257414

4. Run the dataset

1. kitti dataset:
1. Add the save path of the dataset to the environment variable:

gedit ~/.bashrc
export DATASETS_DIR=/home/xqs/PL-SLAM/pl-slam/kitti
source ~/.bashrc

2. Copy pl-slam/config/dataset_params/kitti00-02.yamlto <path-to-data_odometry_gray>/sequences/00/, rename the yaml file to dataset_params.yaml
3. Edit pl-slam/config/config/config_kitti.yaml, modify vocabulary_pand vocabulary_lpath.

# Loop closure
#vocabulary_p          : "/home/ruben/code/pl-slam-dev/vocabulary/mapir_orb.yml"
#vocabulary_l          : "/home/ruben/code/pl-slam-dev/vocabulary/mapir_lsd.yml"

vocabulary_p          : "/home/xqs/PL-SLAM/pl-slam/vocabulary/mapir_orb.yml"
vocabulary_l          : "/home/xqs/PL-SLAM/pl-slam/vocabulary/mapir_lsd.yml"

4. Run:

./plslam_dataset ../kitti/00 -c ../config/config/config_kitti.yaml -o 100 -s 1 -n 1000

or:

./plslam_dataset ../kitti/00 -c ../config/config/config_kitti.yaml -o 100 -s 1

Reference blog: https://blog.csdn.net/u011178262/article/details/86562125

2、EuRoC MH_01_easy
edit ~/.bashrc, and add export DATASETS_DIR=<path-to-MH_01_easy>
copypl-slam/config/dataset_params/euroc_params.yamlto <path-to-MH_01_easy>/mav0/,
rename the yaml file to dataset_params.yaml and change it if necessary
source ~/.bashrc
run ./imagesStVO ../MH_01_easy/mav0
参考链接:https://zhuanlan.zhihu.com/p/157900327

Reference link:

  1. https://blog.csdn.net/yanni0616/article/details/81017120
  2. https://blog.csdn.net/wyy13273181006/article/details/108807570
  3. https://blog.csdn.net/Wenyue_Wang/article/details/82318484
  4. https://blog.csdn.net/u011178262/article/details/86562125
  5. /usr/bin/ld: cannot find -l Basic principle explanation and solution https://blog.csdn.net/boyhoodme/article/details/125097384

Guess you like

Origin blog.csdn.net/xiao_qs/article/details/126681494