ORB-SLAM3编译与运行问题汇总

毕设要做ORB-SLAM3相关内容,对于我这种slam初学者来讲难度还是挺大的,总结实践中碰到的各种问题。

1 安装Eigen3.3.9

ORB-SLAM3要求eigen版本至少是3.1.0,使用一步命令安装eigen3无法满足这个条件,因此采用源代码安装方式,参考下面这个博客:
Ubuntu16.04安装Eigen3

我下载的版本是eigen3.3.9,安装命令:

tar -zxvf eigen-3.3.9.tar.gz
cd eigen-3.3.9
mkdir build
cd build
cmake ..
make 
sudo make install

复制Eigen库到 /usr/local/include 中 ,因为在很多程序中include时经常使用#include <Eigen/Dense>而不是使用#include <eigen3/Eigen/Dense>。

sudo cp -r /usr/local/include/eigen3/Eigen /usr/local/include


2 编译ROS版本

参考博客:
Ubuntu下使用ROS接口运行ORB_SLAM3

2.1 添加环境变量

在.bashrc中添加ORB-SLAM3的ros环境:

gedit ~/.bashrc
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/slender/文档/ORB-SLAM/ORB_SLAM3/Examples/ROS/ORB_SLAM3

2.2 fatal error: xxx.h: 没有那个文件或目录

这类error出现在/ORB-SLAM3/include路径下的Atlas.h,KeyFrame.h和Tracking.h,在头文件添加一层CameraModels目录:

#include "CameraModels/GeometricCamera.h"
#include "CameraModels/Pinhole.h"
#include "CameraModels/KannalaBrandt8.h"

2.3 ‘ORB_SLAM2’ has not been declared

把ORB_SLAM2替换为ORB_SLAM3:

sed -i "s/ORB_SLAM2/ORB_SLAM3/g" `grep -rl "ORB_SLAM2"`

2.4 “pangolin” includes non-existent path “/usr/include/eigen3”

手动安装eigen3的安装路径在/usr/local/include/eigen3,但是有的库默认是到/usr/include这个路径下面找,复制一份过去:

sudo cp -r /usr/local/include/eigen3 /usr/include/

2.5 DSO missing from command line

/usr/lib/x86_64-linux-gnu/libboost_system.so: error adding symbols: DSO missing from command line

参考博客,在Examples/ROS/ORB_SLAM2/Cmakelist.txt 的文件后面加入两句话:

target_link_libraries(Stereo boost_system boost_filesystem)  
target_link_libraries(RGBD boost_system boost_filesystem) 

ROS版本编译完成!



3 运行测试

3.1 非ROS版本

参考博客:Ubuntu16.04环境下配置运行ORB-SLAM3

下载数据集EuRoC MAV Dataset,我下载的是MH_03(注意下载的格式是 ASL Dataset Format),解压后放入/dataset/MH_03/mav0这样的路径。

(1)仅单目相机

./Examples/Monocular/mono_euroc ./Vocabulary/ORBvoc.txt ./Examples/Monocular/EuRoC.yaml ../dataset/MH_03 ./Examples/Monocular/EuRoC_TimeStamps/MH03.txt

(2)仅双目相机

./Examples/Stereo/stereo_euroc ./Vocabulary/ORBvoc.txt ./Examples/Stereo/EuRoC.yaml ../dataset/MH_03 ./Examples/Stereo/EuRoC_TimeStamps/MH03.txt

(3)单目相机+IMU

./Examples/Monocular-Inertial/mono_inertial_euroc ./Vocabulary/ORBvoc.txt ./Examples/Monocular-Inertial/EuRoC.yaml ../dataset/MH_03 ./Examples/Monocular-Inertial/EuRoC_TimeStamps/MH03.txt

(4)双目相机+IMU

