sudo apt-get install git
git clone https://github.com/UZ-SLAMLab/ORB_SLAM3.git
CMakeLists.txt
CMake2.8以上
OpenCV3.0/2.4.3以上
Eigen3 3.1.0
Pangolin
PCL1.7
cmake_minimum_required(VERSION 2.8) #指定CMAKE最小版本为2.8
project(PlanarSLAM) #设置项目名称为PlanarSLAM,支持所有语言
# 指定构建类型为Release
IF (NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Release)
ENDIF ()
# 向终端输出当前构建类型
MESSAGE("Build type: " ${CMAKE_BUILD_TYPE})
# 设置编译器选项,编译过程输出警告信息,使用O3等级优化,自动检测CPU型号并使用增强指令集
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O3 -march=native ")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O3 -march=native")
#set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Check C++11 or C++0x support
# 包含CheckCXXCompilerFlag.cmake文件
# include了这个才能调用CHECK_CXX_COMPILER_FLAG
include(CheckCXXCompilerFlag)
# 下面这一大段都是用于检查当前编译器是否支持c++11
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if (COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
add_definitions(-DCOMPILEDWITHC11)
message(STATUS "Using flag -std=c++11.")
elseif (COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
add_definitions(-DCOMPILEDWITHC0X)
message(STATUS "Using flag -std=c++0x.")
else ()
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif ()
# 在指定要搜索的CMake模块的目录中添加cmake_modules
LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules)
# 用于查找指定的package(OPENCV3.0)
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 ()
# 输出OPENCV版本信息
message(OPENCV_VERSION)
# 找这几个库
find_package(Eigen3 3.1.0 REQUIRED)
find_package(Pangolin REQUIRED)
find_package(PCL 1.7 REQUIRED)
# 添加包含目录
include_directories(
${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/g2oAddition
${EIGEN3_INCLUDE_DIR}
${Pangolin_INCLUDE_DIRS}
${PCL_INCLUDE_DIRS}
)
# 下面三句利用Cmake的宏完成对pcl的头文件路径和链接路径变量的配置和添加
# 若没有这几句,.cpp文件的头文件则会出现报错
include_directories(include/peac)
add_definitions(${PCL_DEFINITIONS})
link_directories(${PCL_LIBRARY_DIRS})
# 一些变量:
# PCL_FOUND:如果找到PCL,则设置为1,否则未设置
# PCL_INCLUDE_DIRS:设置为PCL安装的标头和依赖标头的路径
# PCL_LIBRARIES:设置为已建立和已安装的PCL库的文件名
# PCL_LIBRARY_DIRS:设置为PCL库和第三方依赖关系所在的路径
# PCL_VERSION:找到的PCL的版本
# PCL_COMPONENTS:列出所有可用的组件
# PCL_DEFINITIONS:列出所需的预处理程序定义和编译器标志
# 即生成的共享库/静态库在工程文件夹下的lib文件夹中
# 其中CMAKE_LIBRARY_OUTPUT_DIRECTORY为指定共享库或者静态库的输出目录
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
# 生成共享库
add_library(${PROJECT_NAME} SHARED
src/System.cc
src/Tracking.cc
src/LocalMapping.cc
src/LoopClosing.cc
src/ORBextractor.cc
src/ORBmatcher.cc
src/FrameDrawer.cc
src/Converter.cc
src/MapPoint.cc
src/MapLine.cpp
src/KeyFrame.cc
src/Map.cc
src/MapDrawer.cc
src/Optimizer.cc
src/PnPsolver.cc
src/Frame.cc
src/KeyFrameDatabase.cc
src/Sim3Solver.cc
src/Initializer.cc
src/Viewer.cc
src/LineExtractor.cpp
src/LSDextractor.cpp
src/LSDmatcher.cpp
src/PlaneExtractor.cpp
src/Config.cc
src/MapPlane.cc
src/MeshViewer.cc
src/PlaneMatcher.cpp
Thirdparty/triangle/triangle.cpp
)
# 自定义搜索规则
file(GLOB sources "*.cpp")
# 设置链接库
target_link_libraries(${PROJECT_NAME}
${OpenCV_LIBS}
${EIGEN3_LIBS}
${Pangolin_LIBRARIES}
${PROJECT_SOURCE_DIR}/Thirdparty/DBoW2/lib/libDBoW2.so
${PROJECT_SOURCE_DIR}/Thirdparty/g2o/lib/libg2o.so
${PCL_LIBRARIES}
)
# Build examples
# 设置可执行文件的输出目录
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/Examples/RGB-D)
# 生成可执行文件
add_executable(Planar_SLAM Examples/RGB-D/main.cc)
# 设置链接库
target_link_libraries(Planar_SLAM ${PROJECT_NAME})
README
# PlanarSLAM
This repo proposes a RGB-D SLAM system specifically designed for structured environments and aimed at improved tracking and mapping accuracy by relying on geometric features that are extracted from the surrounding. More details can be found in our papers ([RGB-D](https://arxiv.org/abs/2010.07997) and [Monocular](https://arxiv.org/abs/2008.01963)).**Authors:** Yanyan Li, Raza Yunus, Nikolas Brasch, Nassir Navab and Federico Tombari
### updated on 11.12.2021
We updated the planar meshing section by making use of a more efficient triangulation method, rather than the greedy algorithm from PCL. If the PCL window shows nothing, maybe you could click "R" after selecting the window.
ps: the reconstruction method is still very naive, we will keep moving.
![planarReconstruction](Examples/planarReconstruction.png)
----
<a href="https://www.youtube.com/watch?v=zvmnCFIp58U"><img src="Examples/ICRA21-teasear.png"/></a>
## License
PlanarSLAM is released under a GPLv3 license.
For commercial purposes, please contact the authors: yanyan.li (at) tum.de. If you use PlanarSLAM in an academic work, please cite:
```
inproceedings{Li2021PlanarSLAM,
author = {Li, Yanyan and Yunus, Raza and Brasch, Nikolas and Navab, Nassir and Tombari, Federico},
title = {RGB-D SLAM with Structural Regularities},
year = {2021},
booktitle = {2021 IEEE international conference on Robotics and automation (ICRA)},
}
```## 1. Prerequisites
We have tested the library in **ubuntu 16.04** and **ubuntu 18.04**, but it should be easy to compile on 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 and **OpenCV_Contrib**
We use [OpenCV](http://opencv.org) and corresponding **OpenCV_Contrib** to manipulate images and features. Dowload and install instructions can be found at: http://opencv.org. **Tested with OpenCV 3.4.1**### 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.### PCL
We use [PCL](http://www.pointclouds.org/) to reconstruct and visualize mesh. Download and install instructions can be found at: https://github.com/ros-perception/perception_pcl. **Tested with PCL 1.7.0 and 1.9.0**.
1. https://github.com/PointCloudLibrary/pcl/releases
2. compile and install
```
cd pcl
mkdir release
cd release
cmake -DCMAKE_INSTALL_PREFIX=/usr/local \ -DBUILD_GPU=ON -DBUILD_apps=ON -DBUILD_examples=ON \ -DCMAKE_INSTALL_PREFIX=/usr/local -DPCL_DIR=/usr/local/share/pcl ..
make -j12
sudo make install
```## 2. Test the system
### Structural Public Scenes
[ICL NUIM](http://www.doc.ic.ac.uk/~ahanda/VaFRIC/iclnuim.html), [Structural TUM RGB-D](https://vision.in.tum.de/data/datasets/rgbd-dataset/download), All types of Corridors
### Test the system locally
1. Download **'freiburg3_structure_texture_far'** and associate RGB-D pairs based on [associate.py](http://vision.in.tum.de/data/datasets/rgbd-dataset/tools) provided by the dataset.
```
python associate.py PATH_TO_SEQUENCE/rgb.txt PATH_TO_SEQUENCE/depth.txt > associations.txt
```2. Compile the system
```
./build.sh
``` 3. Run the system
```
./Examples/RGB-D/Planar_SLAM Vocabulary/ORBvoc.txt Examples/RGB-D/TUM3.yaml PATH_TO_SEQUENCE_FOLDER .PATH_TO_SEQUENCE_FOLDER/ASSOCIATIONS_FILE
```*similar command for testing ICL-NUIM sequences*
```
./Examples/RGB-D/Planar_SLAM Vocabulary/ORBvoc.txt Examples/RGB-D/ICL.yaml PATH_TO_SEQUENCE_FOLDER PATH_TO_SEQUENCE_FOLDER/ASSOCIATIONS_FILE```
----
## Citation
```
inproceedings{Li2021PlanarSLAM,
author = {Li, Yanyan and Yunus, Raza and Brasch, Nikolas and Navab, Nassir and Tombari, Federico},
title = {RGB-D SLAM with Structural Regularities},
year = {2021},
booktitle = {2021 IEEE international conference on Robotics and automation (ICRA)},
}
```
```
inproceedings{Li2020SSLAM,
author = {Li, Yanyan and Brasch, Nikolas and Wang, Yida and Navab, Nassir and Tombari, Federico},
title = {Structure-SLAM: Low-Drift Monocular SLAM in Indoor Environments},
year = {2020},
booktitle = {IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS)},
}
```## Acknowledgement
ORB_SLAM2 and the corresponding community.
先决条件
作者已经在 ubuntu 16.04 和 ubuntu 18.04 中测试了该库,但它应该很容易在其他平台上编译。功能强大的计算机(例如i7)将确保实时性能并提供更稳定和准确的结果。
C++11或C++0x编译器
新线程和时间功能
Pangolin
可视化和用户界面
OpenCV 和 OpenCV_Contrib
处理图像
Eigen3
至少3.1.0,虽然这么说我用3.2.9失败了,见下文,最好还是卸了装3.1.0
DBoW2 和 g2o
使用修改版本的 DBoW2 库来执行位置识别,使用 g2o 库来执行非线性优化
PCL
可视化网格
GitHub - ros-perception/perception_pcl: PCL (Point Cloud Library) ROS interface stack
-
如果电脑比较查make -j12改成make防止死机cd pcl mkdir release cd release cmake -DCMAKE_INSTALL_PREFIX=/usr/local \ -DBUILD_GPU=ON -DBUILD_apps=ON -DBUILD_examples=ON \ -DCMAKE_INSTALL_PREFIX=/usr/local -DPCL_DIR=/usr/local/share/pcl .. make -j12 sudo make install
测试
公共数据集
ICL-NUIM RGB-D Benchmark Dataset
Computer Vision Group - Dataset Download (tum.de)
本地测试
freiburg3_structure_texture_far为例(在上面第二个链接里)
根据数据集提供的 associate.py 关联 RGB-D 对。
python associate.py PATH_TO_SEQUENCE/rgb.txt PATH_TO_SEQUENCE/depth.txt > associations.txt
报错:
报错信息:
Traceback (most recent call last):
File "associate.py", line 119, in <module>
matches = associate(first_list, second_list,float(args.offset),float(args.max_difference))
File "associate.py", line 96, in associate
first_keys.remove(a)
AttributeError: 'dict_keys' object has no attribute 'remove'
解决:
需要将associate.py中第86行87行的
first_keys = first_list.keys()
second_keys = second_list.keys()
改为
first_keys = list(first_list.keys())
second_keys = list(second_list.keys())
参考:https://blog.csdn.net/qq_36635888/article/details/108682551
编译系统
./build.sh
出现问题:电脑直接卡死
解决方法:将build.sh中的make -j改成make,即可成功编译
出现问题:无法生成可执行文件
疑似PCL版本不对,我使用的是1.8.0版本,但是作者测试的是1.7.0和1.9.0版本,这俩版本的pcl我下载后编译会报错(不知道为什么)所以我下了1.9.1版本,但是这样PlanarSLAM编译也通过不了,出现大量报错
[ 21%] Building CXX object CMakeFiles/PlanarSLAM.dir/src/FrameDrawer.cc.o
出现大量报错,程序中止,部分报错信息:
解决:eigen版本不对,我是3.2.9,改成3.1.0即可编译,参考这篇文章:
Ubuntu 16.04, 卸载&安装 Eigen_ganbaoni9yang的博客-CSDN博客
下载链接:ZReleases · libeigen / eigen · GitLabZ
报错:vtkSmartPointer.h: 没有那个文件或目录
解决:locate一下vtkSmartPointer.h,找到usr里面的这个文件,我的路径是/usr/local/include/vtk-7.1,在CMakeLists.txt中添加:
include_directories(/usr/local/include/vtk-7.1)
运行系统
./Examples/RGB-D/Planar_SLAM Vocabulary/ORBvoc.txt Examples/RGB-D/TUM3.yaml PATH_TO_SEQUENCE_FOLDER .PATH_TO_SEQUENCE_FOLDER/ASSOCIATIONS_FILE
用于测试 ICL-NUIM 序列的类似命令
./Examples/RGB-D/Planar_SLAM Vocabulary/ORBvoc.txt Examples/RGB-D/ICL.yaml PATH_TO_SEQUENCE_FOLDER PATH_TO_SEQUENCE_FOLDER/ASSOCIATIONS_FILE