毕设突然要搞SLAM,想先跑一个框架试试,以为很容易,但是按照网上的教程来遇到很多坑,总结一下成功的方法,避免以后忘了。。。
参考https://www.cnblogs.com/liujiaxin2018/p/14207930.html
sudo apt-get install cmake
sudo apt-get install git
sudo apt-get install gcc g++
首先要安装一些Pangolin所需要的依赖库:
sudo apt-get install libglew-dev
sudo apt-get install libboost-dev libboost-thread-dev libboost-filesystem-dev
sudo apt-get install libboost-all-dev
sudo apt-get install libpython2.7-dev
然后可以进行Pangolin的安装:
git clone git://github.com/stevenlovegrove/Pangolin.git
在Pangolin文件夹下打开终端:
mkdir build
cd build
cmake -DCPP11_NO_BOOSR=1 ..
make
如果遇到问题,参考https://www.icode9.com/content-4-1134365.html
安装3以上的,先安装依赖库
sudo apt-get install build-essential
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
然后在OpenCV的官网上http://opencv.org/releases.html下载好压缩包,解压,然后编译安装,(本人下载3.4.10):
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release –D CMAKE_INSTALL_PREFIX=/usr/local ..
make
sudo make install
sudo apt-get install libeigen3-dev
先下载
git clone git://github.com/UZ-SLAMLab/ORB_SLAM3.git
打开DBoW2,在其终端执行
mkdir build
cd build
cmake
make
打开ORB_SLAM3文件夹,把build.sh和build_ros.sh中的make -j改为make,
打开CMakeLists.txt,写入这句话set( CMAKE_CXX_FLAGS “-std=c++14” )
将find_package(OpenCV 4.0) 改为find_package(OpenCV 3.0)并在前面加入这两句 find_package set(OpenCV_DIR /home/ubantu/桌面/opencv-3.4.10/build)build为你自己安装的opencv路径
find_package(OpenCV REQUIRED)
在ORB_SLAM3文件夹终端执行
chmod +x ./build.sh
./build.sh
TUM数据集:http://vision.in.tum.de/data/datasets/rgbd-dataset/download
EuRoc数据集:https://projects.asl.ethz.ch/datasets/doku.php?id=kmavvisualinertialdatasets
运行(以EuRoc中的MH_05为例),在ORB_SLAM3文件夹下新建一个文件夹MH_05,将MH_05解压到此文件夹里,在ORB_SLAM3终端运行:
./Examples/Monocular-Inertial/mono_inertial_euroc ./Vocabulary/ORBvoc.txt ./Examples/Monocular-Inertial/EuRoC.yaml ./MH05 ./Examples/Monocular-Inertial/EuRoC_TimeStamps/MH05.txt
注释:
跑EuRoc数据集:
将MH01复制到dataset中,在ORB_SLAM3中运行如下代码(以MH05为例):
单目+IMU:./Examples/Monocular-Inertial/mono_inertial_euroc ./Vocabulary/ORBvoc.txt ./Examples/Monocular-Inertial/EuRoC.yaml ./dataset/MH05 ./Examples/Monocular-Inertial/EuRoC_TimeStamps/MH05.txt
单目:./Examples/Monocular/mono_euroc ./Vocabulary/ORBvoc.txt ./Examples/Monocular/EuRoC.yaml ./dataset/MH05 ./Examples/Monocular/EuRoC_TimeStamps/MH05.txt
双目+IMU:./Examples/Stereo-Inertial/stereo_inertial_euroc ./Vocabulary/ORBvoc.txt ./Examples/Stereo-Inertial/EuRoC.yaml ./dataset/MH05 ./Examples/Stereo-Inertial/EuRoC_TimeStamps/MH05.txt
双目:./Examples/Stereo/stereo_euroc ./Vocabulary/ORBvoc.txt ./Examples/Stereo/EuRoC.yaml ./dataset/MH05 ./Examples/Stereo/EuRoC_TimeStamps/MH05.txt
结果分析:
生成了一个文件KeyFrameTrajectory.txt,第1列为时间,第2-4列分别是关键帧的位置坐标x,y,z,5-7列是姿态四元数q1,q2,q3,qw.X、Y、Z三轴分别指向相机右侧、下侧和沿着光轴指向正前方