Visual Simultaneous Localization and Mapping (SLAM) applications frequently leverage the ORB-SLAM framework due to its efficeincy. Establishing a functional workspace on Ubuntu involves installing specific libraries, compiling source code, and resolving common linkage errors.
Prerequisite Tools
Initialize the environment with essential version control and build management utilities.
sudo apt-get update
sudo apt-get install -y git cmake build-essential pkg-config libgtk2.0-dev
Compiling Core Libraries
Pangolin Visualization
Pangolin handles data visualization. Configure dependencies before cloning the repository.
sudo apt-get install libglew-dev libpython2.7-dev
git clone https://github.com/stevenlovegrove/Pangolin.git
cd Pangolin
mkdir build && cd build
cmake ..
make -j$(nproc)
sudo make install
OpenCV 2.4.11 Build
Compile the legacy OpenCV version required for specific dataset compatibility.
sudo apt-get install python-dev python-numpy libavcodec-dev libavformat-dev \
libswscale-dev libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev \
libjasper-dev libdc1394-22-dev
cd opencv-2.4.11
mkdir build && cd build
cmake .. \
-D CMAKE_BUILD_TYPE=Release \
-DCUDA_nppi_LIBRARY=true \
-DWITH_CUDA=OFF \
-DBUILD_TIFF=ON
make -j$(nproc)
sudo make install
Mathematical Backends
Install Eigen3, DBoW2, and g2o for graph optimizaton and feature matching.
sudo apt-get install libeigen3-dev
# Ensure DBoW2 and g2o are cloned from their respective repositories into the parent directory
Building the SLAM Application
Retrieve the primary project and execute the automated build script.
git clone https://github.com/raulmur/ORB_SLAM2.git ORB_SLAM2
cd ORB_SLAM2
chmod +x build.sh
./build.sh
Troubleshooting Compilation Errors
Missing Video Device Headers:
If linux/videodev.h is not found:
sudo apt-get install libv4l-dev
ln -s /usr/include/libv4l1-videodev.h /usr/include/linux/videodev.h
Eigen Header Missing in OpenCV Contrib:
If unsupported/Eigen/MatrixFunctions raises fatal errors within OpenCV contrib modules:
cd /usr/include/eigen3
sudo cp -r unsupported ..
sudo cp -r Eigen ..
Undefined Symbol usleep:
To fix LocalMapping.cc scope errors, include the POSIX header:
// Add this line at the top of LocalMapping.cc
#include <unistd.h>
Running Experiments
Execute the monocular tracking example using EuRoC dataset parameters.
./Examples/Monocular/mono_euroc Vocabulary/ORBvoc.txt \
Examples/Monocular/EuRoC.yaml mav0/cam0/data \
Examples/Monocular/EuRoC_TimeStamps/MH01.txt
Installing Robot Operating System (ROS)
Set up the Melodic distribution for node communication capabilities.
sudo apt-get install ros-melodic-desktop-full
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt install rospack-tools
sudo rosdep init
rosdep update
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
sudo apt install python-rosinstall python-wstool
Verification steps confirm the installation is active.