Ubuntu20.04 - new system re installation ORB-SLAM3 process (2022)

Write before:

I wanted to be in Ubuntu 18 We ran ORB-SLAM3 on 04, but I don't know which step was wrong. There were many errors in the last step of compilation. We couldn't find many solutions online, because we used to work in Ubuntu 18 04 ran Gaobo's slambook2 routine, installed multiple versions of libraries, felt that different libraries affected each other, and simply directly installed Ubuntu 20 04 build the operation environment from scratch, ubuntu18 We'll find a way after the mistake on 04.
(added a few days later: it's not the problem I installed. Maybe there were bug s in master and v1.0-release, which just made me catch up. Finally, I installed v0.4-beta successfully!!!)
Error code:

$ ./Examples/Monocular/mono_euroc ./Vocabulary/ORBvoc.txt ./Examples/Monocular/EuRoC.yaml ./dataset/MH_01_easy ./Examples/Monocular/EuRoC_TimeStamps/MH01.txt
num_seq = 1
Loading images for sequence 0...LOADED!

-------

ORB-SLAM3 Copyright (C) 2017-2020 Carlos Campos, Richard Elvira, Juan J. Gómez, José M.M. Montiel and Juan D. Tardós, University of Zaragoza.
ORB-SLAM2 Copyright (C) 2014-2016 Raúl Mur-Artal, José M.M. Montiel and Juan D. Tardós, University of Zaragoza.
This program comes with ABSOLUTELY NO WARRANTY;
This is free software, and you are welcome to redistribute it
under certain conditions. See LICENSE.txt.

Input sensor was set to: Monocular
Loading settings from ./Examples/Monocular/EuRoC.yaml
Camera1.k3 optional parameter does not exist...
	-Loaded camera 1
	-Loaded image info
	-Loaded ORB settings
Viewer.imageViewScale optional parameter does not exist...
	-Loaded viewer settings
System.LoadAtlasFromFile optional parameter does not exist...
System.SaveAtlasToFile optional parameter does not exist...
	-Loaded Atlas settings
System.thFarPoints optional parameter does not exist...
	-Loaded misc parameters
----------------------------------
SLAM settings: 
	-Camera 1 parameters (Pinhole): [ 458.65399169921875 457.29598999023438 367.21499633789062 248.375 ]
	-Camera 1 distortion parameters: [  -0.28340810537338257 0.073959067463874817 0.00019359000725671649 1.7618711353861727e-05 ]
	-Original image size: [ 752 , 480 ]
	-Current image size: [ 600 , 350 ]
	-Camera 1 parameters after resize: [  365.94735717773438 333.44500732421875 292.99069213867188 181.10678100585938 ]
	-Sequence FPS: 20
	-Features per image: 1000
	-ORB scale factor: 1.2000000476837158
	-ORB number of scales: 8
	-Initial FAST threshold: 20
	-Min FAST threshold: 7


Loading ORB Vocabulary. This could take a while...
Vocabulary loaded!

Initialization of Atlas from scratch 
Creation of new map with id: 0
Creation of new map with last KF id: 0
Seq. Name: 
There are 1 cameras in the atlas
Camera 0 is pinhole
First KF:0; Map init KF:0
New Map created with 346 points
Shutdown

Saving trajectory to CameraTrajectory.txt ...
There are 1 maps in the atlas
  Map 0 has 299 KFs

End of saving trajectory to CameraTrajectory.txt ...

Saving keyframe trajectory to KeyFrameTrajectory.txt ...

Ubuntu18.04 - new system re installation ORB-SLAM3 process
Please rest assured that the following installation process is correct
Environmental description:
Virtual machine VMware + Ubuntu 20 04 + Win10(i5-8500)

1, Preparation:

Copy and paste terminal and host

sudo apt-get autoremove open-vm-tools
sudo apt-get install open-vm-tools-desktop


Restart virtual machine VMware
After vmtools is installed, restart through the setting button in the upper right corner, not through the restart in the upper left corner of vmware.

1. Install git

sudo apt-get install git

2. Install vi editor

Uninstall the old vim before installing the new one.

sudo apt-get remove vim-common
sudo apt-get install vim

3. Install the c + + compiler

sudo apt install g++

4. Installation CMake-3.18.4

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

# View version
cmake -version

5. Download the ORB-SLAM3 source code

First create a new directory for the source code.

mkdir orb_slam3
cd orb_slam3
git clone https://github.com/UZ-SLAMLab/ORB_SLAM3.git

At this stage, the preparations have been basically completed, and the next step is to install other libraries.

2, Install various dependent Libraries

1.Eigen3.3.4 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 file is installed in / usr/local/include/eigen3/

2.Pangolin installation

install Pangolin Required dependencies
sudo apt install libgl1-mesa-dev
sudo apt install libglew-dev
//sudo apt install cmake / / note that the previous installation is unnecessary
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
# The default git version is 0.6
//git clone https://github.com/stevenlovegrove/Pangolin.git  
//Pit! What a hole! Pangolin master version cannot be installed
git clone https://github.com/stevenlovegrove/Pangolin/tree/v0.6.git    
cd Pangolin
mkdir build && cd build
cmake ..
make -j4
sudo make install

Check for successful installation:

cd examples/HelloPangolin
./HelloPangolin

3.OpenCV3.3.5 installation

sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
sudo apt update
sudo apt install libjasper1 libjasper-dev

sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg.dev libtiff4.dev libswscale-dev libjasper-dev

Here I made a mistake:

obtain:1 http://202.199.28.2/files/4135000001411F7F/http.kali.org/kali focal/main amd64 m4 amd64 1.4.18-4 [199 kB]
error:1 http://202.199.28.2/files/4135000001411F7F/http.kali.org/kali focal/main amd64 m4 amd64 1.4.18-4
  File size mismatch(202872 != 199128). The image you are using is being synchronized? [IP: 202.199.28.2 80]
  Hashes of expected file:
   - SHA256:1ffa955ebb58829f3ab0debf7ad57b150887f6a44769edbaef68b8da9d95f306
   - SHA1:e65ec1a9d9c7ee858f50b3408bfedb9f675b1069 [weak]
   - MD5Sum:3785537d21012e0e481f0fea152b04a1 [weak]
   - Filesize:199128 [weak]
E: Unable to download http://202.199.28.2/files/4135000001411F7F/http.kali.org/kali/pool/main/m/m4/m4_1.4.18-4_amd64.deb file size does not match (202872! = 199128). The image you are using is being synchronized? [IP: 202.199.28.2 80]
   Hashes of expected file:
    - SHA256:1ffa955ebb58829f3ab0debf7ad57b150887f6a44769edbaef68b8da9d95f306
    - SHA1:e65ec1a9d9c7ee858f50b3408bfedb9f675b1069 [weak]
    - MD5Sum:3785537d21012e0e481f0fea152b04a1 [weak]
    - Filesize:199128 [weak]
E: Several software packages cannot be downloaded or run apt-get update Or add --fix-missing Try again?

After changing a lot of sources, it didn't work. Finally, it was found that it was libgtk2 The problem of 0-dev dependency

sudo apt install libgtk2.0-dev --fix-missing

Download opencv3 three point five
Then enter the unzipped folder and open it at the terminal
Next, on the command line, enter:

# Configure and compile
mkdir build&& cd build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..

Note: after executing the above instructions, the terminal will automatically download a necessary ippicv acceleration library.
If the computer is configured with vpn and enters the Internet, it will be stuck for a while to download;

Solution: download the offline ippicv library

//If the download of ippicv package is too slow, the installation will be interrupted and you can download it yourself
https://github.com/opencv/opencv_3rdparty/tree/ippicv/master_20180723
//I put the package ippicv in / home/sfann2/sfann/software /

"file:///##/##/Download / "# (for reference only, fill in according to your own path)
//I will“ https://raw.githubusercontent.com/opencv/opencv_3rdparty/${IPPICV_COMMIT}/ippicv/" 
//Replace with“ file:///home/sfann2/sfann/software/ippicv/ "Watch the semicolon

//Recompile
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
make -j4
sudo make install

Replacement process:

After recompilation:

At this point, OpenCV is installed, and then we configure the environment

#Add library path
sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
 
#Update system library
sudo ldconfig
#Configure bash
sudo gedit /etc/bash.bashrc

# 1. Paste the following two lines of code at the end
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig  
export PKG_CONFIG_PATH 

# 2. Save and execute the following commands to make the configuration effective:
source /etc/bash.bashrc 

#to update
apt-get install mlocate
sudo updatedb  
#opencv version detection
pkg-config --modversion opencv

4. Install Python & libssl dev

sudo apt install libpython2.7-dev
sudo apt-get install libssl-dev

5. Install the boost library

Boost is a powerful, exquisitely constructed, cross platform, open source and completely free C + + library.
Enter the boost official website: https://www.boost.org/
Or the same as I downloaded Download is 1.75.0

Run after decompression

sudo ./bootstrap.sh
sudo ./b2 install

3, Install ORB-SLAM3

cd ORB_SLAM3
chmod +x build.sh
./build.sh

If the compilation fails, you can enter build SH compiles step by step, that is, slow down and take a long time;

echo "Configuring and building Thirdparty/DBoW2 ..."
 
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

//If you can't, you can replace it with make -j4

Possible compilation errors:

make[2]: *** [CMakeFiles/ORB_SLAM3.dir/build.make:89: CMakeFiles/ORB_SLAM3.dir/src/LocalMapping.cc.o] Error 1
 
make[2]: *** [CMakeFiles/ORB_SLAM3.dir/build.make:349: CMakeFiles/ORB_SLAM3.dir/src/CameraModels/KannalaBrandt8.cpp.o] Error 1

terms of settlement:
In the error file, such as kannalbrandt8 cpp,LocalMapping.cc

Add the following code after include

namespace cv
{
template<typename _Tp, int m, int n> static inline
Matx<_Tp, m, n> operator / (const Matx<_Tp, m, n> &a, float alpha)
{
return Matx<_Tp, m, n>(a, 1.f / alpha, Matx_ScaleOp());
}
}


4, Dataset testing

1. Data set download

Method 1:
Data set download address Download ASL format
Method 2:
Alicloud disk MH01

2. Modify dataset

  1. Download from the official website Euroc dataset , ASL format;
  2. Path: ORB_SLAM3/dataset/MH_##/mav0 (for example, the file name of MH01 after decompression is mav0. Create a new MH01 folder in the dataset folder and put mav0 in it. Do not directly modify the file name!!!)
  3. Double click the script "euroc_examples.sh" in the ORB-SLAM3 source code to find the instruction containing MH01
./Examples/Monocular/mono_euroc ./Vocabulary/ORBvoc.txt ./Examples/Monocular/EuRoC.yaml "$pathDatasetEuroc"/MH01 ./Examples/Monocular/EuRoC_TimeStamps/MH01.txt dataset-MH01_mono
//Modify dataset path
./Examples/Monocular/mono_euroc ./Vocabulary/ORBvoc.txt ./Examples/Monocular/EuRoC.yaml ./dataset/MH01 ./Examples/Monocular/EuRoC_TimeStamps/MH01.txt

5, Result display


Operation results:

$ ./Examples/Monocular/mono_euroc ./Vocabulary/ORBvoc.txt ./Examples/Monocular/EuRoC.yaml ./dataset/MH_01_easy ./Examples/Monocular/EuRoC_TimeStamps/MH01.txt
num_seq = 1
Loading images for sequence 0...LOADED!

-------

ORB-SLAM3 Copyright (C) 2017-2020 Carlos Campos, Richard Elvira, Juan J. Gómez, José M.M. Montiel and Juan D. Tardós, University of Zaragoza.
ORB-SLAM2 Copyright (C) 2014-2016 Raúl Mur-Artal, José M.M. Montiel and Juan D. Tardós, University of Zaragoza.
This program comes with ABSOLUTELY NO WARRANTY;
This is free software, and you are welcome to redistribute it
under certain conditions. See LICENSE.txt.

Input sensor was set to: Monocular

Loading ORB Vocabulary. This could take a while...
Vocabulary loaded!

Creation of new map with id: 0
Creation of new map with last KF id: 0
Seq. Name: 

Camera Parameters: 
- Camera: Pinhole
- fx: 458.65399169921875
- fy: 457.29598999023438
- cx: 367.21499633789062
- cy: 248.375
- k1: -0.28340810537338257
- k2: 0.073959067463874817
- p1: 0.00019359000725671649
- p2: 1.7618711353861727e-05
- fps: 20
- color order: RGB (ignored if grayscale)

ORB Extractor Parameters: 
- Number of Features: 1000
- Scale Levels: 8
- Scale Factor: 1.2000000476837158
- Initial Fast Threshold: 20
- Minimum Fast Threshold: 7
Framebuffer with requested attributes not available. Using available framebuffer. You may see visual artifacts.First KF:0; Map init KF:0
New Map created with 315 points
Point distribution in KeyFrame: left-> 315 --- right-> 0
TRACK_REF_KF: Less than 15 matches!!
KF in map: 278
Fail to track local map!
Fail to track local map!
Fail to track local map!
Fail to track local map!
Fail to track local map!
Fail to track local map!
Fail to track local map!
Fail to track local map!
Fail to track local map!
Relocalized!!
Fail to track local map!
Fail to track local map!
Relocalized!!
MakeCurrent: Not available with non-pangolin window.

Saving trajectory to CameraTrajectory.txt ...

End of saving trajectory to CameraTrajectory.txt ...

Saving keyframe trajectory to KeyFrameTrajectory.txt ...

7, Possible error reporting

Solution: download the dataset again

Keywords: github slam

Added by geny on Thu, 06 Jan 2022 01:26:00 +0200