本文主要记录基于Ubuntu20.04环境下,对普通的ORB_SLAM3和稠密版本的ORB_SLAM3进行环境的配置。
这里采用鱼香ros的一键安装,感谢小鱼的一键安装。
wget http://fishros.com/install -O fishros && . fishros
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
sudo apt-get install libeigen3-dev
(基于小六的注释后的ORB_SLAM3代码)
https://github.com/electech6/ORB_SLAM3_detailed_comments
git clone https://github.com/electech6/ORB_SLAM3_detailed_comments.git
需要先修改opencv版本
如何查看opencv版本号?
编译(由于在工程当中,并不需要install)
cd DBoW2
mkdir build
cd build
cmake ..
make -j
cd g2o
mkdir build
cd build
cmake ..
make -j
在工程中修改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
同样需要先修改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
# 运行代码之前记得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文件
git clone -b dense_map_new https://github.com/electech6/ORB_SLAM3_detailed_comments.git
同样需要先安装Thirdparty中的DBoW2和g2o,方法同上。
若出现以上错误,则需要安装pcl-1.12版本
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文件中去寻找我们的文件路径)
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
修改成如下:
find_package(PCL 1.12 REQUIRED
PATHS /home/robot/Documents/pcl-1.12_installfile
)
若出现以上错误,则需要把C++11改为C++14
把C++11改为C++14
若出现error: ‘std::chrono::monotonic_clock’ has not been declared
则全部替换成steady_clock
这样就可以编译通过啦!
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:/home/robot/orb_slam3/dense_ORB_SLAM3_detailed_comments/Examples/ROS/ORB_SLAM3
# 保存完记得
source ~/.bashrc
sudo chmod 777 build_ros.sh
./build_ros.sh
若出现pcl/point_types.h:No such file or directory
则需要修改CMakeList文件
若出现上述问题,则需要将C++11改为C++14
这样就ROS的稠密版本也编译完成啦!
%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
发现源码颜色有点不对劲
修改源码: