1. 程式人生 > >ubuntu14.04配置PL-SLAM並執行

ubuntu14.04配置PL-SLAM並執行

前言

在視覺SLAM中,前端一般分為特徵點法和直接法。
在弱紋理環境中,可靠點特徵的缺乏會降低系統的效能,針對該問題,陸續有學者提出聯合點、線特徵的視覺SLAM系統,從而更加穩定地應用於點特徵缺乏或分佈不均的場景。
論文《PL-SLAM: a Stereo SLAM System through the Combination of Points and Line Segments》便是一項十分傑出的工作,可在https://arxiv.org/abs/1705.09479下載閱讀。
更關鍵的是作者開源了程式碼,大讚,Github地址為https://github.com/rubengooj/pl-slam


本部落格暫不做理論分析,先對開源專案進行實現,這花費了我一天的時間,遇到很多問題,不過最終還是成功了。

配置PL-SLAM

主要參考專案主頁的 README.md。

安裝依賴

OpenCV 3.x.x

It can be easily found at http://opencv.org.
建議安裝OpenCV 3.1.0,否則編譯過程中會出現一些.so檔案的錯誤,推測作者可能用的這個版本。

Eigen3 (tested with 3.2.92)

$ sudo apt-get install libeigen3-dev

Boost

$ sudo apt-get
install libboost-dev

g2o - General Graph Optimization

It can be found at:
https://github.com/RainerKuemmerle/g2o.git
這裡在編譯時可能會出現錯誤,將安裝好的g2o資料夾中的cmake_modules資料夾複製到~/pl-slam資料夾中即可。

YAML (tested with 0.5.2)

Installation on Ubuntu:

$ sudo apt-get install libyaml-cpp-dev

stvo-pl

It can be found at:

MRPT

Line Descriptor

We have modified the line_descriptor module from the OpenCV/contrib library (both BSD) which is included in the 3rdparty folder.
這裡不用操作,後面的指令碼build.sh會一併安裝。
但是這裡值得特別注意,一般情況下我們安裝OpenCV就夠用了,但是為了使用line_descriptor,必須安裝opencv_contrib,而且最好同時安裝,否則會可能出現一些錯誤。

git clone https://github.com/opencv/opencv/tree/3.1.0
git clone https://github.com/opencv/opencv_contrib/tree/3.1.0
unzip opencv-3.1.0.zip
unzip opencv_contrib.zip
cd ~/opencv-3.1.0
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules/ ..
make -j8 #具體執行緒視電腦效能而定
sudo make install

Configuration and generation

cd ~/pl-slam
./build.sh

如果按照以上步驟操作,這裡應該不會再出現錯誤,如果有,請百度或谷歌。
印象中有一些.so檔案的錯誤,都可百度找到解決方案。
比如:

Linking CXX shared library ../lib/libplslam.so
/usr/bin/ld: can not find -lg2o_ext_csparse

解決方法:

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

Usage

Datasets configuration

We employ an environment variable, ${DATASETS_DIR}, pointing the directory that contains our datasets. Each sequence from each dataset must contain in its root folder a file named dataset_params.yaml, that indicates at least the camera model and the subfolders with the left and right images. We provide dataset parameters files for several datasets and cameras with the format xxxx_params.yaml.
關鍵是設定資料集路徑的環境變數,閱讀~/pl-slam/app/plslam-dataset.cpp可以加深理解。

gedit ~/.bashrc
export DATASETS_DIR=~/KITTI
source ~/.bashrc

KITTI下載kitti/00資料,並將其放到~/KITTI目錄下。
~/pl-slam/config/dataset_params/kitti00-02.yaml複製到~/KITTI/kitti/00,然後將kitti00-02.yaml改為dataset_params.yaml.
~/pl-slam/config/config/config_kitti.yamlvocabulary_pvocabulary_l的路徑改為自己的。

SLAM Application

./plslam_dataset kitti/00

最終執行截圖如下

總結

從效果來看,比較驚豔,關鍵是融合點線特徵的詞袋提高了迴環檢測的效果。
視覺化工具只顯示了關鍵幀和軌跡,沒有地圖,如果想在此基礎上開發,還需增加軌跡儲存、地圖儲存和載入等模組。
接下來,會配置ROS版,畢竟不能只停留在跑資料集,要能實時線上的使用。
安裝期間遇到很多問題,記憶有限,不能面面俱到,如有問題,歡迎留言交流。