错误1
错误2
错误3
错误4
错误5
错误6
错误7
错误8
TUM-RGBD测试
KITTI测试
EuRoC测试
写在前面~
ORB-SLAM2
github链接:GitHub - electech6/ORB_SLAM2_detailed_comments: Detailed comments for ORB-SLAM2 with trouble-shooting, key formula derivation, and diagrammatic drawing
参考数目:《视觉惯性SLAM理论与源码分析》
csdn报错参考链接
https://www.ngui.cc/zz/1185096.html?action=onClick
https://blog.csdn.net/m0_51030297/article/details/130545401#t36
https://blog.csdn.net/ABC_ORANGE/article/details/118497033
https://blog.csdn.net/catpico/article/details/118348240
数据集
TUM Dataset: Computer Vision Group - Dataset Download
KITTI Dataset:The KITTI Vision Benchmark Suite
EuRoC Dataset:kmavvisualinertialdatasets – ASL Datasets
但是上面官网下载很慢,书本也提供了全部数据库的下载
链接:https://pan.baidu.com/s/19KvkF1FUlWHCr1G8y0MdGQ
提取码:jl01
但是由于提供的百度云不是压缩包,即使开了SVIP,我也下载了三四天,也只是下载了一半。
下面这个是我的个人下载数据集测试(每个数据集只有一个项目,但基本可以满足测试)
链接:https://pan.baidu.com/s/1QoOrUBVPZSxtrkaqp37hcA?pwd=58gt
提取码:58gt
(注!KITTI是四个压缩包要一起下载后才能解压,建议在window解压)
!!!!
当然你可以下载完数据集后,按照下面的做法即可,不用自行取debug
本人安装库的是pangolin(v0.5),eigen(v3.4.0),Dow3,opencv(4.7.0).
建议将库修改为上面这些,这是编译时最稳定的搭配。
本人是在catkin_ws/src(取决于个人)下git clone
git clone https://github.com/electech6/ORB_SLAM2_detailed_comments.git
作者官网的./build.sh在Ubuntu20.04下是有问题的,这是win和linux的回车换行键不兼容引起的。
首先需要安装工具dos2unix,再dos2unix ./build.sh把它变成在Ubuntu20.04下可执行的脚本。
即
sudo apt install dos2unix
cd /ORB_SLAM2_detailed_comments
dos2unix ./build.sh
但是下面这个先走一遍错误再执行,即先不要执行!
./build.sh
报错1:FATAL_ERROR "OpenCV > 2.4.3 not found."的错误
或者 No rule to make target ‘…/Thirdparty/DBoW2/lib/libDBoW2.so’, needed by ‘…/lib/libORB_SLAM2.so’. Stop.
解决:将/ORB_SLAM2_detailed_comments/CMakeLists.txt
和/ORB_SLAM2_detailed_comments/Thirdparty/DBoW2/CMakeLists.txt中的opencv版本改成自己对应的版本
即
# find_package(OpenCV 3.0 QUIET)
# if(NOT OpenCV_FOUND)
# find_package(OpenCV 2.4.3 QUIET)
# if(NOT OpenCV_FOUND)
# message(FATAL_ERROR "OpenCV > 2.4.3 not found.")
# endif()
# endif()
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
报错2:error: ‘CV_LOAD_IMAGE_UNCHANGED’ was not declared in this scope
解决: 把Examples文件夹里.cc文件所有的这个名改成cv::IMREAD_UNCHANGED
(因为opencv新版本变量名换了)
EIGEN_DEPRECATED const unsigned int AlignedBit = 0x80(可以不用管,只是警告而已)
或者Pangolin could not be found because dependency Eigen3 could not be found.
(这两个就是pangolin和Eigen的版本问题)
解决:
关于pangolin v0.5和Eigen 3.2.1以上的版本的卸载与安装(如果装了3.2.1,后续catkin_make会报错,建议3.4.0)
卸载pangolin库
locate pangolin
sudo rm -rf XXX的路径
sudo updatedb
知道locate pangolin没有输出路径
安装pangolin v0.5库
https://github.com/stevenlovegrove/Pangolin/releases/tag/v0.5
到Pagolin/src文件夹下,在CMakeList.txt中注释掉下面这段代码(屏蔽掉ffmpeg的影响):
# find_package(FFMPEG QUIET)
# if(BUILD_PANGOLIN_VIDEO AND FFMPEG_FOUND)
# set(HAVE_FFMPEG 1)
# list(APPEND INTERNAL_INC ${FFMPEG_INCLUDE_DIRS} )
# list(APPEND LINK_LIBS ${FFMPEG_LIBRARIES} )
# list(APPEND HEADERS ${INCDIR}/video/drivers/ffmpeg.h)
# list(APPEND SOURCES video/drivers/ffmpeg.cpp)
# message(STATUS "ffmpeg Found and Enabled")
# endif()
cd Pangolin
mkdir build
cd build
cmake ..
make -j12
sudo make install
由于ORB-SLAM2需要低版本的Eigen(最好3.2.1以上),不然会报错EIGEN_DEPRECATED const unsigned int AlignedBit = 0x80;
查看自己Eigen版本
pkg-config --modversion eigen3
卸载
locate eigen3
sudo rm -rf /usr/include/eigen3
sudo rm -rf /usr/lib/cmake/eigen3
sudo rm -rf /usr/local/include/eigen3
sudo rm -rf /usr/share/doc/libeigen3-dev
sudo rm -rf /usr/local/share/pkgconfig/eigen3.pc /usr/share/pkgconfig/eigen3.pc /var/lib/dpkg/info/libeigen3-dev.list /var/lib/dpkg/info/libeigen3-dev.md5sums
sudo rm -rf /usr/local/lib/pkgconfig/eigen3.pc
sudo rm -rf /usr/local/share/eigen3
查看是否删除彻底
sudo updatedb
locate eigen3
pkg-config --modversion eigen3
Eigen3.4.0的安装
https://gitlab.com/libeigen/eigen/-/releases
找到3.4.0下载tar.gz
mkdir build
cd build
cmake..
sudo make install
sudo cp -r /usr/local/include/eigen3 /usr/include
# 检测当前版本
pkg-config --modversion eigen3
“opencv/cv.h not found”
解决
需要将ORBextractor.h改成:
#include
“orb_slam2/src/PnPsolver.cc:860:37: error: ‘CvMat’ was not declared in this scope”
也是因为opencv新版本的没有继承老版本的变量导致
解决:在System.h, PnPSolver.h, Sim3Solver.h 中都加入
#include
#include
using namespace cv;
报错: static assertion failed: std::map must have the same value_type as its allocator
解决:修改/ORB_SLAM2_detailed_comments/include/LoopClosing.h::50,
typedef map
Eigen::aligned_allocator
修改为
typedef map,
Eigen::aligned_allocator > > KeyFrameAndPose;
orb rror: ‘usleep’ was not declared in this scope
解决:
在System.h里添加
#include
LoopClosing.cc
mnFullBAIdx++;
解决:
// mnFullBAIdx++;
if (mnFullBAIdx==0)
{
mnFullBAIdx=1;
}
最后在/ORB_SLAM2_detailed_comments目录下
./build.sh
一堆warning没事,这是eigen低版本输出的信息而已,最后可以100%的。
数据集的话,三个都可以测试,其他测试类型可以参考github:GitHub - electech6/ORB_SLAM2_detailed_comments: Detailed comments for ORB-SLAM2 with trouble-shooting, key formula derivation, and diagrammatic drawing
下面进行测试
下面是在/ORB_SLAM2_detailed_comments终端下执行,凡是有mengs的,就是自己数据集的路径
./Examples/Monocular/mono_tum Vocabulary/ORBvoc.txt Examples/Monocular/TUM1.yaml /media/mengs/SSD/ubuntu-dateset/slam常用数据集/TUM-RGBD/rgbd_dataset_freiburg1_xyz
./Examples/Monocular/mono_kitti Vocabulary/ORBvoc.txt Examples/Monocular/KITTI00-02.yaml /media/mengs/SSD/ubuntu-dateset/slam常用数据集/KITTI/data_odometry_gray/00
./Examples/Stereo/stereo_euroc Vocabulary/ORBvoc.txt Examples/Stereo/EuRoC.yaml /media/mengs/SSD/ubuntu-dateset/slam常用数据集/EuRoC/MH_01_easy/mav0/cam0/data /media/mengs/SSD/ubuntu-dateset/slam常用数据集/EuRoC/MH_01_easy/mav0/cam1/data Examples/Stereo/EuRoC_TimeStamps/MH01.txt
其他错误
/usr/bin/ld: warning: libopencv_imgcodecs.so.4.2, needed by /opt/ros/noetic/lib/libcv_bridge.so, may conflict with libopencv_imgcodecs.so.3.4
或者
rospack found package “ORB_SLAM2” at “”, but the current directory is
“/home/zhangjian/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2”. You should
double-check your ROS_PACKAGE_PATH to ensure that packages are found in the correct
precedence order.
参考链接
使用ROS编译ORB-SLAM2时遇到的问题(已解决)_名字真的难想的博客-CSDN博客
报错
_ZNK2cv8FileNodecviEv' /usr/bin/ld: /lib/x86_64-linux-gnu/libopencv_core.so.4.2:
参考链接
编译工程需要Opencv3 与 ROS自带Opencv4冲突解决办法_秃头队长的博客-CSDN博客
报错
No rule to make target '/usr/lib/x86_64-linux-gnu/libIlmImf.so', needed by '../lib/libORB_SLAM2.so'. Stop.
CMakeFiles/Makefile2:178: recipe for target 'CMakeFiles/ORB_SLAM2.dir/all' failed
参考
sudo apt-get install libopenexr-dev
opencv卸载
[详细教程] opencv的完全卸载和重新安装--3.x版本与4.x版本_opencv卸载重装_HeyMountain的博客-CSDN博客
opencv3.4.11安装
Ubuntu 20.04 下安装 OpenCV 3.4.11 并测试使用_ubuntu opencv测试_罐装三斤的博客-CSDN博客
ROS环境下
ros由于个人电脑或者opencv版本的原因,即使./build_ros.sh成功,但运行rosrun ORB_SLAM2 Mono ~/catkin_ws/src/ORB_SLAM2/Vocabulary/ORBvoc.txt ~/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/Asus.yaml会立即闪退,换了opencv3,比较容易的版本是3.4.11,但却始终没法通过./build_ros.sh。所以自己又装回了4.7.0,后续ORB-SLAM3可能得一阵子才更新。
正常电脑参考下面这个链接即可
最完整---在ROS用自己电脑的摄像头在运行ORB_SLAM2_orb-slam2 ros_一大块肉松的博客-CSDN博客
2023.08.24