orb-slam3 Compilation Manual (Ubuntu20.04)
- 1. Environmental requirements
-
- 1.Install git
- 2. Install g++
- 3. Install CMake
- 4. Install vi editor
- 2. Source code download
- 3. Download dependent libraries
-
- 1. Eigen installation
- 2.Pangolin installation
- 3.opencv installation
- 4. Install Python & libssl-dev
- 5. Install boost library
- 3. Install orb-slam3
- 4. Data set download and testing
Written before: This article is a complete record of compiling and running orb-slam3 from scratch on the Ubuntu20.04 system. I believe that even students with zero foundation can perfectly run orb-slam3 after following this blog. stand up. This article covers the entire compilation process from environment configuration, installation of dependencies, source code acquisition to data set download, and code testing. It is an easy-to-understand and follow guide to ensure that users can successfully build and compile code projects.
1. Environmental requirements
The author compiled it successfully on the Ubuntu20.04 system. I am not sure whether it will be OK for other versions.
1. Install git
View git version
git --version
If the version number is not displayed, it means that git is not installed on the system. Use the following command to install it.
sudo apt install git
Check the git version number again:
2. Install g++
View g++ version
g + + --version
If an error is reported, install g++
sudo apt install g++
Check the g++ version number again
3. Install CMake
sudo apt install build-essential libssl-dev wget https://github.com/Kitware/CMake/releases/download/v3.18.4/cmake-3.18.4.tar.gz tar -zxvf cmake-3.18.4.tar.gz cd cmake-3.18.4 ./bootstrap make sudo make install
After installation, check the version number. As shown in the figure, the installation is successful.
4. Install vi editor
sudo apt-get remove vim-common sudo apt-get install vim
At this point, the environmental requirements of orb-slam3 are met. Next, download the source code.
2. Source code download
Save the source code of orb-slam3 in your newly created folder.
mkdir orb_slam3 cd orb_slam3 git clone https://github.com/UZ-SLAMLab/ORB_SLAM3.git
If your computer has problems accessing github, you can try git changing the source. There are a lot of solutions after searching.
3. Dependent library download
1.Eigen installation
#github has a mirror, version 3.3.4 from 2017 git clone https://github.com/eigenteam/eigen-git-mirror #Install cd eigen-git-mirror mkdir build cd build cmake.. sudo make install #After installation, the header files are installed in /usr/local/include/eigen3/
2.Pangolin installation
Install the required dependencies of Pangolin
If it prompts that it is already installed, just skip it.
sudo apt install libgl1-mesa-dev sudo apt install libglew-dev //sudo apt install cmake //Note that if you installed it before, you don’t need to install it. sudo apt install libpython2.7-dev //sudo apt install python-pip //sudo python -mpip install numpy pyopengl pillow pybind11 sudo apt install pkg-config sudo apt install libegl1-mesa-dev libwayland-dev libxkbcommon-dev wayland-protocols //sudo apt install ffmpeg libavcodec-dev libavutil-dev libavformat-dev libswscale-dev libavdevice-dev //sudo apt install libdc1394-22-dev libraw1394-dev //sudo apt install libjpeg-dev libpng-dev libtiff5-dev libopenexr-dev
Install Pangolin
# The default git version is 0.6 git clone https://github.com/stevenlovegrove/Pangolin/tree/v0.6.git cd Pangolin mkdir build & amp; & amp; cd build cmake.. make -j4 sudo make install
If git cannot access this URL, you can manually download and decompress the compressed package, and then compile and install it. It is the same.
Test after successful installation.
cd examples/HelloPangolin ./HelloPangolin
If a cube appears that can be dragged freely, it proves that the installation is successful.
3.opencv installation
Skip it here. There are many tutorials on the Internet. Since my computer has opencv4.2, I skipped this step directly.
It should be noted that although opencv3/4 is available, you need to change one place for your own opencv version during the make process of the entire project, otherwise an error will be reported, which will be mentioned later.
4. Install Python & libssl-dev
sudo apt install libpython2.7-dev
sudo apt-get install libssl-dev
5. Install boost library
Enter boost official website: https://www.boost.org/
I downloaded version 1.75
After downloading, unzip and run in the folder:
sudo ./bootstrap.sh sudo ./b2 install
3. Install orb-slam3
Before compiling and installing, modify one place. The code location is as follows:
If the last bool type here is false, please change it to true. This bool type is a parameter that controls the visualization of the results of the euroc data set run by the monocular camera. If it is false, it will not be visualized during operation.
It can be done in one step, but it is easy to cause problems and difficult to find.
cd ORB_SLAM3 chmod +x build.sh ./build.sh
If an error is reported in the above method, it is recommended to follow the step by step below. In fact, it means compiling and installing sub-folders one by one. Although it is troublesome, it is easy to locate the problem.
cd Thirdparty/DBoW2 mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=Release make cd ../../g2o echo "Configuring and building Thirdparty/g2o ..." mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=Release make cd ../../../ echo "Uncompress vocabulary ..." cd Vocabulary tar -xf ORBvoc.txt.tar.gz cd.. echo "Configuring and building ORB_SLAM3 ..." mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=Release make -j4
Note that the opencv version problem mentioned earlier, if an error is reported during the make process
FATAL_ERROR OpenCV > 3.2 not found
If an error is reported during the make process in whichever folder, go to the CMakeLists file in that folder and look for the following code block:
The find_package here needs to be changed to your own opencv version, otherwise an error will be reported.
After compilation is completed, you can download the data set for testing.
4. Data set download and testing
- Go to the official website (https://projects.asl.ethz.ch/datasets/doku.php?id=kmavvisualinertialdatasets) to download the ASL format data set. For example, what I downloaded here is the ASL format data set of MH01. After downloading, it is a compressed Bag, put it aside first.
- Create a new dataset folder in the orb-slam3 project directory, create a new folder MH01 under the dataset folder, and drag the decompressed mav0 folder of the just downloaded dataset into the MH01 folder.
- Double-click to open the script “euroc_examples.sh” in the ORB-SLAM3 source code and find the instructions containing MH01, such as the shortcut command for the monocular camera:
./Examples/Monocular/mono_euroc ./Vocabulary/ORBvoc.txt ./Examples/Monocular/EuRoC.yaml "$pathDatasetEuroc"/MH01 ./Examples/Monocular/EuRoC_TimeStamps/MH01.txt dataset-MH01_mono
Modify "$pathDatasetEuroc"
to ./dataset. The modified command is as follows:
./Examples/Monocular/mono_euroc ./Vocabulary/ORBvoc.txt ./Examples/Monocular/EuRoC.yaml ./dataset/MH01 ./Examples/Monocular/EuRoC_TimeStamps/MH01.txt dataset-MH01_mono
Run the above command in the terminal, the results are as follows:
At this point, the compilation and operation of orb-slam3 is successful.