[ORB_SLAM] Ubuntu20.04 Placement ORB_SLAM3

This article mainly records the environment configuration of ordinary ORB_SLAM3 and dense version of ORB_SLAM3 based on Ubuntu20.04 environment.

1. Configure ORB_SLAM3<common version>

1. Install the ROS development environment

The one-click installation of Yuxiang ros is used here, thanks to Xiaoyu for the one-click installation.

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

2. Install Pangolin

Pangolin: Link: https://pan.baidu.com/s/1FXYLsEK1W3xmX0m_Vqylag Extraction code: jgz2

# 这里采用的是Pangolin-0.5-20.04
cd Pangolin-0.5-20.04
mkdir build
cd build
cmake ..
make -j
sudo make install 

3. Install eigen

sudo apt-get install libeigen3-dev

4. Pull the source code of orb_slam3

(ORB_SLAM3 code based on Xiao Liu's comments)

https://github.com/electech6/ORB_SLAM3_detailed_comments

git clone https://github.com/electech6/ORB_SLAM3_detailed_comments.git

5. Install DBoW2 (in the Thirdparty file)

Need to modify the opencv version first

How to check the opencv version number?

Compile (because in the project, install is not required)

cd DBoW2
mkdir build
cd build
cmake ..
make -j

6. Install g2o

cd g2o
mkdir build
cd build
cmake ..
make -j

7. Start compiling ORBSLAM3 (normal version)

Modify the version of opencv in CMakeLists in the project, and it must be consistent with the version of opencv in the system

cd ORB_SLAM3_detailed_comments
mkdir build
cd build
cmake ..
make -j

If the above error is displayed, you need to install realsense2

sudo apt-get install ros-noetic-realsense2-camera

ORB_SLAM3 can also use one-click installation

cd ORB_SLAM3_detailed_comments
sudo chmod 777 build.sh
./build.sh

8. Compile ORB_SLAM3 ROS environment

It is also necessary to modify the version number of OpenCV to the native version

Add ORBSLAM path in bashrc

sudo vim ~/.bashrc
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:/home/robot/orb_slam3/ORB_SLAM3_detailed_comments/Examples/ROS/ORB_SLAM3
# vim 操作方法: 输入 按a
#              结束先按Esc ,再按 :wq
# 记得source下环境
source ~/.bashrc

If the above error occurs, you need to go to rosdep init , and rosdep update

You can use the top Yuxiang ros to update it

cd ORB_SLAM3_detailed_comments/Examples/ROS/ORB_SLAM3
mkdir build
cd build
cmake ..
make -j

You can also use one-click installation

cd ORB_SLAM3_detailed_comments
sudo chmod 777 build_ros.sh
./build_ros.sh

9. Test it out

# 运行代码之前记得source一下
cd orb_slam3/ORB_SLAM3_detailed_comments/Examples/ROS/ORB_SLAM3/build
source devel/setup.bash
# 终端1
roscore
# 终端2
rosrun ORB_SLAM3 Mono_Inertial /home/robot/orb_slam3/ORB_SLAM3_detailed_comments/Vocabulary/ORBvoc.txt /home/robot/orb_slam3/ORB_SLAM3_detailed_comments/Examples/Monocular-Inertial/EuRoC.yaml

Test dataset:

Link: https://pan.baidu.com/s/1WwTSvQqJ8QSpPPs0G-dXNg Extraction code: nnej

rosbag play V1_01_easy.bag

这样,普通版本的ORB_SLAM3环境搭建成功!

将ORB-SLAM3编写成launch文件

<?xml version="1.0"?>
<launch>
    <node pkg="ORB_SLAM3" type="RGBD" name="RGBD" args="/home/qsx/orb_slam/ORB_SLAM3_detailed_comments/Vocabulary/ORBvoc.txt /home/qsx/orb_slam/ORB_SLAM3_detailed_comments/Examples/RGB-D/RealSense_L515.yaml" />

    <arg name="node_start_delay" default="5.0" />  
    <node pkg="rosbag" type="play" name="rosbag_play" args="/home/qsx/F1_dataset/1/record_12_6_F1_3.bag" launch-prefix="bash -c 'sleep $(arg node_start_delay); $0 $@' " />
</launch>

二、编译ORB_SLAM3(稠密版本)

1.下载源码:

git clone -b dense_map_new https://github.com/electech6/ORB_SLAM3_detailed_comments.git

同样需要先安装Thirdparty中的DBoW2和g2o,方法同上。

2.修改opencv版本

若出现以上错误,则需要安装pcl-1.12版本

3.解决pcl多版本共存问题

pcl各个版本下载地址:https://github.com/PointCloudLibrary/pcl/releases

下载pcl-1.12.1:https://github.com/PointCloudLibrary/pcl/archive/refs/tags/pcl-1.12.1.zip

(个人认为:由于我们一般编译安装的文件都放再/usr/local路径,而若是我们自行定义自己的文件夹,这样系统就找不到,也就不会出现多版本共存冲突的问题啦!<俗话说,打不过我躲还行吧!>但需要在CMakeList文件中去寻找我们的文件路径)

①将下载的1.12.1源码放到pcl-1.12文件夹中,再新建一个pcl-1.12_installfile文件用来存放安装后的文件

②开始编译pcl

cd pcl-1.12
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=None -DCMAKE_INSTALL_PREFIX=/home/robot/Documents/pcl-1.12_installfile ..
make
make install 
make clean

③修改CmakeList文件

修改成如下:

find_package(PCL 1.12 REQUIRED 
PATHS /home/robot/Documents/pcl-1.12_installfile
)

4.修改c++版本

若出现以上错误,则需要把C++11改为C++14

把C++11改为C++14

5.C++问题

若出现error: ‘std::chrono::monotonic_clock’ has not been declared

则全部替换成steady_clock

这样就可以编译通过啦!

6.编译稠密版本的ORB_SLAM3 ROS

①添加bashrc环境

export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:/home/robot/orb_slam3/dense_ORB_SLAM3_detailed_comments/Examples/ROS/ORB_SLAM3

# 保存完记得 
source ~/.bashrc 

②修改CMakeList文件

③使用一键安装

sudo chmod 777 build_ros.sh
./build_ros.sh

④pcl问题

若出现pcl/point_types.h:No such file or directory

则需要修改CMakeList文件

⑤C++版本问题

若出现上述问题,则需要将C++11改为C++14

这样就ROS的稠密版本也编译完成啦!

7.测试一下

①编写launch文件

<?xml version="1.0"?>
<launch>
    <!-- <include file="$(find ORB_SLAM3)/launch/rs_camera.launch"/> -->


    <node pkg="ORB_SLAM3" type="RGBD" name="RGBD" args="/home/robot/orb_slam3/dense_map_ORB_SLAM3_detailed_comments/Vocabulary/ORBvoc.txt /home/robot/orb_slam3/dense_map_ORB_SLAM3_detailed_comments/Examples/ROS/ORB_SLAM3/config/RealSense_L515.yaml" output="screen"/>

    <arg name="node_start_delay" default="5.0" />  

    <node pkg="rosbag" type="play" name="rosbag_play" args="/media/robot/Q小鑫/数据集/R2DIO_data/F3_scene3_data/F3_scene3_dataset/F3_scene3_4.bag" launch-prefix="bash -c 'sleep $(arg node_start_delay); $0 $@' " />

    
</launch>

②修改相机Yaml文件(采用的是RealSense_L515相机)

%YAML:1.0

#--------------------------------------------------------------------------------------------
# Camera Parameters. Adjust them!
#--------------------------------------------------------------------------------------------
# File.version: "1.0"

Camera.type: "PinHole"

# Right Camera calibration and distortion parameters (OpenCV)
Camera.fx: 603.086
Camera.fy: 603.23
Camera.cx: 329.578
Camera.cy: 232.509


# distortion parameters
Camera.k1: 0.15858
Camera.k2: -0.492513
Camera.k3: 0.4519
Camera.p1: -0.00218088
Camera.p2: 0.00021294 

# Camera resolution
Camera.width: 640
Camera.height: 480

# Camera frames per second 
Camera.fps: 30

# IR projector baseline times fx (aprox.)
Camera.bf: 30.33325

# Color order of the images (0: BGR, 1: RGB. It is ignored if images are grayscale)
Camera.RGB: 1

# Close/Far threshold. Baseline times.
ThDepth: 40.0
#Stereo.b: 0.0745
DepthMapFactor: 1000.0
# DepthMapFactor: 1.0
# Depth map values factor
# RGBD.DepthMapFactor: 1000.0

#--------------------------------------------------------------------------------------------
# ORB Parameters
#--------------------------------------------------------------------------------------------
# ORB Extractor: Number of features per image
ORBextractor.nFeatures: 1000

# ORB Extractor: Scale factor between levels in the scale pyramid     
ORBextractor.scaleFactor: 1.2

# ORB Extractor: Number of levels in the scale pyramid    
ORBextractor.nLevels: 8

# ORB Extractor: Fast threshold
# Image is divided in a grid. At each cell FAST are extracted imposing a minimum response.
# Firstly we impose iniThFAST. If no corners are detected we impose a lower value minThFAST
# You can lower these values if your images have low contrast            
ORBextractor.iniThFAST: 20
ORBextractor.minThFAST: 7

#--------------------------------------------------------------------------------------------
# Viewer Parameters
#--------------------------------------------------------------------------------------------
Viewer.KeyFrameSize: 0.05
Viewer.KeyFrameLineWidth: 1.0
Viewer.GraphLineWidth: 0.9
Viewer.PointSize: 2.0
Viewer.CameraSize: 0.08
Viewer.CameraLineWidth: 3.0
Viewer.ViewpointX: 0.0
Viewer.ViewpointY: -0.7
Viewer.ViewpointZ: -1.8
Viewer.ViewpointF: 500.0

PointCloudMapping.Resolution: 0.05
meank: 50
thresh: 1.0

发现源码颜色有点不对劲

修改源码:

Guess you like

Origin blog.csdn.net/qq_42108414/article/details/129133002