ORB-SLAM3 installation and operation

ORB-SLAM3 installation and operation

Operating environment: Ubuntu 18 04

Installation dependency

Download ORB-SLAM3 source code

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

Pangolin installation

git clone https://github.com/stevenlovegrove/Pangolin.git

According to the instructions on github, install the dependencies required for Pangolin

  • C++11
  • OpenGL (Desktop / ES / ES2)
    • (lin) sudo apt install libgl1-mesa-dev
  • Glew
    • (deb) sudo apt install libglew-dev
  • CMake (for build environment)
    • (deb) sudo apt install cmake

Recommended Dependencies

  • Python2 / Python3, for drop-down interactive console
    • (deb) sudo apt install libpython2.7-dev
  • Wayland
    • pkg-config: sudo apt install pkg-config
    • Wayland and EGL:sudo apt install libegl1-mesa-dev libwayland-dev libxkbcommon-dev wayland-protocols
sudo apt-get install cmake libeigen3-dev libsuitesparse-dev qtdeclarative5-dev qt5-qmake libqglviewer-dev //Dependencies of g2o
sudo apt-get install libboost-dev //Dependencies of DBoW2

Compile and install Pangolin

cd Pangolin
mkdir build
cd build
cmake ..
cmake --build .

Opencv (requirement > 3.0) installation steps are omitted

Install boost library

The official website is https://www.boost.org/ , download and unzip, and execute sudo/ bootstrap. SH and sudo/ b2 install

Install libssl dev sudo apt get install libssl dev

ORB-SLAM3 compilation and installation

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

Directly executing the compiled script may eat memory and the process is slow. You can also execute build one by one Instructions in Sh

# build. The contents in SH are as follows
echo "Configuring and building Thirdparty/DBoW2 ..."

cd Thirdparty/DBoW2
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j

cd ../../g2o

echo "Configuring and building Thirdparty/g2o ..."

mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j

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 -j

Compilation error problem

  • Eigen version problem

    Modify ORB_SLAM3/Thirdparty/g2o/CMakeLists.txt version number

    Put line 72 FIND_PACKAGE(Eigen3 3.1.0 REQUIRED)

    Change to FIND_PACKAGE(Eigen3 REQUIRED)

  • 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
    

    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());
    	}
    }
    

Dataset testing

Using the TUM dataset, https://vision.in.tum.de/data/datasets/rgbd-dataset/download

Monocular

./Examples/Monocular/mono_tum_vi Vocabulary/ORBvoc.txt Examples/Monocular/TUM_512.yaml ./data/dataset-corridor5_512_16/mav0/cam0/data Examples/Monocular/TUM_TimeStamps/dataset-corridor5_512.txt  dataset-corridor5_512_mono# The data set path is arbitrarily specified. Here, the data set is placed in the data folder under the current path

RGB-D

./Examples/Monocular/mono_tum Vocabulary/ORBvoc.txt Examples/Monocular/TUM1.yaml ./data/rgbd_dataset_freiburg1_desk

The screenshot of the operation is as follows

Online test

ROS needs to be installed for online test. Please install it yourself```

Compile first

  1. Examples / ROS / orb in the source code_ Add slam3 path to ROS_PACKAGE_PATH environment variable

    # open .bashrc file: gedit ~/.bashrc# Add path, 
    # Where PATH is the specific PATH of the machine export
     ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:"PATH"/ORB_SLAM3/Examples/ROS
    
  2. Execute build_ros.sh file

    chmod +x build_ros.sh./build_ros.sh
    

If the compilation reports an error, it is probably that / ros/noetic/share has no orb_ The soft connection of slam3 can be solved by executing the following commands

sudo ln -s "PATH"/ORB_SLAM3/Examples/ROS/ORB_SLAM3 /opt/ros/noetic/share/ORB_SLAM3

USB is required for online operation_ CAM software package

sudo apt-get install ros-noetic-usb-cam

Running ORB-SLAM3 with laptop camera

First, modify the source code and enter the directory / ORB_SLAM3/Examples/ROS/ORB_SLAM3/src, modify ros_mono.cc file

// Where / usb_cam/image_raw is the topic of the local camera,
// Using roslaunch USB_ cam usb_ cam-test. When launch tests the camera,
// You can view all topics in the rostopic list
ros::Subscriber sub = nodeHandler.subscribe("/usb_cam/image_raw", 1, &ImageGrabber::GrabImage,&igb);

Open three terminals respectively and run the following commands in turn

roscore
roslaunch usb_cam usb_cam-test.launch
# Running ORB-SLAM3 with monocular camera
rosrun ORB_SLAM3 Mono /home/jxf/ORB_SLAM3/Vocabulary/ORBvoc.txt /home/jxf/ORB_SLAM3/Examples/ROS/ORB_SLAM3/Asus.yaml

Run ORB-SLAM3 with external fisheye camera

In this experiment, a 210 degree fisheye camera (purchased from a treasure, more than 100 rmb) was used

After the computer is connected to the usb camera, first enter the directory / opt / ROS / melody / share / usb_ Cam / launch modify usb_cam-test.launch file, where / dev/video1 (laptop camera) is modified to / dev/video2,

Then go to the directory / ORB_SLAM3/Examples/ROS/ORB_SLAM3/src, modify ros_mono.cc file

//Where / usb_cam/image_raw is the topic of the local camera,
//Using roslaunch USB_ cam usb_ cam-test. When launch tests the camera,
//You can view all topics in the rostopic list
ros::Subscriber sub = nodeHandler.subscribe("/usb_cam/image_raw", 1, &ImageGrabber::GrabImage,&igb);

Then it can be run. Open three terminals respectively and run the following commands in turn

roscore
roslaunch usb_cam usb_cam-test.launch
# Running ORB-SLAM3 with monocular camera
rosrun ORB_SLAM3 Mono /home/jxf/ORB_SLAM3/Vocabulary/ORBvoc.txt /home/jxf/ORB_SLAM3/Examples/ROS/ORB_SLAM3/Asus.yaml

The screenshot of the operation is as follows

If ROS runs ORB-SLAM3 and reports an error Segmentation fault (core dumped), it may be because

ORB_SLAM3/Thirdparty/DBoW2/CMakeLists.txt and ORB_SLAM3/CMakeLists.txt specifies opencv 4 But ORB_SLAM3/Examples/ROS/ORB_SLAM3/CMakeLists.txt is opencv 3. Modify the former cmakelists Txt specifies that the opencv version is 3,

For example, set(OpenCV_DIR "/usr/local/opencv/3.4.11/share/OpenCV"), it is better to modify all cmakelists to keep the OpenCV version consistent

Keywords: Ubuntu slam

Added by fatalcure on Wed, 05 Jan 2022 18:39:07 +0200