Install orb_slam2, vins_mono, orb_slam3 in ubuntu18melodic environment to run the euroc data set and use evo to evaluate

Foreword

Recently, I used orb_slam2 modified by Dr. Gao Xiang to generate a dense point cloud, and then used an octree to generate a two-dimensional raster map for navigation. However, the effect of the created map is not very good and the drift is too serious.

On the left is the image generated by cartographer, and on the right is the image generated by orb_slam2.

The effect is so poor. On the one hand, my point cloud processing is not good, because the generated point cloud is tilted in the octree, and the angle I manually adjusted may not be so accurate. On the other hand, the generated pcd itself is Drift, this is the pcd file that was run out

So I looked at some other algorithms and wanted to do some evaluation of these algorithms. I ran the same euroc data set MH01_easy.

Installation of three algorithms

Because the library used by orb_slam2 conflicts with orb_slam3, two computers are used, and vins_mono is installed on both computers. Orb_slam3 is installed on a newly installed system.

1.orb_slam2

Using the modified version of GitHub by Dr. Gao Xiang – gaoxiang12/ORBSLAM2_with_pointcloud_map

Because it is troublesome to install and compile, I will make up for it later when I have time.

2.vins_mono

2.1 Installing system packages

sudo apt install ros-melodic-cv-bridge ros-melodic-tf ros-melodic-message-filters ros-melodic-image-transport

2.2 Install ceres_solver

Install dependencies

sudo apt-get install cmake
sudo apt-get install libgoogle-glog-dev libgflags-dev
sudo apt-get install libatlas-base-dev
sudo apt-get install libeigen3-dev
sudo apt-get install libsuitesparse-dev

Download the ceres_solver source code (note version compatibility, choose version 1.14)

Refer to this article

Ubuntu18.04 installs Ceres1.14_ubuntu18 installs ceres-CSDN blog

Compile and install

mkdir build
cd build
cmake..
make
make test
sudo make install

If the compilation error is reported, it may be a problem with the cmake version. You can establish a higher version of cmake soft connection. Be sure not to use automove. See this article.

cmake upgrade and update (ubuntu18.04)-CSDN blog

2.3 Run

roslaunch vins_estimator euroc.launch
roslaunch vins_estimator vins_rviz.launch
rosbag play --pause MH_01_easy.bag

The data set can be downloaded from here

kmavvisualinertialdatasets – ASL Datasets

3.orb_slam3

1. Install libraries and dependencies

Pangolin,opencv,eigen3,boost

pangolin uses version 0.6 like orb_slam2, opencv and eigen3 can use their own ones.

boost

Boost Downloads Download boost_1_77_0.tar.gz version

tar -xvf boost_1_77_0.tar.gz
cd ./boost_1_77_0
./bootstrap.sh
sudo ./b2 install

rosdep Because the official website update download can easily fail, here we use rosdepc of Yuxiang ros.

sudo pip install rosdepc
//If pip cannot be found, try pip3
sudo pip3 install rosdepc
//If it still doesn't work, execute the following first and then repeat the above.
sudo apt-get install python3-pip

sudo rosdepc init
rosdepc update

Tried and tested before but I don’t know why the new system can’t connect to the website. Here is a one-click installation using Xiaoyu.

wget http://fishros.com/install -O fishros & amp; & amp; . fishros

2. Compile

code

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

compile

Compiling build.sh is relatively simple. First give permissions to build_sh.

sudo chmod + x build.sh

Our opencv version does not correspond to the c++ version. We need to change two places in Cmakelists.

1.find

find_package(OpenCV 4.4)

Change to

find_package(OpenCV 3 REQUIRED)

2.find

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c + + 11")

Change to

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c + + 14")

If an internal segmentation fault occurs during compilation, just modify make -j8 in build.sh and delete all -j8.

If the compilation fails, you need to delete the build and lib folders under ORB_SlAM3, as well as the build and lib folders in DBoW2 and g2o under Thirdparty, and the build folder under Sophus. If you don’t delete it, an error will be reported during the next compilation. If some of the above files are not available, it means that the last compilation has not reached that point.

A few more steps to compile build_ros.sh

First of all, the Cmakelists need to be modified as above, and there are some

