从零开始学习SLAM实战教程|【ORB_SLAM2】Ubuntu 20.04编译跑通ORB_SLAM2、ORB_SLAM3


文章目录

    • Command 'cmake' not found
    • No CMAKE_CXX_COMPILER could be found
    • OpenCV > 2.4.3 not found
      • 先安装ROS
      • The repository 'http://packages.ros.org/ros/ubuntu focal InRelease' is not signed.
    • PangolinConfig.cmake、pangolin-config.cmake
    • ORBextractor.h:26:10: fatal error: opencv/cv.h
    • Viewer.cc:160:17: error: ‘usleep’
    • stl_map.h:122:71: error: static assertion failed:
    • mono_tum.cc:68:68: error: ‘CV_LOAD_IMAGE_UNCHANGED’
    • 下载TUM单目数据集
    • 终端运行命令
    • 下载TUM RGBD数据集
    • 编译ORB_SLAM3
    • ORB_SLAM3源码解读

~/$ git clone https://github.com/raulmur/ORB_SLAM2 ~/$ cd ORB_SLAM2 ~/ORB_SLAM2$ ./build.sh hirdparty/DBoW2 ... mkdir: cannot create directory ‘build’: File exists ./build.sh: line 6: cmake: command not found ./build.sh: line 7: make: command not found Configuring and building Thirdparty/g2o ... mkdir: cannot create directory ‘build’: File exists ./build.sh: line 15: cmake: command not found ./build.sh: line 16: make: command not found Uncompress vocabulary ... Configuring and building ORB_SLAM2 ... mkdir: cannot create directory ‘build’: File exists ./build.sh: line 30: cmake: command not found ./build.sh: line 31: make: command not found

Command ‘cmake’ not found
sudo aptinstall cmake

No CMAKE_CXX_COMPILER could be found
sudo apt install -y build-essential

OpenCV > 2.4.3 not found 尝试安装ROS解决问题
先安装ROS
http://wiki.ros.org/noetic/Installation/Ubuntu

The repository ‘http://packages.ros.org/ros/ubuntu focal InRelease’ is not signed.
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F42ED6FBAB17C654

【从零开始学习SLAM实战教程|【ORB_SLAM2】Ubuntu 20.04编译跑通ORB_SLAM2、ORB_SLAM3】依然报错,最终更改编译文件解决
find_package(OpenCV 3.0 QUIET)/home/xq/ORB_SLAM2/Thirdparty/DBoW2/CMakeLists.txt find_package(OpenCV QUIET)/home/xq/ORB_SLAM2/CMakeLists.txt find_package(OpenCV QUIET)

安装ROS的时候会安装EIgen和OpenCV,我没有另外安装。
PangolinConfig.cmake、pangolin-config.cmake
下载 https://github.com/stevenlovegrove/Pangolin/archive/refs/tags/v0.6.zip

ORBextractor.h:26:10: fatal error: opencv/cv.h
#include 替换为 #include #include

从零开始学习SLAM实战教程|【ORB_SLAM2】Ubuntu 20.04编译跑通ORB_SLAM2、ORB_SLAM3
文章图片

Viewer.cc:160:17: error: ‘usleep’
/home/ORB_SLAM2/include/system.h #include

stl_map.h:122:71: error: static assertion failed:
/home/ORB_SLAM2/include/LoopClosing.htypedef map, Eigen::aligned_allocator::pair > > KeyFrameAndPose; 改为typedef map, Eigen::aligned_allocator::pair > > KeyFrameAndPose;

从零开始学习SLAM实战教程|【ORB_SLAM2】Ubuntu 20.04编译跑通ORB_SLAM2、ORB_SLAM3
文章图片

mono_tum.cc:68:68: error: ‘CV_LOAD_IMAGE_UNCHANGED’
replaced CV_LOAD_IMAGE_UNCHANGED with it's enum value -1

从零开始学习SLAM实战教程|【ORB_SLAM2】Ubuntu 20.04编译跑通ORB_SLAM2、ORB_SLAM3
文章图片

从零开始学习SLAM实战教程|【ORB_SLAM2】Ubuntu 20.04编译跑通ORB_SLAM2、ORB_SLAM3
文章图片

同样的编译./build_ros需要更改编译文件
从零开始学习SLAM实战教程|【ORB_SLAM2】Ubuntu 20.04编译跑通ORB_SLAM2、ORB_SLAM3
文章图片

添加环境变量
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/xq/ORB_SLAM2/Examples/ROS

下载TUM单目数据集 可添加微信 slamshizhaniaoheng 获取
终端运行命令
./Examples/Monocular/mono_tum Vocabulary/ORBvoc.txt Examples/Monocular/TUM1.yaml /home/xq/datasets/rgbd_dataset_freiburg1_xyz

下载TUM RGBD数据集 可添加微信 slamshizhaniaoheng 获取
./Examples/RGB-D/rgbd_tum Vocabulary/ORBvoc.txt Examples/RGB-D/TUM1.yaml /home/xq/datasets/rgbd_dataset_freiburg1_xyz /home/xq/datasets/rgbd_dataset_freiburg1_xyz/associations.txt

编译ORB_SLAM3 报错和解决方法同ORB_SLAM2
【ORB_SLAM3源码解读】Ubuntu 16.04 编译跑通 ORB_SLAM3 各个版本
【ORB_SLAM2】Ubuntu 20.04编译跑通ORB_SLAM2、ORB_SLAM3
【ORB_SLAM2源码解读】Ubuntu 16.04 TUM、EuRoC单目数据集跑通ORB_SLAM2
【ORB_SLAM2源码解读】Ubuntu 16.04 EuRoC双目数据集跑通ORB_SLAM2
【ORB_SLAM2源码解读】Ubuntu 16.04 TUM RGBD 数据集跑通ORB_SLAM2
【ORB_SLAM2源码解读】Ubuntu 16.04 RealSense D435i 实时跑ORB_SLAM2单目、双目、RGBD
ORB_SLAM3源码解读 【ORB_SLAM3源码解读】原理解读代码实战

    推荐阅读