实测 | Stereo PL-SLAM安装运行以及错误解决

  • Basics
sudo apt install build-essential pkg-config libboost-dev \
libsuitesparse-dev libeigen3-dev libyaml-cpp-dev
  • OpenCV 3.x.x

略。

  • G2O

  • MRPT/mrpt: The Mobile Robot Programming Toolkit

    • recommend version: commit id 0c3d605 (0c3d605c3cbf5f2ffb8137089e43ebdae5a55de3)
      git clone https://github.com/MRPT/mrpt.git
      git branch cg_0c3d605 0c3d605c3cbf5f2ffb8137089e43ebdae5a55de3
      git checkout cg_0c3d605
      
      # install dependencies
      sudo apt install libdc1394-22-dev libjpeg-dev libftdi-dev freeglut3-dev \
      libwxgtk3.0-dev zlib1g-dev libusb-1.0-0-dev libudev-dev libfreenect-dev \
      libavformat-dev libswscale-dev libassimp-dev libgtest-dev libpcap-dev
      
      # build & install
      mkdir build & cd build
      cmake .. & make -j4
      sudo make install
      

       

Note: it’s better mrpt, stvo-pl and pl-slam are in the same directory


Build

Build pl-slam

git clone https://github.com/rubengooj/pl-slam.git
chmod +x build.sh
./build.sh

Errors

  • Q: /usr/bin/ld: cannot find -lg2o_ext_csparse
    A: sudo ln -sv libg2o_csparse_extension.so libg2o_ext_csparse.so

Run

Dataset

  • Kitti Dataset: data_odometry_gray (~22G)
  • Kitti data_odometry_gray
     

edit ~/.bashrc, and
add export DATASETS_DIR=<path-to-data_odometry_gray>/sequences
copy pl-slam/config/dataset_params/kitti00-02.yaml
to <path-to-data_odometry_gray>/sequences/00/,
rename the yaml file to dataset_params.yaml and change it if necessary
source ~/.bashrc
edit pl-slam/config/config/config_kitti.yaml, change the value of vocabulary_p and vocabulary_l
run
./plslam_dataset 00 -c ../config/config/config_kitti.yaml -o 100 -s 1 -n 1000
or
./plslam_dataset 00 -c ../config/config/config_kitti.yaml -o 100 -s 1


Result

 



EuRoC MH_01_easy


edit ~/.bashrc, and add export DATASETS_DIR=<path-to-MH_01_easy>
copy pl-slam/config/dataset_params/euroc_params.yaml to <path-to-MH_01_easy>/mav0/,
rename the yaml file to dataset_params.yaml and change it if necessary
source ~/.bashrc
edit pl-slam/config/config/config_euroc.yaml, change the value of vocabulary_p and vocabulary_l
run ./plslam_dataset mav0 -c ../config/config/config_euroc.yaml -o 100 -s 1


Result

 


错误解决

1. G2O问题 

报错:

/home/hri/SLAM/slambook/ch6/g2o_curve_fitting/main.cpp: In function ‘int main(int, char**)’: 
/home/hri/SLAM/slambook/ch6/g2o_curve_fitting/main.cpp:77:49: error: no matching function for call to ‘g2o::BlockSolver<g2o::BlockSolverTraits<3, 1> >::BlockSolver(g2o::BlockSolver<g2o::BlockSolverTraits<3, 1> >::LinearSolverType*&)’ 
Block* solver_ptr = new Block( linearSolver ); // 矩阵块求解器 

等等.......

g2o版本的问题。不建议用最新的,因为pl-slam是使用低版本的头文件,新版本中,g2o的指针用到智能指针需要多处修改。

解决一:

删掉/卸载掉新版本的g2o,安装新的SLAM十四讲代码中附带的第三方库文件夹下的旧版本

卸载g2o:

sudo rm -r /usr/local/lib/libg2o* /usr/local/include/g2o /usr/local/lib/g2o /usr/local/bin/g2o*

    如果显示有找不到的路径可以忽略,因为该删的都已经删掉了
 

重新安装g2o: 

高博github《slam十四讲书》上g2o版本为低版本,可下载https://github.com/gaoxiang12/slambook/tree/master/3rdparty

安装(常规套路)

mkdir build
cd build
cmake ..
make -j4
sudo make install

解决二:

用g2o新版,但是在源码有误处修改: 

// new
// g2o::BlockSolver_6_3::LinearSolverType* linearSolver;
// linearSolver = new g2o::LinearSolverCholmod<g2o::BlockSolver_6_3::PoseMatrixType>();
// unique_ptr
std::unique_ptr<g2o::BlockSolver_6_3::LinearSolverType> linearSolver (new g2o::LinearSolverCholmod<g2o::BlockSolver_6_3::PoseMatrixType>());