include_directories(
${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/../../../
${PROJECT_SOURCE_DIR}/../../../include
${PROJECT_SOURCE_DIR}/../../../include/CameraModels
${Pangolin_INCLUDE_DIRS}
#Add the following. I don’t know if the catkin line is needed or not, so just add it all to avoid recompiling (this line will be deleted after copying)
${EIGEN3_INCLUDE_DIR}
${catkin_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/../../../Thirdparty/Sophus
)

There is no ROS folder in Examples in the new version of ORB_SLAM3. Just copy the one in Eamples_old and then add the package path to the bash file.

sudo gedit ~/.bashrc
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/cr/ORB_SLAM3/Examples/ROS

Copy the above code into it. Note that it must be placed at the end of the source path otherwise it will not be displayed later. Just put it at the end to be on the safe side. Next, check whether there is any in the output path

echo ${ROS_PACKAGE_PATH}

The code also needs to be modified

In ~/ORB_SLAM3/Examples/ROS/ORB_SLAM3/src/AR/ViewerAR.cc

Add header file
#include <Eigen/Dense>
#include <opencv2/core/eigen.hpp>
 //vPoints.push_back(pMP->GetWorldPos());
Comment out the above and change it to the following
cv::Mat WorldPos;
cv::eigen2cv(pMP->GetWorldPos(), WorldPos);
vPoints.push_back(WorldPos);
//cv::Mat Xw = pMP->GetWorldPos();
Comment out the above and change it to the following
cv::Mat Xw;
cv::eigen2cv(pMP->GetWorldPos(), Xw);

In ~/ORB_SLAM3/Examples/ROS/ORB_SLAM3/src/AR/ros_mono_ar.cc

Add header file
#include <Eigen/Dense>
#include <opencv2/core/eigen.hpp>
//cv::Mat Tcw = mpSLAM->TrackMonocular(cv_ptr->image,cv_ptr->header.stamp.toSec());
Comment out the above and change it to the following
cv::Mat Tcw;
Sophus::SE3f Tcw_SE3f = mpSLAM->TrackMonocular(cv_ptr->image,cv_ptr->header.stamp.toSec());
Eigen::Matrix4f Tcw_Matrix = Tcw_SE3f.matrix();
cv::eigen2cv(Tcw_Matrix, Tcw);

Finally, enter the following command to update the shared library and compile it. Remember to give permissions to build_ros first.

sudo ldconfig

3.3 Run

./Examples/Monocular/mono_euroc ./Vocabulary/ORBvoc.txt ./Examples/Monocular/EuRoC.yaml /home/************/MH_01_easy ./Examples/Monocular/EuRoC_TimeStamps/MH01 .txt

*****Change to your own path. Note that what is running here is not the bag, but the data set, because subsequent evaluation requires a file in the data set.

! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !

If it crashes halfway through the run or just at the beginning and reports an error that the core has been dumped, modify the yaml file in the above code.

ORBextractor.nFeatures: 2000

Change it to 3000. If it still doesn’t work, increase it. This problem has been stuck for a long time when running orb_slam2 before. After testing, the final values are not much different. The following content will give the results.

evo installation and evaluation

1. evo installation

pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple/ evo --upgrade --no-binary evo

Afterwards, enter the evo tap key completion in the terminal and other commands will appear. That means the installation is successful. If not, don’t worry, just restart the computer and it will be fine.

sudo apt-get install python-tk
sudo apt-get install python3-tk

2. vins_mono test

The trajectory generated by vins_mono cannot be used directly for testing, so the code needs to be modified.

Ubuntu 18.04 — Evaluation and use of VINS-Mono operation and EVO_vins-mono implementation ubuntu18.04-CSDN blog

Refer to this article

After the modification is completed, there will be a file vins_result_loop.txt, which is the file to be evaluated. In the data set we mentioned above, which is the data set run by orb_slam3, the file MH_01_easy/mav0/state_groundtruth_estimate0/data.csv is in euroc format and needs to be Convert to tum format

evo_traj euroc data.csv --save_as_tum

Then put vins_result_loop.txt and data.tum in the same directory, and execute the following code to get the results.

evo_ape tum data.tum vins_result_loop.txt -p --plot_mode=xyz -a --correct_scale --save_results ./test.zip

Just give the compressed package of the last saved results a random name.

There may be an error ModuleNotFoundError: No module named ‘_tkinter’

Just install it

sudo apt-get install python-tk
sudo apt-get install python3-tk

Execute it again and you will see the result.

3. ORB_SLAM3 test

The files generated by ORB_SLAM2 can be used directly. Note that the file to be evaluated is not KeyFrameTrajectory.txt but CameraTrajectory.txt.

Similarly, put it in the same directory as data.tum and execute the code to see the results.

evo_ape tum data.tum CameraTrajectory.txt -p --plot_mode=xyz -a --correct_scale --save_results ./test.zip

Result comparison and follow-up thoughts

orb_slam2

vin_mono

ORB_SLAM3_3000 (modified yaml file)

ORB_SLAM3_2000 (I ran 70% to 80% core dump, but the trajectory file can also be used)

After analysis, although only one data set was run, the data was very intuitive. The effect of ORB_SLAM3 was great. Then I modified the yaml file and the difference between the two sets of data was very small. Later, I will test multiple sets of data sets with different values of ORBextractor.nFeatures.

But in the final analysis, we still want to build a qualified map. There is a long way to go and we need to work together to encourage each other.