ORB-SLAM2报错集合(数据集测试系列1)

目录

错误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


报错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


报错2:error: ‘CV_LOAD_IMAGE_UNCHANGED’ was not declared in this scope

解决: 把Examples文件夹里.cc文件所有的这个名改成cv::IMREAD_UNCHANGED
(因为opencv新版本变量名换了)

错误3


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


错误4


“opencv/cv.h not found”
解决
需要将ORBextractor.h改成:

#include <opencv2/opencv.hpp>

错误5


“orb_slam2/src/PnPsolver.cc:860:37: error: ‘CvMat’ was not declared in this scope”

也是因为opencv新版本的没有继承老版本的变量导致


解决:在System.h, PnPSolver.h, Sim3Solver.h 中都加入

#include <opencv2/imgproc/types_c.h>
#include <opencv2/opencv.hpp>
using namespace cv;


错误6


报错: static assertion failed: std::map must have the same value_type as its allocator
解决:修改/ORB_SLAM2_detailed_comments/include/LoopClosing.h::50,

 typedef map<KeyFrame*,g2o::Sim3,std::less<KeyFrame*>,
   Eigen::aligned_allocator<std::pair<const KeyFrame*, g2o::Sim3> > > KeyFrameAndPose;
修改为

typedef map<KeyFrame*,g2o::Sim3,std::less<KeyFrame*>,
    Eigen::aligned_allocator<std::pair<KeyFrame* const, g2o::Sim3> > > KeyFrameAndPose;


错误7


orb rror: ‘usleep’ was not declared in this scope

解决:
在System.h里添加

#include <unistd.h>

错误8

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的,就是自己数据集的路径
 

TUM-RGBD测试

./Examples/Monocular/mono_tum Vocabulary/ORBvoc.txt Examples/Monocular/TUM1.yaml /media/mengs/SSD/ubuntu-dateset/slam常用数据集/TUM-RGBD/rgbd_dataset_freiburg1_xyz

KITTI测试

./Examples/Monocular/mono_kitti Vocabulary/ORBvoc.txt Examples/Monocular/KITTI00-02.yaml /media/mengs/SSD/ubuntu-dateset/slam常用数据集/KITTI/data_odometry_gray/00

EuRoC测试

./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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值