Build the compilation and running environment of ORB_SLAM3 under Linux

The environment construction has gone through a total of 10 main steps as follows:

1. Install VMware virtual machine and Ubuntu image
2. Download, compile and install CMake
3. Install python
4. Install and compile OpenCV
5. Install PANGOLIN 6.
Install boost library
7. Install Eigen 3
8. Install openssl-devel
9. Compile Source code
10. Download and run the dataset

After stepping on a lot of pitfalls, the process was quite difficult, but fortunately, it finally worked.

After the environment is built,
the optimization or idea of ​​the ORB_SLAM3 open source algorithm
can be modified in the source code, compiled, run and verified using the dataset, and the
algorithm innovation Idea can be put into practice.

​Note:
If there is an exception in the steps that require network links, downloads, etc. during the environment construction process,
first consider switching to the external network
. If it still does not work, then find out the reason

let's start!


1. Install VMware virtual machine and Ubuntu image:


  (1). Reference documents for installing VMware virtual machines and Ubuntu systems : 2020 latest version of VMware installation Ubuntu20.04 tutorial (size)! - Know almost

  During the installation of the Ubuntu image, when customizing the hardware settings, the automatically
  allocated virtual memory and hard disk are 2G and 20G,
  which need to be modified: memory: 10G, hard disk: 50G
  *If the virtual memory is too low, it will lead to the virtual machine when compiling ORB_SLAM3 directly stuck

If no modifications were made during the installation, they can also be modified after the installation is complete.
(2). Expand virtual memory:
  Just adjust the virtual memory directly here

  After the adjustment is complete, restart the virtual machine, and view it in the terminal with "free -m" or "free -g":

I also tried to create a swap partition for virtual memory expansion,
refer to the document:
[Problem Solving] C++: fatal error: Killed signal terminated program cc1plus_tiffiny10's Blog-CSDN Blog_c++fatal error how to solve
ubuntu setting swap (swap memory)_zzcchunter's Blog-CSDN Blog_ubuntu
This method of setting swap swap partition has been personally tested. It seems to be useless.
Later, it has been run after modifying it directly in "Edit Virtual Machine Settings".

(3) Expansion of the virtual hard disk
The expansion of the virtual hard disk is relatively troublesome

After entering the disk size, the "Extend" option will be highlighted, click "Extend".
Start the virtual machine and download "GParted Partition Editor" to expand the disk.
Reference document:
Insufficient disk space on Ubuntu? Easy expansion with one trick

(4). After the Ubuntu installation is complete, because Win10 uses Docker,
Ubuntu and Win10 will have Hyper-V compatibility issues

Modification method:
"Control Panel-->Programs and Features-->Enable or Disable Windows Features", uncheck the Hyper-V item

After unchecking, open cmd or powershell and enter:
  bcdedit /set hypervisorlaunchtype off
Reference document:

Your host does not meet the requirements of enabling hyper-v or Device/Credental..._mogexiuluo's blog-CSDN blog_Your host does not meet the requirements of enabling After the hyper-v or device is modified, the computer restarts and the virtual machine restarts

If you still have problems, refer to the following documents, try to modify the registry, close the virtual machine security service under Windows, etc.:
Your host does not meet the minimum requirements for running VMware Workstation with Hyper-V or Device/Credential Guard enabled_TATYBOY Blog-CSDN Blog_Your host is not satisfied. After enabling hyper-v or device
pro-test registry modification, the virtual machine runs normally.
But later, the registry was restored, and the newly added registry items were deleted, and there was no problem running the virtual machine again.
Therefore, it is not clear whether it is normal after restarting or after modifying the registry. This method is reserved for reference.


2. Download, compile and install CMake  

Method 1:
Linux command installation: sudo apt install cmake,
but it can only be installed to version 3.16.3.
Finally, when compiling ORB_SLAM3, a bunch of errors will be reported,
pit!

Method 2:
(1). Download the CMake source file to compile and install:

Download | CMake
Latest Release-->Source distributions-->cmake-3.23.1.tar.gz-->right click-->copy link address
terminal execution :
wget https://github.com/Kitware/CMake/releases/download/v3.23.1/cmake-3.23.1.tar.gz
       (the link address copied in the previous step)