// g2o::BlockSolver_6_3 * solver_ptr = new g2o::BlockSolver_6_3(linearSolver);
std::unique_ptr<g2o::BlockSolver_6_3> solver_ptr (new g2o::BlockSolver_6_3(std::move(linearSolver)));
g2o::OptimizationAlgorithmLevenberg * solver = new g2o::OptimizationAlgorithmLevenberg(std::move(solver_ptr));

 

2. FindG2O问题

原pl-slam中的CMakeLists.txt文件中有

list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake_modules")

解决一:

但是实际上pl-slam文件夹中并没有cmake_modules目录,所以我们可以添加,参见高博github中

https://github.com/gaoxiang12/slambook/tree/master/project/0.4/cmake_modules

把上述文件复制至 .../pl-slam/文件中 即可。

解决二: 

把CMakeLists.txt中

list( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules ) 

修改为

list( APPEND CMAKE_MODULE_PATH /home/hri/ThirdParty/g2o/cmake_modules ) 

注:大致这个意思,其中的路径换做你电脑上的路径  
 

 

3.  /usr/bin/ld: cannot find -lg2o_ext_csparse问题

解决一: 

进入CMakeLists.txt中 

SET(G2O_LIBS g2o_cli g2o_ext_freeglut_minimal g2o_simulator g2o_solver_slam2d_linear g2o_types_icp g2o_types_slam2d g2o_core g2o_interface g2o_solver_csparse g2o_solver_structure_only g2o_types_sba g2o_types_slam3d g2o_csparse_extension g2o_opengl_helper g2o_solver_dense g2o_stuff g2o_types_sclam2d g2o_parser g2o_solver_pcg g2o_types_data g2o_types_sim3 cxsparse  
g2o_ext_csparse cholmod )

中把g2o_ext_csparse删除 

解决二: 

cd  /usr/local/lib/ 

sudo ln -sv libg2o_csparse_extension.so libg2o_ext_csparse.so

上述操作是库文件之间的软链接,linux下很多报错都可以用这样的方式来解决。主要应对一些库名找不到的情况,把旧版的库名软链接到新版库名。软链接可以理解为共享。

 

4. 运行时候的问题

1. edit ~/.bashrc, and

这一步sudo edit ~/.bashrc,或者 sudo gedit ~/.bashrc  前者是用VIM修改,后者使用编辑器修改,只要最后保存就行。 


2. add export DATASETS_DIR=<path-to-data_odometry_gray>/sequences


3. copy pl-slam/config/dataset_params/kitti00-02.yaml
    to <path-to-data_odometry_gray>/sequences/00/,


4. rename the yaml file to dataset_params.yaml and change it if necessary

这里注意, change it if necessary。举例我是用的Kitti 00数据集,在这个yaml文件中需要其中两句修改为imge_0 image_1   

5. source ~/.bashrc

使得立即生效 


6. edit pl-slam/config/config/config_kitti.yaml, change the value of vocabulary_p and vocabulary_l

这里注意,实际上最好修改两个地方的: 

~/src/slamConfig.cpp内vocabulary_p和vocabulary_l 地址修改. 
~/config/config/config_kitti.yamlvocabulary_p和vocabulary_l 地址修改.

而且我是在编译之前修改的。   


7. run
    ./plslam_dataset 00 -c ../config/config/config_kitti.yaml -o 100 -s 1 -n 1000
or
    ./plslam_dataset 00 -c ../config/config/config_kitti.yaml -o 100 -s 1

这里注意,参数的含义: 

./plslam_dataset <数据集名,dataset目录下的某个子文件夹名> [options]

Usage: ./imgPLSLAM <dataset_name> [options]
Options:
-o Offset (number of frames to skip in the dataset directory
-n Number of frames to process the sequence
-s Parameter to skip s-1 frames (default 1)
-c Config file

你也可以简单的运行 

./pl-slam 00   

如果有误,可以把参数带上  

 

暂时到这,其他问题网上已经有一些指导贴了,如果你还有什么问题,feel free to contact me.      

 


题外话……好想再多给我一点时间,完成对PL-SLAM的源码的解读,贡献在github上……虽然作者说是基于ORBslam开发的,但是架构和代码风格和ORB-SLAM有很大的区别了。    

  • 1
    点赞
  • 29
    收藏
    觉得还不错? 一键收藏
  • 16
    评论
评论 16
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值