Orbslam2 installation and operation

Table of contents

1. Update apt library and update software list

2. Install git, which is used to clone projects from Github to local

3. Download orbslam2 source code

4. Install the C++11 compiler cmake

5. Install Pangolin

6. Install Eigen3

7. Install opencv

 8. Install and run ORB-SLAM2

9. Running ORB_SLAM in ROS environment

9.1 Add environment variables

9.2 Check whether the ROS path is recognized

10. Run ORB_SLAM2 on the official data set


1. Update apt library and update software list

sudo apt-get update

2. Install git, which is used to clone projects from Github to local

sudo apt-get install git

3. Download orbslam2 source code

git clone https://github.com/raulmur/ORB_SLAM2

After downloading orbslam2, let’s take a look at what’s in this folder:

4. Install the C++11 compiler cmake

sudo apt-get install cmake

5. Install Pangolin

Pangolin is a lightweight OpenGL input/output and video display library that encapsulates OpenGL. Visual diagrams that can be used for 3D vision and 3D navigation, can input various types of videos, and can retain videos and input data for debugging.

Before installing pangolin, install 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

Pangolin download link: https://github.com/stevenlovegrove/Pangolin

The recommended version to use is V0.5, which can avoid Eigen3 errors.

cd Pangolin
mkdir build
cd build
cmake ..
make –j
sudo make install
  • The role of cmake ..: The ../CMakeLists.txt file is used as a starting point to generate a makefile in the current directory
  • The make command, executed after this, builds the program using the generated makefile as input
  • make install: Install the program into the system. If the source code is compiled correctly and the execution result is correct, the program can be installed to the system's default executable file storage path. Default/usr/local/bin

Error resolution:

Installation and operation of ORB-SLAM2_ydongy's blog-CSDN blog_orbslam2 installation and operation

1. Find the FindEigen3.cmake file, /usr/share/cmake2.8/Modules
2. Copy it to your own project
3. In the CMakeLists.txt of the project. Add this sentence:

 set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})

Reference link: https://blog.51cto.com/u_15127644/3362825

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})*******就是这句,加上就行了。这样cmake就会到你自己工程目录下去找FindEigen3.cmake了。
find_package(Eigen3)
if(NOT EIGEN3_FOUND)
  # Fallback to cmake_modules
  find_package(cmake_modules REQUIRED)
  find_package(Eigen REQUIRED)
  set(EIGEN3_INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS})
  set(EIGEN3_LIBRARIES ${EIGEN_LIBRARIES})  # Not strictly necessary as Eigen is head only
  # Possibly map additional variables to the EIGEN3_ prefix.
else()
  set(EIGEN3_INCLUDE_DIRS ${EIGEN3_INCLUDE_DIR})
endif()
-----------------------------------
CMake Error: not providing "FindEigen3.cmake" in CMAKE_MODULE_PATH
https://blog.51cto.com/u_15127644/3362825

Problems that occur when using lower versions of the Pangolin library:

Make -j causes terminal crash problem  

Solution: make -j4, 4 is the number of CPU threads in your computer

Error reported after make -j4:

Add settings in Pangolin folder CMakeLists.txt 

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}-pthread")

success! !

6. Install Eigen3

sudo apt-get install libeigen3-dev

7. Install opencv

opencv official download address: Releases - OpenCV

Select version 3.4.0, download and unzip

Before installing opencv, you must install libgtk2.0-dev and pkg-config. If you install it or do not install it, you will get an error.

sudo apt-get install libgtk2.0-dev
sudo apt-get install pkg-config
cd ~/opencv
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release –D CMAKE_INSTALL_PREFIX=/usr/local ..
make 
sudo make install

When installing opencv , you will use:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
What does this sentence mean?
Enter in the build file: cmake -D CMAKE_BUILD_TYPE=RELEASEThe executable file generated by makefile generated 
in this way contains debugging information for use by gdb and gdbserver. The value of CMAKE_BUILD_TYPE can be Release or Debug.