(2). Decompression: tar -zxf cmake-3.23.1.tar.gz
(3). Enter the directory: cd cmake-3.23.1
(4). Configuration: ./configure --prefix=/home/shawn/ cmake-3.23.1/cmake-install
        or ./bootstrap --prefix=/home/shawn/cmake-3.23.1/cmake-install
(5). Compile: sudo make all
(6). Install: sudo make install
( 7). Add environment variables: sudo vim /etc/profile
(8). Add in the last line of the file:  export PATH=/home/shawn/cmake-3.23.1/bin:$PATH
(9). Check the version: cmake --version

If you can see the version number, the installation is successful.
Reference document:

https://www.jianshu.com/p/d51291c3e82e Linux cmake installation, configuration and testing_No. 1993 Blog-CSDN Blog

Method 3:
Terminal command: sudo snap install cmake –classic

In the process of setting up the environment this time, the CMake installation stepped on the pit of method 1, and then it was uninstalled and installed repeatedly.
Both method 2 and method 3 have been carried out, and I don’t know which one will take effect in the end.
It is recommended to try method 3 first, and then compile and install the source file of method 2 if it fails.
Uninstall command:
sudo apt remove cmake keep the configuration file
sudo apt purge cmake    uninstall cleanly


3. Install python

Terminal command: sudo apt install libpython2.7-dev
Check the version number: python -V 


4. Install and compile OpenCV

OpenCV is used for ORB feature point extraction

(1). Download OpenCV from the official website and select the sources version. The
download for this build is opencv3.4.16
download link:
Releases - OpenCV

The latest ORB_SLAM3 compilation requires opencv4.4, otherwise a compilation error will be reported,
but it doesn’t matter, opencv3.4.16 is completely sufficient, just modify the associated version of opencv in CMakeLists.txt in the ORB_SLAM3 source code.

(2). Unzip: unzip opencv-3.4.16.zip
Enter the opencv directory: cd opencv-3.4.16

(3). Install dependent libraries:
sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg.dev    libtiff4.dev libswscale-dev libjasper -dev
It installs:
Reference document:

The solution to unable to locate the package libjasper-dev_Xu Yeping's Blog-CSDN Blog_Unable to locate the package libjasper-dev Ubuntu18.04 to install the OpenCv dependency package libjasper-dev cannot be installed_SDUHXP Blog-CSDN Blog_libjasper

(4). Create a compilation directory (release) and enter: mkdir release && cd release

(5).cmake配置编译:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..

(6).make compile: make

(7). Installation: sudo make install

(8). Add library path to environment configuration:
sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'

(9). Update the system library: sudo ldconfig

(10). Configure bash: sudo gedit /etc/bash.bashrc

Add at the end of the file:
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig 
export PKG_CONFIG_PATH

Execute the command to make the configuration take effect: source /etc/bash.bashrc 
update: sudo updatedb 

Finally, there may be problems that the source and updatedb commands cannot be recognized.
Execute: sudo apt-get install mlocate
and then execute source and updatedb

(11). Use opencv’s built-in smaple to test whether the installation is successful
1. cd to the opencv-3.4.16/samples/cpp/example_cmake directory
2. Execute in sequence: cmake .
                      make
                      ./opencv_example

"Hello OpenCV" appears, indicating that the installation is successful

Reference document: Install opencv3.4.10 under ubuntu16.04 (super-detailed test was successful)


5. Install PANGOLIN

Pangolin is mainly used for visualization and user interface.

(1). The following tools need to be installed first, if installed, skip.
sudo apt-get install vim cmake   (Note: Check cmake version command cmake -version)
sudo apt-get install vim git       (Note: Check git version command git --version)
sudo apt-get install vim gcc g++  (Note: Check gcc g++ version command gcc -v g++ -v)

(2). Download the source code: https://github.com/stevenlovegrove/Pangolin

(3). Install according to the official installation method in the git link:
# Get Pangolin

cd ~/your_fav_code_directory
git clone --recursive https://github.com/stevenlovegrove/Pangolin.git
cd Pangolin

(I downloaded the source compression directly Package decompression, without using git clone)

# Install dependencies (as described above, or your preferred method)
# recommended

./scripts/install_prerequisites.sh

# Configure and build
mkdir build && cd build
cmake ..
cmake --build .

# GIVEME THE PYTHON STUFF!!!! (Check the output to verify selected python version)
cmake --build . -t pypangolin_pip_install

# Run me some tests! (Requires Catch2 which must be manually installed on Ubuntu.)
ctest

