暑假研习系列:线、面SLAM从零入门(三)
将测试以下几种点线结合的SLAM系统:
- PL-SVO
- STVO-PL
- PL-SLAM
一、PL-SVO
作为svo系列的改进版本,pl-svo增加了线特征。一定程度上的增加了svo的稳定性。不过,据我自己评测结果来看,速度的确是一如既往的快,但是稳定性和准确性吗,就和svo一样一言难尽了(和svo有所提升,具体见论文)。
代码:https://github.com/rubengooj/pl-svo
首先安装svo,最好两个版本(ros及非ros)都安装:https://github.com/uzh-rpg/rpg_svo/wiki
svo的安装几乎没有难度,我唯一出的问题是eigen库,最后重新下了源码重新安装即可。
git clone https://github.com/eigenteam/eigen-git-mirror.git
mkdir build
cd build
cmake ..
sudo make install
sudo cp -r /usr/local/include/eigen3 /usr/include
另外ros安装时候别忘记在catkin_make之后使用命令:source devel setup.zsh (如果没有用zsh换成bash)
除此之外,rpg_vikit在ROS安装后不必重下,非ROS安装时直接在ROS的src文件下修改编译即可。
之后便进入pl-svo的安装流程。注意,这里可视化(MRPT库)出了点小问题,本人并没能成功弄出来,不过最终轨迹都是正常的。
-
首先修改CMakeLists.txt。注释掉~/libs/Sophus/build/libSophus.so(简直有毒),取消${Sophus_LIBRARIES}前的注释符号#
-
打开home目录下的bashrc或者zshrc。添加数据集主目录。注意,这里的目录到数据集序列前即可,并以/结尾。如:我的文件在末尾添加:
export DATASETS_DIR=/home/demo/Data/SVO/EuRoc/
-
阅读代码可知,执行命令对数据集格式由要求。因此,需要修改数据集格式:
在home/demo/Data/SVO/EuRoc/下新建数据序列文件夹:如 images3
在images3下,制作dataset_params.yaml文件。按照config中的实例编写。如MH_03_medium中cam0配置文件如下:
cam0: cam_cx: 367.215 cam_cy: 248.375 cam_d0: -0.28340811 cam_d1: 0.07395907 cam_d2: 0.00019359 cam_d3: 1.76187114e-05 cam_fx: 458.654 cam_fy: 457.296 cam_height: 480 cam_model: Pinhole cam_width: 752 rx: 0.0 ry: 0.0 rz: 0.0 tx: 0.0 ty: 0.0 tz: 0.0 images_subfolder: images/
在images3下,制作图片数据集,命名为images,并将cam0下所有图像拷贝到该文件夹下。
整个文件树结构如下:
-
执行./build.sh。如果一切OK,顺利编译通过,如果其他问题按照报错修改即可。
-
运行:
./bin/run_pipeline image3/
如果一切顺利,那么恭喜你,顺便可以加我wx交流一下。
如果你报错:
terminate called after throwing an instance of 'YAML::BadFile' what(): yaml-cpp: error at line 0, column 0: bad file [1] 22817 abort (core dumped) ./bin/run_pipeline image3/
那么你的文件路径出了问题。
如果你报错:
=============== MRPT EXCEPTION ============= void mrpt::utils::CImage::copyFastFrom(mrpt::utils::CImage&), line 186: Origin image is empty! (o.img==NULL) void mrpt::utils::CImage::copyFastFrom(mrpt::utils::CImage&), line 202: [1] 23921 abort (core dumped) ./bin/run_pipeline image3/
那么恭喜你,和我一样,你的MRPT库也出了点问题(也有可能是代码的问题)需要进行手动调整。以下内容参考issues:https://github.com/rubengooj/pl-svo/issues/2。
MRPT主要负责可视化部分,因此最简单的方法是去除可视化代码模块。
注释掉run_pipline.cpp文件的以下内容: 385行 scene.initializeScene(T_f_w); 483行 scene.setLinesSVO(lines3d); 486行 scene.updateScene();
再次编译运行,成功,但是只有命令行显示相关信息。
在该isssue后还有大佬交流如何修改代码使MRPT正常。修改内容如下:
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_ . Then I recompile and re-run run_pipline to successfully see the window.
但是follow大佬修改并没成功运行起来。尝试用apt重装MRPT,提示需要gcc7,并且安装完成后仍然报错。尝试源代码编译。
注意,不能选择较高版本的库。在后续的stvo-pl内,作者提供被验证过的MRPT版本,链接如下:https://github.com/MRPT/mrpt/tree/0c3d605c3cbf5f2ffb8137089e43ebdae5a55de3。
cmake成功,但是make出错,发现Eigen库的问题。百度谷歌未果,猜测Eigen库刚才安装的最新版版本过高。下载较低版本的Eigen库https://github.com/eigenteam/eigen-git-mirror/tree/3.3.0。 再次编译,成功。
-
测试工具
使用evo评测工具。新建euroc文件夹,在文件夹下,拷贝EuRoC/mav0/state_groundtruth_estimate0/data.csv及pl-svo下运行得到的trajout.txt。输入命令:
evo_traj tum trajout.txt --save_as_tum evo_traj euroc data.csv --save_as_tum
理论上应该能将data.csv成功转换的。但是,不知为何evo提示时间戳找不到。打开才发现,data.tum时间戳不知为何变成了e+09(10的9次方),但是原文件明明给的是e+18.不得已,手动替换e+09为e+18。接着:
evo_traj tum trajout.tum --ref=data.tum -p -a -s
-
测试结果:
在02序列cam0中,随机记录几条还可以的数据分析:
Frame-Id: 553 #PointFeatures: 101 #LineFeatures: 18 Proc. Time: 2.956ms Frame-Id: 547 #PointFeatures: 101 #LineFeatures: 8 Proc. Time: 2.242ms Frame-Id: 527 #PointFeatures: 101 #LineFeatures: 11 Proc. Time: 4.52ms Frame-Id: 454 #PointFeatures: 101 #LineFeatures: 8 Proc. Time: 2.275ms
速度是真的可以,但是在MH_03_medium中也经常容易丢,在中间一段也容易出现线特征数量为0的情况。
[WARN] Relocalizing frame [WARN] Not enough matched features. Frame-Id: 2373 #PointFeatures: 3 #LineFeatures: 0 Proc. Time: 3.696ms ……………… [INFO] Relocalization successful. Frame-Id: 2544 #PointFeatures: 41 #LineFeatures: 4 Proc. Time: 3.44ms
结果展示图:
在00序列中的cam1,pl-svo表现要好得多:
Frame-Id: 3677 #PointFeatures: 101 #LineFeatures: 31 Proc. Time: 6.103ms
Frame-Id: 3658 #PointFeatures: 101 #LineFeatures: 43 Proc. Time: 7.161ms
Frame-Id: 3638 #PointFeatures: 101 #LineFeatures: 57 Proc. Time: 8.483ms
Frame-Id: 3601 #PointFeatures: 101 #LineFeatures: 18 Proc. Time: 6.799ms
Frame-Id: 3540 #PointFeatures: 101 #LineFeatures: 101 Proc. Time: 7.989ms
Frame-Id: 3530 #PointFeatures: 101 #LineFeatures