Notes

Make sure to practice on Ubuntu 18.04 to avoid potential build failures caused by different version of tools.

  • If you are running Windows, you can make use of WSL2 or VMware to raise up one Ubuntu 18.04 instance.

  • If you are running Linux but not Ubuntu 18.04, then you can try Incus(formerly LXD), LXC, systemd-nspawn or QEMU/KVM to run a Ubuntu 18.04 image.

Ubuntu 18.04 on WSL2

Dependencies

Use a mirror if needed.

1
2
sudo sed -i 's@//.*archive.ubuntu.com@//mirrors.ustc.edu.cn@g' /etc/apt/sources.list
sudo apt update && sudo apt upgrade

Get necessary tools and libs.

1
2
sudo apt install git cmake gcc g++
sudo apt install libglew-dev libeigen3-dev libopencv-dev libboost-dev libssl-dev libboost-serialization-dev

Build & Install Pangolin

Get the source code from GitHub. Use --depth=1to save download time and disk storage by only acquiring the latest version.

1
2
mkdir ~/repos && cd ~/repos
git clone --depth=1 https://github.com/stevenlovegrove/Pangolin.git pangolin && cd pangolin

Configure the project with CMake by generating build configuration files in build/. The CMAKE_BUILD_TYPE option should be set to ensure you get the Release build (not Debug or something else), which allows a higher perfomance.

1
2
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release

Build the project with GNU Make according to the Makefile you just generated. Use -j to make use of all CPU cores and accelerate the compiling.

1
make -j

Be aware that there exist new syntaxes for Configure and Build, though Pangolin uses a low CMake version which does not support them:

1
2
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build

Install Pangolin into system for later use.

1
sudo make install

Refresh cached list of shared libraries to ensure Pangolin be correctly found and linked later.

1
sudo ldconfig

Build ORB-SLAM3

Get the source code from GitHub. The tested version is v0.4-beta.

1
2
cd ~/repos
git clone --branch v0.4-beta https://github.com/UZ-SLAMLab/ORB_SLAM3.git orb-slam && cd orb-slam

The system-wide installed OpenCV version is 3.x, while ORB-SLAM3 uses 4.x. A simple workaround would be modifying include/CameraModels/KannalaBrandt8.h by adding these lines:

1
2
3
4
5
6
7
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());
}
}

Build with build.sh.

1
chmod +x build.sh && ./build.sh

If you ran into errors like c++: internal compiler error: killed (program cc1plus), it’s possibly caused by a lack of memory. Try the methods below:

  • Allocate more memory to the virtual machine / container.

  • Adopt make instead of make -j to occupy less system resource.

  • Use Swap Memory.

Test and Judge

Take EuRoc Dateset - MH03 for an example. Download and extract files to ~/repos/orb-slam/Examples/Datasets/EuRoc/.

Mono Data

Refer to euroc_examples.sh and find Mono processing command. This will generate two txt files. The f- one stands for the whole track while the kf- one stands for the key frame track.

1
2
cd ~/repos/orb-slam/Examples
./Monocular/mono_euroc ../Vocabulary/ORBvoc.txt ./Monocular/EuRoC.yaml ./Datasets/EuRoc/MH03 ./Monocular/EuRoC_TimeStamps/MH03.txt dataset-MH03_mono

Refer to euroc_eval_examples.sh and find the corresponding judging command. This will generate a pdf file.

You may need to install some libraries for python:

1
sudo apt install python-numpy python-matplotlib
1
2
cd ~/repos/orb-slam/Examples
python ../evaluation/evaluate_ate_scale.py ../evaluation/Ground_truth/EuRoC_left_cam/MH03_GT.txt f_dataset-MH03_stereo.txt --plot MH03_stereo.pdf

Whole Dataset

The whole script would be like below. Edit and run it under ~/repos/orb-slam/Examples to judge the whole dataset.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env bash
pathDatasetEuroc='./Datasets/EuRoC'

# Mono
./Monocular/mono_euroc ../Vocabulary/ORBvoc.txt ./Monocular/EuRoC.yaml "$pathDatasetEuroc"/MH03 ./Monocular/EuRoC_TimeStamps/MH03.txt dataset-MH03_mono
python ../evaluation/evaluate_ate_scale.py ../evaluation/Ground_truth/EuRoC_left_cam/MH03_GT.txt f_dataset-MH03_mono.txt --plot MH03_mono.pdf

# Stereo
./Stereo/stereo_euroc ../Vocabulary/ORBvoc.txt ./Stereo/EuRoC.yaml "$pathDatasetEuroc"/MH03 ./Stereo/EuRoC_TimeStamps/MH03.txt dataset-MH03_stereo
python ../evaluation/evaluate_ate_scale.py ../evaluation/Ground_truth/EuRoC_left_cam/MH03_GT.txt f_dataset-MH03_stereo.txt --plot MH03_stereo.pdf

# Mono + INS
./Monocular-Inertial/mono_inertial_euroc ../Vocabulary/ORBvoc.txt ./Monocular-Inertial/EuRoC.yaml "$pathDatasetEuroc"/MH03 ./Monocular-Inertial/EuRoC_TimeStamps/MH03.txt dataset-MH03_monoi
python ../evaluation/evaluate_ate_scale.py "$pathDatasetEuroc"/MH03/mav0/state_groundtruth_estimate0/data.csv f_dataset-MH03_monoi.txt --plot MH03_monoi.pdf

# Stereo + INS
./Stereo-Inertial/stereo_inertial_euroc ../Vocabulary/ORBvoc.txt ./Stereo-Inertial/EuRoC.yaml "$pathDatasetEuroc"/MH03 ./Stereo-Inertial/EuRoC_TimeStamps/MH03.txt dataset-MH03_stereoi
python ../evaluation/evaluate_ate_scale.py "$pathDatasetEuroc"/MH03/mav0/state_groundtruth_estimate0/data.csv f_dataset-MH03_stereoi.txt --plot MH03_stereoi.pdf