During the installation process of Pangolin, the following error occurred:
E: Unable to download http://cn.archive.ubuntu.com/ubuntu/pool/universe/f/flite/libflite1_2.1-release-3_amd64.deb Connection failed [IP: 91.189.91.39 80]
E: Several software packages cannot be downloaded, why not run apt-get update or add --fix-missing option and try again?

Solution:
connect to overseas network.


6. Install the boost library

(1). Download the compressed package: Index of main/release/1.79.0/source

(2). Execute the following commands in order to complete the compilation and installation:
Decompression:
tar -xzvf boost_1_79_0.tar.gz
cd into the decompressed folder, execute the command: sudo ./bootstrap.sh

(3). Execute the following command again , so that the header files will be installed under /usr/local/include by default, and the library files will be installed under /usr/local/lib by default. Execute
:
sudo ./b2 install ldconfig
           

Reference document:
Ubuntu16.04 install boost library- & Dafei- Blog Park
No compilation errors mentioned in the reference document were encountered during the installation process.
If you encounter any, please follow the instructions in the document to solve it.


7. Install Eigen 3

Source code installation: sudo apt-get install libeigen3-dev
can also be downloaded from the official website to compile and install locally (this method was not used in this build)

Reference document: Ubuntu18.04 two ways to install eigen3_don't quit's blog-CSDN Blog_ubuntu install eigen


8. Install openssl-devel

sudo apt-get install libssl-dev


9. Compile the source code

(1). Download the source code:  https://github.com/UZ-SLAMLab/ORB_SLAM3

(2) After decompression, go to the directory: cd ORB_SLAM3
The command to decompress the tar.gz file under Linux: tar –zxf
           The command to decompress the .zip file: unzip

(3) Modify the opencv version number in CMakeList.txt
As mentioned in step "5. Install and compile OpenCV", the opencv we installed is version 3.4.16, and the
source code compilation of ORB_SLAM3 requires 4.4. The version is wrong, and it will report when compiling The error is as follows:

CMake Error at CMakeLists.txt:8 (find_package):
  Could not find a configuration file for package "OpenCV" that is compatible
  with requested version "4".
  The following configuration files were considered but not accepted:
    /usr/local/share/OpenCV/OpenCVConfig.cmake, version: 3.4.16
-- Configuring incomplete, errors occurred!

Execute: sudo gedit CMakeLists.txt
Search: "find_package"
Find the place of opencv, modify it to the installed version number

(4) Solve the pits stepped on during the source code compilation process first!
 1. When compiling, many "-std=C++" related syntax errors may be reported. The specific reason may be the C++ support version and other issues.
    Solution: sudo gedit CMakeLists.txt 
    directly note the following two lines:

2. When running, you may encounter the following errors. Halfway through the compilation, the virtual machine crashes directly

 Solution: Virtual machine settings --> Display --> Accelerate 3D images (3), uncheck

(6) Compile the source code
  and execute the following commands in sequence:
  chmod +x build.sh
 ./build.sh
  

100%, no error reported, the source code compilation is complete
Next, download the dataset and run it.


10. Download and run the dataset

(1). Download the dataset:
kmavvisualinertialdatasets – ASL Datasets
This environment is built, and the downloaded V101 dataset is:

(2) Run the dataset:
1. Create a new Datasets folder in the ORC_SLAM3 directory
2. Copy the downloaded dataset to Datasets and decompress it
3. Execute the following command:
./Examples/Stereo/stereo_euroc ./Vocabulary/ORBvoc.txt ./Examples/Stereo/EuRoC.yaml ./Datasets ./Examples/Stereo/EuRoC_TimeStamps/V101.txt

Running result:
I originally recorded a running video, but I don’t know how to post it, so I’ll post a screenshot to show success

On the left is the frame-by-frame playback of the capture process of dataset scenes, feature points, trajectories, etc.
On the right is the effect of the algorithm operation, where you can choose to show/hide Point, KeyFrame, Gragh, etc.

So far, the Linux compilation and operating environment of ORB_SLAM3 has been built

The overall configuration process is carried out with reference to the following reference documents:
Compiling and running ORB_SLAM3 under Ubuntu 16.04 [Complete tutorial] - Gray letter network (software development blog aggregation) is
very grateful to the contributors of this reference document.

Guess you like

Origin blog.csdn.net/geyichongchujianghu/article/details/124293250