./Examples/Stereo-Inertial/stereo_inertial_euroc ./Vocabulary/ORBvoc.txt ./Examples/Stereo-Inertial/EuRoC.yaml ../dataset/MH_03 ./Examples/Stereo-Inertial/EuRoC_TimeStamps/MH03.txt

用ORB-SLAM3运行EuRoC数据集,发现最后Current Frame窗口卡住,并且无法保存轨迹文件。

参考了ORB-SLAM2运行数据集时Pangolin界面卡住,不能生成轨迹以及用摄像头运行非ROS版程序时如何退出的方法,猜测是Pangolin更新后存在bug。

我用了方法2,在System.cc的SLAM.Shoutdown()中将以下代码注释掉:

if(mpViewer)
        pangolin::BindToContext("ORB-SLAM2: Map Viewer");

能够自动关闭窗口,也能生成轨迹文件,但是又出现了段错误,有的博客提到是因为内存小了,目前还没解决这个问题。

在这里插入图片描述

3.2 ROS版本

参考博客:
SLAM笔记–第2篇: ORB_SLAM2编译运行
EVO Estimate SLAM 4 — ORB-SLAM3 build &run

ORB_SLAM3的ROS版本中没有加入imu的节点,运行时仅有Mono_AR,Mono,Stereo。

测试使用 .bag 格式数据集。

# -ROS版本
roscore

#  EuRoC单目, 运行EuRoc单目目ROS数据包,发送图像信息
rosbag play --pause V1_01_easy.bag /cam0/image_raw:=/camera/image_raw
rosrun ORB_SLAM3 Mono Vocabulary/ORBvoc.txt Examples/Monocular/EuRoC.yaml

#  EuRoC双目, 运行EuRoc双目ROS数据包,发送图像信息
rosbag play --pause V1_01_easy.bag /cam0/image_raw:=/camera/left/image_raw /cam1/image_raw:=/camera/right/image_raw
rosrun ORB_SLAM3 Stereo Vocabulary/ORBvoc.txt Examples/Stereo/EuRoC.yaml true

# Monocular-Inertial单目+IMU
rosbag play --pause MH_01_easy.bag /cam0/image_raw:=/camera/image_raw /imu0:=/imu
rosrun ORB_SLAM3 Mono_Inertial Vocabulary/ORBvoc.txt Examples/Monocular-Inertial/EuRoC.yaml true

注意,其中rosbag是以暂停的形式开始的,按空格键启动发送。

如果要用自己的相机测试,需要将topic名字替换成自己用的相机的输入,配置文件 .yaml 改成自己相机的配置。

roscore
rosrun ORB_SLAM3 MonoAR Vocabulary/ORBvoc.txt Examples/Monocular/EuRoC.yaml 
rosrun ORB_SLAM3 Stereo Vocabulary/ORBvoc.txt Examples/Stereo/EuRoC.yaml true

得,到这里好不容易把.bag跑完了,又遇到了新问题:
QObject::~QObject: Timers cannot be stopped from another thread

这个暂时不影响结果,我也不知道咋解决…(苦涩)


3.3 精度评定

evaluate_ate_scale 可以用来评测单目SLAM运动估计效果

# 仅双目相机
./Examples/Stereo/stereo_euroc ./Vocabulary/ORBvoc.txt ./Examples/Stereo/EuRoC.yaml ../dataset/MH_03 ./Examples/Stereo/EuRoC_TimeStamps/MH03.txt

# 使用evaluate_ate_scale.py评定误差精度
python evaluation/evaluate_ate_scale.py evaluation/Ground_truth/EuRoC_left_cam/MH03_GT.txt KeyFrameTrajectory.txt --plot MH03_stereo.pdf

得到(0.031998,0.996112,0.028380)
(absolute_translational_error.rmse, scale, absolute_translational_errorGT.rmse)

在这里插入图片描述

OK,ORB-SLAM3在数据集下基本跑通了,未来还要自制数据集,精度评定的部分也不太明白,冲冲冲!

  • 6
    点赞
  • 60
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值