ORB-SLAM3代码下载地址:ORB-SLAM3源码下载
所有的操作都是在完成以下网址中的所有操作内容下进行的:Ubuntu系统安装之后首需要做的事情
本文是总结的比较完善和直接的过程。
其实在整个运行中也遇到了一些问题,也做了一些总结,记录在了文章
ORB-SLAM3复现过程中遇到的问题及解决办法中
建议是先以本文为主,有问题之后再去参考问题解决办法。
在一键安装ROS后,只需要再安装Pangolin即可,其他所有的需要都已经存在。
依次执行以下命令即可:
#依赖项
sudo apt-get install libglew-dev
sudo apt-get install cmake
sudo apt-get install libpython2.7-dev
sudo apt-get install ffmpeg libavcodec-dev libavutil-dev libavformat-dev libswscale-dev libavdevice-dev
sudo apt-get install libdc1394-22-dev libraw1394-dev
sudo apt-get install libjpeg-dev libpng-dev libtiff5-dev libopenexr-dev
#下载编译
git clone https://github.com/stevenlovegrove/Pangolin.git
cd Pangolin
mkdir build
cd build
cmake ..
cmake --build .
sudo make install
这样下载下来的是Pangolin0.8。在ORB-SLAM3中是可以正常使用的。
由于许多库的版本不一样,所以有部分代码需要更改
这里先声明我的环境:
Ubuntu20.04
Opencv4.2.0
C++11
Eigen3.3.7
Python3.8.10
Pangolin0.8
gedit /home/xiaoduan/project/source2/orb_slam3/CMakeLists.txt
#第33行Opencv的版本改为4
#第41行Eigen的版本改为3
gedit /home/xiaoduan/project/source2/orb_slam3/Examples_old/ROS/ORB_SLAM3/CMakeLists.txt
更改内容如下:
- 第33行Opencv的版本改为4
- 第41行Eigen的版本改为3
- 第49行,加入${PROJECT_SOURCE_DIR}/…/…/…/Thirdparty/Sophus
gedit /Examples/Monocular/mono_euroc.cc
更改内容:
第83行中的false改为true
gedit ~/.bashrc
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:PATH/ORB_SLAM3/Examples_old/ROS
source ~/.bashrc
注意: 第二条命令中的${ROS_PACKAGE_PATH}是自己文件的路径。
在ORB_SLAM3中的src下有个AR文件夹,里面的一些内容会导致ros可执行文件的编译,做出以下修改:
#include
#include
cv::Mat Tcw;
Sophus::SE3f Tcw_SE3f = mpSLAM->TrackMonocular(cv_ptr->image,cv_ptr->header.stamp.toSec());
Eigen::Matrix4f Tcw_Matrix = Tcw_SE3f.matrix();
cv::eigen2cv(Tcw_Matrix, Tcw);
cv::Mat WorldPos;
cv::eigen2cv(pMP->GetWorldPos(), WorldPos);
vPoints.push_back(WorldPos);
cv::Mat Xw;
cv::eigen2cv(pMP->GetWorldPos(), Xw);
按顺序执行以下命令即可:
cd ORB_SLAM3
chmod +x build.sh
./build.sh
执行以下命令:
cd Examples_old/ROS/ORB_SLAM3
chmod +x build_ros.sh
./build_ros.sh
用微型飞行器采集的视觉惯性数据集,包含双目相机和IMU同步测量数据及位姿的真值。
数据集需下载MH_01_easy.zip,下载地址:MH_01_easy.zip下载地址
将数据集解压,命名为MH01。
运行命令:
注意: 命令中的${dir}是个人数据的存放路径
cd Examples
./Monocular/mono_euroc ../Vocabulary/ORBvoc.txt ./Monocular/EuRoC.yaml ${dir}/MH01 ./Monocular/EuRoC_TimeStamps/MH01.txt dataset-MH01_mono
./Examples/Stereo/stereo_euroc ./Vocabulary/ORBvoc.txt ./Examples/Stereo/EuRoC.yaml ${dir}/MH01 ./Examples/Stereo/EuRoC_TimeStamps/MH01.txt dataset-MH01_stereo
./Examples/Monocular-Inertial/mono_inertial_euroc ./Vocabulary/ORBvoc.txt ./Examples/Monocular-Inertial/EuRoC.yaml ${dir}/MH01 ./Examples/Monocular-Inertial/EuRoC_TimeStamps/MH01.txt dataset-MH01_monoi
./Examples/Stereo-Inertial/stereo_inertial_euroc ./Vocabulary/ORBvoc.txt ./Examples/Stereo-Inertial/EuRoC.yaml ${dir}/MH01 ./Examples/Stereo-Inertial/EuRoC_TimeStamps/MH01.txt dataset-MH01_stereoi
其采用的相机和IMU传感器,在硬件上进行了时间同步。
所提供的图像具有高动态范围,事先进行了光度标定,用20Hz的帧率采集,分辨率为1024像素*1024像素;三轴IMU采样频率为200Hz,可测量加速度和角速度。
需要下载数据集dataset-room1_512_16和rgbd_dataset_freiburg1_desk。下载地址:TUM数据集下载
cd Examples
./Monocular/mono_tum_vi ../Vocabulary/ORBvoc.txt Monocular/TUM_512.yaml ${dir}/dataset-room1_512_16/mav0/cam0/data Monocular/TUM_TimeStamps/dataset-room1_512.txt dataset-room1_512_mono
./Stereo/stereo_tum_vi ../Vocabulary/ORBvoc.txt Stereo/TUM_512.yaml ${dir}/dataset-room1_512_16/mav0/cam0/data /home/sangfor/2023/bro_ws/dataset-room1_512_16/mav0/cam1/data Stereo/TUM_TimeStamps/dataset-room1_512.txt dataset-room1_512_stereo
./Monocular-Inertial/mono_inertial_tum_vi ../Vocabulary/ORBvoc.txt Monocular-Inertial/TUM_512.yaml ${dir}/dataset-room1_512_16/mav0/cam0/data Monocular-Inertial/TUM_TimeStamps/dataset-room1_512.txt Monocular-Inertial/TUM_IMU/dataset-room1_512.txt dataset-room1_512_monoi
./Monocular-Inertial/mono_inertial_tum_vi ../Vocabulary/ORBvoc.txt Monocular-Inertial/TUM_512.yaml ${dir}/dataset-room1_512_16/mav0/cam0/data Monocular-Inertial/TUM_TimeStamps/dataset-room1_512.txt Monocular-Inertial/TUM_IMU/dataset-room1_512.txt dataset-room1_512_monoi
./Examples/RGB-D/rgbd_tum Vocabulary/ORBvoc.txt Examples/RGB-D/TUM1.yaml ${dir}/rgbd_dataset_freiburg1_desk /home/sangfor/2023/bro_ws/rgbd_dataset_freiburg1_desk/associations.txt
首先,打开三个
终端
在第一个终端上面运行roscore
接着在其余两个终端上,分别运行以下命令:
rosrun ORB_SLAM3 Mono Vocabulary/ORBvoc.txt Examples/Monocular/EuRoC.yaml
rosbag play MH_01_easy.bag /cam0/image_raw:=/camera/image_raw
rosrun ORB_SLAM3 Stereo Vocabulary/ORBvoc.txt Examples/Stereo/EuRoC.yaml false
rosbag play MH_01_easy.bag /cam0/image_raw:=/camera/left/image_raw /cam1/image_raw:=/camera/right/image_raw
rosrun ORB_SLAM3 Mono_Inertial Vocabulary/ORBvoc.txt Examples/Monocular-Inertial/EuRoC.yaml
rosbag play MH_01_easy.bag
rosrun ORB_SLAM3 Stereo_Inertial Vocabulary/ORBvoc.txt Examples/Stereo-Inertial/EuRoC.yaml false
rosbag play MH_01_easy.bag /cam0/image_raw:=/camera/left/image_raw /cam1/image_raw:=/camera/right/image_raw /imu0:=/imu
TUM
数据集的下载网址。rosrun ORB_SLAM3 RGBD Vocabulary/ORBvoc.txt Examples/RGB-D/TUM1.yaml
rosbag play rgbd_dataset_freiburg1_xyz.bag