1. Create a ros workspace
mkdir -p ~/ORB_SLAM2/src
cd ~/ORB_SLAM2/src
catkin_init_workspace
cd ..
catkin_make
2. Set environment variables
echo "source ~/ORB_SLAM2/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc
3. Preparations before installation
sudo apt-get install vim cmake
sudo apt-get install git
sudo apt-get install gcc g++
4. Install Pangolin
(1) Installation dependencies
sudo apt-get install libglew-dev
sudo apt-get install libboost-dev libboost-thread-dev libboost-filesystem-dev
sudo apt-get install libpython2.7-dev
(2) Install Pangolin
git clone https://github.com/FAST-ROBOT/Pangolin.git
cd Pangolin
mkdir build
cd build
cmake -DCPP11_NO_BOOSR=1 ..
make -j16
sudo make install
5. Install OpenCV3.4.16
Refer to this article https://blog.csdn.net/forever_008/article/details/103625637
6. Install Eigen3
sudo apt-get install libeigen3-dev
7. Install ORB-SLAM2
(1) Install and run ORB-SLAM2
git clone https://github.com/FAST-ROBOT/ORB_SLAM2_zhushiban.git
cd ORB_SLAM2
chmod +x build.sh
./build.sh
If there is the following error during compilation: add #include <unistd.h> to the corresponding header file
(2) Compile the source code under ROS
chmod +x build_ros.sh
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:~/ORB_SLAM2/src/ORB_SLAM2/Examples/ROS
./build_ros.sh
If there is an error related to the boost library when compiling: Modify the CMakeLists.txt file in the Examples/ROS/ORB_SLAM2/ folder
8. Code run
(1) Download the tum dataset and put it in the main directory, run the following command
cd ~/ORB_SLAM2/src/ORB_SLAM2
./Examples/Monocular/mono_tum Vocabulary/ORBvoc.txt Examples/Monocular/TUM1.yaml data/rgbd_dataset_freiburg1_desk
Note: The picture on the right is the result of running the code, and the picture on the left is the dense mapping version of ORB-SLAM2.
(2) For real-time operation of the camera in the ros environment, please refer to this article .
9. Refer to this article for dense mapping version ORB_SLAM2 .