本文主要记录基于Ubuntu20.04环境下,对普通的ORB_SLAM3和稠密版本的ORB_SLAM3进行环境的配置。
一、配置ORB_SLAM3<普通版本>
1.安装ROS开发环境
这里采用鱼香ros的一键安装,感谢小鱼的一键安装。
wget http://fishros.com/install -O fishros && . fishros
2.安装Pangolin
Pangolin:链接: https://pan.baidu.com/s/1FXYLsEK1W3xmX0m_Vqylag 提取码: jgz2
# 这里采用的是Pangolin-0.5-20.04
cd Pangolin-0.5-20.04
mkdir build
cd build
cmake ..
make -j
sudo make install
3.安装eigen
sudo apt-get install libeigen3-dev
4.拉取orb_slam3 的源码
(基于小六的注释后的ORB_SLAM3代码)
https://github.com/electech6/ORB_SLAM3_detailed_comments
git clone https://github.com/electech6/ORB_SLAM3_detailed_comments.git
5.安装DBoW2(在Thirdparty文件中)
需要先修改opencv版本
如何查看opencv版本号?
编译(由于在工程当中,并不需要install)
cd DBoW2
mkdir build
cd build
cmake ..
make -j
6.安装g2o
cd g2o
mkdir build
cd build
cmake ..
make -j
7.开始编译ORBSLAM3(普通版)
在工程中修改CMakeLists 中opencv的版本,一定要与系统的opencv版本一致
cd ORB_SLAM3_detailed_comments
mkdir build
cd build
cmake ..
make -j
若显示以上报错,则需要安装realsense2
sudo apt-get install ros-noetic-realsense2-camera
ORB_SLAM3也可以使用一键安装
cd ORB_SLAM3_detailed_comments
sudo chmod 777 build.sh
./build.sh
8.编译ORB_SLAM3 ROS环境
同样需要先修改OpenCV的版本号为本机版本
在bashrc中添加ORBSLAM路径
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
若出现以上错误,则需要去rosdep init一下,并且rosdep update
可以使用最上面的鱼香ros更新一下
cd ORB_SLAM3_detailed_comments/Examples/ROS/ORB_SLAM3
mkdir build
cd build
cmake ..
make -j
也可以使用一键安装
cd ORB_SLAM3_detailed_comments
sudo chmod 777 build_ros.sh
./build_ros.sh
9.测试一下
# 运行代码之前记得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
测试数据集:
链接: https://pan.baidu.com/s/1WwTSvQqJ8QSpPPs0G-dXNg 提取码: 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
发现源码颜色有点不对劲文章来源:https://www.toymoban.com/news/detail-617969.html
修改源码:文章来源地址https://www.toymoban.com/news/detail-617969.html
到了这里,关于【ORB_SLAM】Ubuntu20.04 配置ORB_SLAM3的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!