# ORB-SLAM3_v0.4 **Repository Path**: CodeAlan3/orb-slam3 ## Basic Information - **Project Name**: ORB-SLAM3_v0.4 - **Description**: 个人实验记录: ORB-SLAM3_V0.4版本进行的相关更改,其中包含了: 1. BEBLID描述子的替换 2. BEBLID视觉词典的添加 - **Primary Language**: C++ - **License**: GPL-3.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 0 - **Created**: 2022-04-02 - **Last Updated**: 2025-06-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: slam ## README 该仓库为自己基于ORB-SLAM3—V0.4版本改进代码的记录,电脑内存太小,实在放不下了!!! --- ##### 该版本为第六版:ORB6_SLAM3_Fixed-master4(最后改成了原始的ORBSLAM) 【注:所有版本均是基于ORB-SLAM3_V0.4】 --- ### ORB0_SLAM3: 论文作者原始代码 ### ORB1_SLAM3_detailed_comments: 作者计算机视觉life 公众号旗下开源学习小组:SLAM研习社(详细注释版-当作代码参考) --- ### ORB2_SLAM3_Fixed-master: 作者shanpenghui 新增实际用T265相机运行的说明; 新增了MLPnP算法的详细注释;新增了RGBD运行shell; wk: [2021.12.06]只加入了BEBLID描述子,代码未作任何优化(耗时太长) wk: [2021.12.16]替换了txt词典为二进制格式ORBvoc.bin,加载速度更快 [2021.12.16]该工程文件的测试全部结束,之后将不再使用该工程进行进一步的修改... ### ORB3_SLAM3_Fixed-master2: 作者shanpenghui wk: 加入了BEBLID描述子,并对代码进行优化(注释掉一些不需要的内容) wk: 继续更改特征点提取数量 & 金字塔层数(尝试减少耗时) wk: [2021.12.16]替换了txt词典为二进制格式ORBvoc.bin,加载速度更快 [2021.12.16]该工程文件的测试全部结束,之后将不再使用该工程进行进一步的修改... ### ORB4_SLAM3_Fixed-master3: 作者shanpenghui wk: 对双目RGBD初始化进行进一步修改,使得特征点数目可以进一步下降 wk: 添加了自己训练的BEBLID词典词袋 ### ORB5_SLAM3_Fixed-master4 wk:虽然我添加了BEBLID词袋,但是当系统读取到一张图片后,依然是将其转换成ORB类型的视觉词袋,然后再与BEBLID类型的训练词典进行比较。 ### ORB6_SLAM3_Fixed-master4 (最后改成了原始的ORBSLAM) wk: 去除工程中许多用不上的东西,然后重新训练了词袋,**时间消耗的问题还没找到** wk:发现了其实每一个新输入的图片在提取词袋向量和特征向量的时候依然是点用的我的BEBLID描述子,并不是之前想的ORB描述子 wk: [20220223晚10点]时间问题搞定了,原来就是在`static void computeDescriptors(const Mat& image, vector& keypoints, Mat& descriptors, const vector& pattern)`这个函数里面,与词袋根本没有啥关系。 但是目前还存在偶尔跟丢的原因,不知道是不是词袋训练时候`BEBLID:creat(256,0.75)`中0.75的原因 wk:将代码中beblid部分删掉,用来测试原始orb算法的性能(测试5次,每次都不会跟丢,APE精度分别为~~0.119~~, 0.07, 0.09,0.03, 0.04) --- --- --- # ORB-SLAM3 The raw address: https://github.com/UZ-SLAMLab/ORB_SLAM3 Reference article 参考文章: >EVO Evaluation of SLAM 4 --- ORB-SLAM3 编译和利用数据集运行 >https://blog.csdn.net/shanpenghui/article/details/109354918 >EVO Evaluation of SLAM 5 --- ORB-SLAM3 精度和性能效果评估 >https://blog.csdn.net/shanpenghui/article/details/109361766 ## 新增了MLPnP算法的详细注释 ## 新增了RGBD运行shell ## 一、Install Third Party Pangolin: ```shell script git clone https://github.com/stevenlovegrove/Pangolin.git sudo apt install libglew-dev cd Pangolin && mkdir build && cd build cmake .. make -j 4 sudo make install ``` Googlelog: ```shell script git clone https://github.com/google/glog cd glog cmake -H. -Bbuild -G "Unix Makefiles" cmake --build build cmake --build build --target test cd build sudo make install ``` OpenCV: [https://docs.opencv.org/master/d0/d3d/tutorial_general_install.html](https://docs.opencv.org/master/d0/d3d/tutorial_general_install.html) ```shell script git clone https://github.com/opencv/opencv git -C opencv checkout 4.5.1 git clone https://github.com/opencv/opencv_contrib git -C opencv_contrib checkout 4.5.1 git clone https://github.com/opencv/opencv_extra git -C opencv_extra checkout 4.5.1 cmake .. make -j4 sudo make install ``` ## 二、Build ORB-SLAM3: Work in shells path, continue the operation upon: ```shell script cd shells ./build.sh ``` ## 三、Run ORB-SLAM3 in shell Before running, you should change the path in tum_vi.sh where you save the dataset, such as: ```shell script pathDatasetTUM_VI='/home/sph/Downloads' #Example, it is necesary to change it by the dataset path ``` **Remember to unzip the ORBvoc.txt.tar.gz into Vocabulary folder!!!** Work in shells path ```shell script cd shells ./tum_vi.sh or ./euroc.sh ``` ## 四、Run ORB-SLAM3 in ros Build ros version ```shell script cd shells ./build_ros.sh ``` Set ROS_PACKAGE_PATH: ```shell script export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/sph/Documents/ORB_SLAM3_Fixed/Examples/ROS ``` Run ros-version ORB-SLAM3 in root path: ```shell script cd ORB_SLAM3_Fixed rosrun ORB_SLAM3 Mono Vocabulary/ORBvoc.txt Examples/Monocular-Inertial/TUM_512.yaml ``` ## 五、注意: ### 1.目前只有单目带IMU的被激活,里面的配置需要对应自己的电脑更新 ### 2.原版出现的错误(因为本工程是在ORB3刚开放的时候就建立了,所以有些问题应该被作者修复了,如果有遗漏或冗余请读者自行忽略) 原版ros的编译会出现ORBSLAM2的错误 ```C++ error: ‘ORB_SLAM2’ has not been declared ImageGrabber(ORB_SLAM2::System* pSLAM):mpSLAM(pSLAM){} ``` 需要用指令修复: ```shell script sed -i "s/ORB_SLAM2/ORB_SLAM3/g" `grep -rl "ORB_SLAM2"` ``` 原版ros的编译也有可能出现找不到文件的错误: ```C++ fatal error: GeometricCamera.h: No such file or directory #include "GeometricCamera.h" ``` 需要在CMakeList添加文件路径: ```shell script ${PROJECT_SOURCE_DIR}/../../../include/CameraModels ``` ## 六、Use usb_cam to run camera_node But!!!! You can`t run ORB-SLAM3 without run the camera_node!!!! So, if you want to test ros-version, just use your computer camera(wish you have) ```shell script git clone https://github.com/bosch-ros-pkg/usb_cam.git ``` Build and launch it, so you can see the /usb_cam/image_raw in rostopic. But, that is not enough!!!!! You should change the rostopic name in ORB-SLAM3, which is in Line 62, ros_mono.cc ```C++ ros::Subscriber sub = nodeHandler.subscribe("/usb_cam/image_raw", 1, &ImageGrabber::GrabImage,&igb); ``` After the steps up, it work finally! #### 利用自己相机模块可能出现的问题 When I first run it, error come out: ```C++ Failed to load module "canberra-gtk-module" ``` To solve this problem, install the module: ```shell script sudo apt-get install libcanberra-gtk-module ``` -------------------------------------------------- -------------------------------------------------- # ORB-SLAM3 ### V0.3: Beta version, 4 Sep 2020 **Authors:** Carlos Campos, Richard Elvira, Juan J. Gómez Rodríguez, [José M. M. Montiel](http://webdiis.unizar.es/~josemari/), [Juan D. Tardos](http://webdiis.unizar.es/~jdtardos/). The [Changelog](https://github.com/UZ-SLAMLab/ORB_SLAM3/Changelog.md) describes the features of each version. ORB-SLAM3 is the first real-time SLAM library able to perform **Visual, Visual-Inertial and Multi-Map SLAM** with **monocular, stereo and RGB-D** cameras, using **pin-hole and fisheye** lens models. In all sensor configurations, ORB-SLAM3 is as robust as the best systems available in the literature, and significantly more accurate. We provide examples to run ORB-SLAM3 in the [EuRoC dataset](http://projects.asl.ethz.ch/datasets/doku.php?id=kmavvisualinertialdatasets) using stereo or monocular, with or without IMU, and in the [TUM-VI dataset](https://vision.in.tum.de/data/datasets/visual-inertial-dataset) using fisheye stereo or monocular, with or without IMU. Videos of some example executions can be found at [ORB-SLAM3 channel](https://www.youtube.com/channel/UCXVt-kXG6T95Z4tVaYlU80Q). This software is based on [ORB-SLAM2](https://github.com/raulmur/ORB_SLAM2) developed by [Raul Mur-Artal](http://webdiis.unizar.es/~raulmur/), [Juan D. Tardos](http://webdiis.unizar.es/~jdtardos/), [J. M. M. Montiel](http://webdiis.unizar.es/~josemari/) and [Dorian Galvez-Lopez](http://doriangalvez.com/) ([DBoW2](https://github.com/dorian3d/DBoW2)). ORB-SLAM3 ### Related Publications: [ORB-SLAM3] Carlos Campos, Richard Elvira, Juan J. Gómez Rodríguez, José M. M. Montiel and Juan D. Tardós, **ORB-SLAM3: An Accurate Open-Source Library for Visual, Visual-Inertial and Multi-Map SLAM**, Under review. **[PDF](https://arxiv.org/pdf/2007.11898.pdf)**. [IMU-Initialization] Carlos Campos, J. M. M. Montiel and Juan D. Tardós, **Inertial-Only Optimization for Visual-Inertial Initialization**, *ICRA 2020*. **[PDF](https://arxiv.org/pdf/2003.05766.pdf)** [ORBSLAM-Atlas] Richard Elvira, J. M. M. Montiel and Juan D. Tardós, **ORBSLAM-Atlas: a robust and accurate multi-map system**, *IROS 2019*. **[PDF](https://arxiv.org/pdf/1908.11585.pdf)**. [ORBSLAM-VI] Raúl Mur-Artal, and Juan D. Tardós, **Visual-inertial monocular SLAM with map reuse**, IEEE Robotics and Automation Letters, vol. 2 no. 2, pp. 796-803, 2017. **[PDF](https://arxiv.org/pdf/1610.05949.pdf)**. [Stereo and RGB-D] Raúl Mur-Artal and Juan D. Tardós. **ORB-SLAM2: an Open-Source SLAM System for Monocular, Stereo and RGB-D Cameras**. *IEEE Transactions on Robotics,* vol. 33, no. 5, pp. 1255-1262, 2017. **[PDF](https://arxiv.org/pdf/1610.06475.pdf)**. [Monocular] Raúl Mur-Artal, José M. M. Montiel and Juan D. Tardós. **ORB-SLAM: A Versatile and Accurate Monocular SLAM System**. *IEEE Transactions on Robotics,* vol. 31, no. 5, pp. 1147-1163, 2015. (**2015 IEEE Transactions on Robotics Best Paper Award**). **[PDF](https://arxiv.org/pdf/1502.00956.pdf)**. [DBoW2 Place Recognition] Dorian Gálvez-López and Juan D. Tardós. **Bags of Binary Words for Fast Place Recognition in Image Sequences**. *IEEE Transactions on Robotics,* vol. 28, no. 5, pp. 1188-1197, 2012. **[PDF](http://doriangalvez.com/php/dl.php?dlp=GalvezTRO12.pdf)** # 1. License ORB-SLAM3 is released under [GPLv3 license](https://github.com/UZ-SLAMLab/ORB_SLAM3/LICENSE). For a list of all code/library dependencies (and associated licenses), please see [Dependencies.md](https://github.com/UZ-SLAMLab/ORB_SLAM3/blob/master/Dependencies.md). For a closed-source version of ORB-SLAM3 for commercial purposes, please contact the authors: orbslam (at) unizar (dot) es. If you use ORB-SLAM3 in an academic work, please cite: @article{ORBSLAM3_2020, title={{ORB-SLAM3}: An Accurate Open-Source Library for Visual, Visual-Inertial and Multi-Map {SLAM}}, author={Campos, Carlos AND Elvira, Richard AND G\´omez, Juan J. AND Montiel, Jos\'e M. M. AND Tard\'os, Juan D.}, journal={arXiv preprint arXiv:2007.11898}, year={2020} } # 2. Prerequisites We have tested the library in **Ubuntu 16.04** and **18.04**, but it should be easy to compile in other platforms. A powerful computer (e.g. i7) will ensure real-time performance and provide more stable and accurate results. ## C++11 or C++0x Compiler We use the new thread and chrono functionalities of C++11. ## Pangolin We use [Pangolin](https://github.com/stevenlovegrove/Pangolin) for visualization and user interface. Dowload and install instructions can be found at: https://github.com/stevenlovegrove/Pangolin. ## OpenCV We use [OpenCV](http://opencv.org) to manipulate images and features. Dowload and install instructions can be found at: http://opencv.org. **Required at leat 3.0. Tested with OpenCV 3.2.0**. ## Eigen3 Required by g2o (see below). Download and install instructions can be found at: http://eigen.tuxfamily.org. **Required at least 3.1.0**. ## DBoW2 and g2o (Included in Thirdparty folder) We use modified versions of the [DBoW2](https://github.com/dorian3d/DBoW2) library to perform place recognition and [g2o](https://github.com/RainerKuemmerle/g2o) library to perform non-linear optimizations. Both modified libraries (which are BSD) are included in the *Thirdparty* folder. ## Python Required to calculate the alignment of the trajectory with the ground truth. **Required Numpy module**. * (win) http://www.python.org/downloads/windows * (deb) `sudo apt install libpython2.7-dev` * (mac) preinstalled with osx ## ROS (optional) We provide some examples to process input of a monocular, monocular-inertial, stereo, stereo-inertial or RGB-D camera using ROS. Building these examples is optional. These have been tested with ROS Melodic under Ubuntu 18.04. # 3. Building ORB-SLAM3 library and examples Clone the repository: ``` git clone https://github.com/UZ-SLAMLab/ORB_SLAM3.git ORB_SLAM3 ``` We provide a script `build.sh` to build the *Thirdparty* libraries and *ORB-SLAM3*. Please make sure you have installed all required dependencies (see section 2). Execute: ``` cd ORB_SLAM3 chmod +x build.sh ./build.sh ``` This will create **libORB_SLAM3.so** at *lib* folder and the executables in *Examples* folder. # 4. EuRoC Examples [EuRoC dataset](http://projects.asl.ethz.ch/datasets/doku.php?id=kmavvisualinertialdatasets) was recorded with two pinhole cameras and an inertial sensor. We provide an example script to launch EuRoC sequences in all the sensor configurations. 1. Download a sequence (ASL format) from http://projects.asl.ethz.ch/datasets/doku.php?id=kmavvisualinertialdatasets 2. Open the script "euroc_examples.sh" in the root of the project. Change **pathDatasetEuroc** variable to point to the directory where the dataset has been uncompressed. 3. Execute the following script to process all the sequences with all sensor configurations: ``` ./euroc_examples ``` ## Evaluation EuRoC provides ground truth for each sequence in the IMU body reference. As pure visual executions report trajectories centered in the left camera, we provide in the "evaluation" folder the transformation of the ground truth to the left camera reference. Visual-inertial trajectories use the ground truth from the dataset. Execute the following script to process sequences and compute the RMS ATE: ``` ./euroc_eval_examples ``` # 5. TUM-VI Examples [TUM-VI dataset](https://vision.in.tum.de/data/datasets/visual-inertial-dataset) was recorded with two fisheye cameras and an inertial sensor. 1. Download a sequence from https://vision.in.tum.de/data/datasets/visual-inertial-dataset and uncompress it. 2. Open the script "tum_vi_examples.sh" in the root of the project. Change **pathDatasetTUM_VI** variable to point to the directory where the dataset has been uncompressed. 3. Execute the following script to process all the sequences with all sensor configurations: ``` ./tum_vi_examples ``` ## Evaluation In TUM-VI ground truth is only available in the room where all sequences start and end. As a result the error measures the drift at the end of the sequence. Execute the following script to process sequences and compute the RMS ATE: ``` ./tum_vi_eval_examples ``` # 6. ROS Examples ### Building the nodes for mono, mono-inertial, stereo, stereo-inertial and RGB-D Tested with ROS Melodic and ubuntu 18.04. 1. Add the path including *Examples/ROS/ORB_SLAM3* to the ROS_PACKAGE_PATH environment variable. Open .bashrc file: ``` gedit ~/.bashrc ``` and add at the end the following line. Replace PATH by the folder where you cloned ORB_SLAM3: ``` export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:PATH/ORB_SLAM3/Examples/ROS ``` 2. Execute `build_ros.sh` script: ``` chmod +x build_ros.sh ./build_ros.sh ``` ### Running Monocular Node For a monocular input from topic `/camera/image_raw` run node ORB_SLAM3/Mono. You will need to provide the vocabulary file and a settings file. See the monocular examples above. ``` rosrun ORB_SLAM3 Mono PATH_TO_VOCABULARY PATH_TO_SETTINGS_FILE ``` ### Running Monocular-Inertial Node For a monocular input from topic `/camera/image_raw` and an inertial input from topic `/imu`, run node ORB_SLAM3/Mono_Inertial. Setting the optional third argument to true will apply CLAHE equalization to images (Mainly for TUM-VI dataset). ``` rosrun ORB_SLAM3 Mono PATH_TO_VOCABULARY PATH_TO_SETTINGS_FILE [EQUALIZATION] ``` ### Running Stereo Node For a stereo input from topic `/camera/left/image_raw` and `/camera/right/image_raw` run node ORB_SLAM3/Stereo. You will need to provide the vocabulary file and a settings file. For Pinhole camera model, if you **provide rectification matrices** (see Examples/Stereo/EuRoC.yaml example), the node will recitify the images online, **otherwise images must be pre-rectified**. For FishEye camera model, rectification is not required since system works with original images: ``` rosrun ORB_SLAM3 Stereo PATH_TO_VOCABULARY PATH_TO_SETTINGS_FILE ONLINE_RECTIFICATION ``` ### Running Stereo-Inertial Node For a stereo input from topics `/camera/left/image_raw` and `/camera/right/image_raw`, and an inertial input from topic `/imu`, run node ORB_SLAM3/Stereo_Inertial. You will need to provide the vocabulary file and a settings file, including rectification matrices if required in a similar way to Stereo case: ``` rosrun ORB_SLAM3 Stereo_Inertial PATH_TO_VOCABULARY PATH_TO_SETTINGS_FILE ONLINE_RECTIFICATION [EQUALIZATION] ``` ### Running RGB_D Node For an RGB-D input from topics `/camera/rgb/image_raw` and `/camera/depth_registered/image_raw`, run node ORB_SLAM3/RGBD. You will need to provide the vocabulary file and a settings file. See the RGB-D example above. ``` rosrun ORB_SLAM3 RGBD PATH_TO_VOCABULARY PATH_TO_SETTINGS_FILE ``` **Running ROS example:** Download a rosbag (e.g. V1_02_medium.bag) from the EuRoC dataset (http://projects.asl.ethz.ch/datasets/doku.php?id=kmavvisualinertialdatasets). Open 3 tabs on the terminal and run the following command at each tab for a Stereo-Inertial configuration: ``` roscore ``` ``` rosrun ORB_SLAM3 Stereo_Inertial Vocabulary/ORBvoc.txt Examples/Stereo-Inertial/EuRoC.yaml true ``` ``` rosbag play --pause V1_02_medium.bag /cam0/image_raw:=/camera/left/image_raw /cam1/image_raw:=/camera/right/image_raw /imu0:=/imu ``` Once ORB-SLAM3 has loaded the vocabulary, press space in the rosbag tab. **Remark:** For rosbags from TUM-VI dataset, some play issue may appear due to chunk size. One possible solution is to rebag them with the default chunk size, for example: ``` rosrun rosbag fastrebag.py dataset-room1_512_16.bag dataset-room1_512_16_small_chunks.bag ```