CMAKE_INSTALL_PREFIX=/usr/local ..
The INSTALL directive is used to define installation rules. The installed content can include target binaries, dynamic libraries, static libraries and
Files, directories, scripts, etc. Here is the path to compile in advance!

 8. Install and run ORB-SLAM2

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

Error 1:

According to the error message, add: in gapi_async_tesr.cpp:

#include<unistd.h>

Error 2:

reference:

https://blog.csdn.net/u014717398/article/details/110356066?ops_request_misc=&request_id=&biz_id=102&utm_term=OpenCV%20%3E%202.4.3%20not%20found.&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-3-110356066.142%5Ev47%5Epc_rank_34_default_2,201%5Ev3%5Eadd_ask&spm=1018.2226.3001.4187

Error 3:

darren@PTY:~/ORB_SLAM2/build$ make -j4
[  6%] Building CXX object CMakeFiles/ORB_SLAM2.dir/src/LocalMapping.cc.o
[  6%] Building CXX object CMakeFiles/ORB_SLAM2.dir/src/System.cc.o
[  9%] Building CXX object CMakeFiles/ORB_SLAM2.dir/src/Tracking.cc.o
[ 12%] Building CXX object CMakeFiles/ORB_SLAM2.dir/src/LoopClosing.cc.o
In file included from /home/darren/ORB_SLAM2/include/Frame.h:31,
                 from /home/darren/ORB_SLAM2/include/MapPoint.h:25,
                 from /home/darren/ORB_SLAM2/include/KeyFrame.h:24,
                 from /home/darren/ORB_SLAM2/include/LoopClosing.h:24,
                 from /home/darren/ORB_SLAM2/src/LoopClosing.cc:21:
/home/darren/ORB_SLAM2/include/ORBextractor.h:26:10: fatal error: opencv/cv.h: 没有那个文件或目录
   26 | #include <opencv/cv.h>
      |          ^~~~~~~~~~~~~
In file included from /home/darren/ORB_SLAM2/include/Frame.h:31,
                 from /home/darren/ORB_SLAM2/include/MapPoint.h:25,
                 from /home/darren/ORB_SLAM2/include/KeyFrame.h:24,
                 from /home/darren/ORB_SLAM2/include/LocalMapping.h:24,
                 from /home/darren/ORB_SLAM2/src/LocalMapping.cc:21:
/home/darren/ORB_SLAM2/include/ORBextractor.h:26:10: fatal error: opencv/cv.h: 没有那个文件或目录
   26 | #include <opencv/cv.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
compilation terminated.
make[2]: *** [CMakeFiles/ORB_SLAM2.dir/build.make:104:CMakeFiles/ORB_SLAM2.dir/src/LocalMapping.cc.o] 错误 1
make[2]: *** 正在等待未完成的任务....
make[2]: *** [CMakeFiles/ORB_SLAM2.dir/build.make:118:CMakeFiles/ORB_SLAM2.dir/src/LoopClosing.cc.o] 错误 1
In file included from /home/darren/ORB_SLAM2/include/KeyFrame.h:28,
                 from /home/darren/ORB_SLAM2/include/MapPoint.h:24,
                 from /home/darren/ORB_SLAM2/include/FrameDrawer.h:25,
                 from /home/darren/ORB_SLAM2/include/Viewer.h:25,
                 from /home/darren/ORB_SLAM2/include/Tracking.h:28,
                 from /home/darren/ORB_SLAM2/src/Tracking.cc:22:
/home/darren/ORB_SLAM2/include/ORBextractor.h:26:10: fatal error: opencv/cv.h: 没有那个文件或目录
   26 | #include <opencv/cv.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
In file included from /home/darren/ORB_SLAM2/include/KeyFrame.h:28,
                 from /home/darren/ORB_SLAM2/include/MapPoint.h:24,
                 from /home/darren/ORB_SLAM2/include/FrameDrawer.h:25,
                 from /home/darren/ORB_SLAM2/include/Viewer.h:25,
                 from /home/darren/ORB_SLAM2/include/Tracking.h:28,
                 from /home/darren/ORB_SLAM2/include/System.h:29,
                 from /home/darren/ORB_SLAM2/src/System.cc:23:
/home/darren/ORB_SLAM2/include/ORBextractor.h:26:10: fatal error: opencv/cv.h: 没有那个文件或目录
   26 | #include <opencv/cv.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/ORB_SLAM2.dir/build.make:90:CMakeFiles/ORB_SLAM2.dir/src/Tracking.cc.o] 错误 1
make[2]: *** [CMakeFiles/ORB_SLAM2.dir/build.make:76:CMakeFiles/ORB_SLAM2.dir/src/System.cc.o] 错误 1
make[1]: *** [CMakeFiles/Makefile2:95:CMakeFiles/ORB_SLAM2.dir/all] 错误 2
make: *** [Makefile:91:all] 错误 2
darren@PTY:~/ORB_SLAM2/build$ 

 reference: 

https://blog.csdn.net/u014717398/article/details/110356066?ops_request_misc=&request_id=&biz_id=102&utm_term=OpenCV%20%3E%202.4.3%20not%20found.&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-3-110356066.142%5Ev47%5Epc_rank_34_default_2,201%5Ev3%5Eadd_ask&spm=1018.2226.3001.4187

Error 4:

Add to the header file of the error program

 #include <unistd.h>

Error 5:

ORB-SLAM2 compilation error_Chenjie's blog-CSDN blog

Error 6:

This is due to the fact that higher versions of opencv deprecate the CV_LOAD_IMAGE_UNCHANGED parameter.
Solution:
Replace CV_LOAD_IMAGE_UNCHANGEDit IMREAD_UNCHANGED
with and add a namespace under the code header file.using namespace cv;

9. Running ORB_SLAM in ROS environment

9.1 Add environment variables

sudo gedit ~/.bashrc   //查看bashrc文件

Add this sentence after the bashrc file:

export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/darren/ORB_SLAM2/Examples/ROS/ORB_SLAM2

source ~/.bashrc   //使环境变量生效

9.2 Check whether the ROS path is recognized

echo $ROS_PACKAGE_PATH

 Then execute the following three commands:

chmod +x build_ros.sh
./build_ros.sh

Error 1:

/usr/bin/ld: CMakeFiles/RGBD.dir/src/ros_rgbd.cc.o: undefined reference to symbol '_ZN5boost6system15system_categoryEv' /usr/lib/x86_64-linux-gnu/libboost_system.so: Unable to add symbol: DSO missing from command line collect2: error: ld returned 1 exit status CM

Solution:

/usr/bin/ld: CMakeFiles/RGBD.dir/src/ros_rgbd.cc.o: undefined reference to symbol '_ZN5boost6system1_Life is just a blog about closing and opening eyes - CSDN Blog

10. Run ORB_SLAM2 on the official data set

Dataset: Computer Vision Group - Dataset Download

Just download rgbd_dataset_freiburg1_xyz and unzip it

./Examples/Monocular/mono_tum Vocabulary/ORBvoc.txt Examples/Monocular/TUMX.yaml PATH_TO_SEQUENCE_FOLDER

Question 1: 

Solution:

https://blog.csdn.net/hy13684802853/article/details/83343093

https://blog.csdn.net/weixin_38493195/article/details/117454809


 

Problem 2: The screen suddenly crashes about 2 seconds after it appears.

New Map created with 86 points
double free or corruption (out)
Abandoned (core dumped)

Solution:

Solving the problem of double free or corruption (out) in Gao Xiang's slam14 project - Take a look at the
pitfalls of running ORB-SLAM2 under Ubuntu18.04_Wutongxue's blog-CSDN blog

Delete -march=native in ORBSLAM's cmakelists and -march=native in g2o's cmakelists and re-execute ./build.sh in the ORBSLAM directory to run normally.

Run successfully:

If you run rgbd mode, you need to use  the associate.py  script to manually align the depth and rgbd timestamps.

python associate.py PATH_TO_SEQUENCE/rgb.txt PATH_TO_SEQUENCE/depth.txt > associations.txt

Guess you like

Origin blog.csdn.net/peng_258/article/details/126725770