ORBSLAM3
官方链接:https://github.com/UZ-SLAMLab/ORB_SLAM3
安装依赖
C++11 Compiler
需要用到C++11的特性
sudo apt install gcc g++ build-essential cmake
Pangolin
官方链接:https://github.com/stevenlovegrove/Pangolin
选择安装0.6版本,是怕新版本cmake版本不够
git clone -b v0.6 --depth=1 https://github.com/stevenlovegrove/Pangolin.git
旧版本没有scripts安装依赖,根据0.6版本的README安装依赖
# openGL
sudo apt install libgl1-mesa-dev
# Glew
sudo apt install libglew-dev
# Cmake
sudo apt install cmake
# python
sudo apt install libpython2.7-dev
# Wayland
sudo apt install pkg-config
# FFMPEG
sudo apt install ffmpeg libavcodec-dev libavutil-dev libavformat-dev libswscale-dev libavdevice-dev
# DC1394
sudo apt install libdc1394-22-dev libraw1394-dev
# libjpeg, libpng, libtiff, libopenexr
sudo apt install libjpeg-dev libpng-dev libtiff5-dev libopenexr-dev
编译测试
cd Pangolin/
mkdir build && cd build
cmake ..
cmake --build . # make应该也可以
sudo make install
./examples/HelloPangolin/HelloPangolin # 测试
OpenCV
官方链接:https://opencv.org,我安装的是3.4.0版本
git clone -b 3.4.0 --depth=1 https://github.com/opencv/opencv.git opencv-3.4.0
cd opencv-3.4.0/
mkdir build && cd build
cmake -D CMAKE_BUILD_TYPE=Release ..
make
sudo make install
# 测试
cd ../samples/cpp/example_cmake/
mkdir build && cd build
cmake .. && make
./opencv_example
cd .. && rm -r build # 测试完删掉
Eigen3
官方链接:https://eigen.tuxfamily.org/index.php?title=Main_Page
安装
sudo apt install libeigen3-dev
检查版本,保证在3.1.0之前
whereis eigen3
cat /usr/include/eigen3/Eigen/src/Core/util/Macros.h | head -n 20
编译
最新版本要opencv大于4.4.0,编译0.4版本
git clone -b v0.4-beta --depth=1 https://github.com/UZ-SLAMLab/ORB_SLAM3.git
cd ORB_SLAM3
可以直接通过build.sh编译,这个文件实现了DBoW2、g2o的编译,字典的解压,以及ORB-SLAM3的编译
为了避免中途报错不好定位问题,我打算一步一步执行
编译DBoW2
cd Thirdparty/DBoW2
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make
cd ../../../
编译g2o
cd Thirdparty/g2o
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make
cd ../../../
解压字典
cd Vocabulary
tar -xf ORBvoc.txt.tar.gz
cd ..
编译ORB-SLAM3
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make
报错解决
报错:recipe for target ‘CMakeFiles/ORB_SLAM3.dir/src/LocalMapping.cc.o’ failed
ORB_SLAM3/include/CameraModels/KannalaBrandt8.h 添加以下代码
namespace cv
{
template<typename _Tp, int m, int n> static inline Matx<_Tp, m, n> operator / (const Matx<_Tp, m, n>& a, float alpha)
{
return Matx<_Tp, m, n>(a, 1.f / alpha, Matx_ScaleOp());
}
}
测试
数据集链接:https://projects.asl.ethz.ch/datasets/doku.php?id=kmavvisualinertialdatasets
以MH_01_easy为例
cd ORB_SLAM3
mkdir dataset && cd dataset
wget http://robotics.ethz.ch/~asl-datasets/ijrr_euroc_mav_dataset/machine_hall/MH_01_easy/MH_01_easy.zip
unzip MH_01_easy.zip -d ./MH01 # 这里MH01是脚本里的默认名
cd ../Examples
gedit ./euroc_examples.sh # 修改数据集路径为 ../dataset/ 后保存
./euroc_examples.sh # 运行 画面关闭ctrl+c关闭就好了
评估
ORB-SLAM3提供了多种视觉SLAM方案
单目:ORB_SLAM3/Examples/Monocular
单目+IMU:ORB_SLAM3/Examples/Monocular-Inertial
双目:ORB_SLAM3/Examples/Stereo
双目+IMU:ORB_SLAM3/Examples/Stereo-Inertial
以单目+IMU为例,
代码在ORB_SLAM3/Examples/Monocular-Inertial/mono_inertial_euroc.cc
看得到运行命令为:
./mono_inertial_euroc \
path_to_vocabulary \
path_to_settings \
path_to_sequence_folder_1 path_to_times_file_1 \
(path_to_image_folder_2 path_to_times_file_2 ... path_to_image_folder_N path_to_times_file_N)
运行
cd ORB_SLAM3
./Examples/Monocular-Inertial/mono_inertial_euroc \
./Vocabulary/ORBvoc.txt \
./Examples/Monocular-Inertial/EuRoC.yaml \
./dataset/MH01 \
./Examples/Monocular-Inertial/EuRoC_TimeStamps/MH01.txt
轨迹文件保存在ORB_SLAM3/CameraTrajectory.txt
关键帧轨迹文件保存在ORB_SLAM3/KeyFrameTrajectory.txt
用evo转换GT文件为tum文件,然后写python脚本统一时间戳单位后就可以评估了