当前位置:   article > 正文

【ORB_SLAM】Ubuntu20.04 配置ORB_SLAM3_ubuntu20.04安装orbslam3

ubuntu20.04安装orbslam3

本文主要记录基于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

  1. # 这里采用的是Pangolin-0.5-20.04
  2. cd Pangolin-0.5-20.04
  3. mkdir build
  4. cd build
  5. cmake ..
  6. make -j
  7. 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)

  1. cd DBoW2
  2. mkdir build
  3. cd build
  4. cmake ..
  5. make -j

6.安装g2o

  1. cd g2o
  2. mkdir build
  3. cd build
  4. cmake ..
  5. make -j

7.开始编译ORBSLAM3(普通版)

在工程中修改CMakeLists 中opencv的版本,一定要与系统的opencv版本一致

  1. cd ORB_SLAM3_detailed_comments
  2. mkdir build
  3. cd build
  4. cmake ..
  5. make -j

若显示以上报错,则需要安装realsense2

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

ORB_SLAM3也可以使用一键安装

  1. cd ORB_SLAM3_detailed_comments
  2. sudo chmod 777 build.sh
  3. ./build.sh

8.编译ORB_SLAM3 ROS环境

同样需要先修改OpenCV的版本号为本机版本

在bashrc中添加ORBSLAM路径

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

若出现以上错误,则需要去rosdep init一下,并且rosdep update

可以使用最上面的鱼香ros更新一下

  1. cd ORB_SLAM3_detailed_comments/Examples/ROS/ORB_SLAM3
  2. mkdir build
  3. cd build
  4. cmake ..
  5. make -j

也可以使用一键安装

  1. cd ORB_SLAM3_detailed_comments
  2. sudo chmod 777 build_ros.sh
  3. ./build_ros.sh

9.测试一下

  1. # 运行代码之前记得source一下
  2. cd orb_slam3/ORB_SLAM3_detailed_comments/Examples/ROS/ORB_SLAM3/build
  3. source devel/setup.bash
  1. # 终端1
  2. roscore
  3. # 终端2
  4. 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文件

  1. <?xml version="1.0"?>
  2. <launch>
  3. <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" />
  4. <arg name="node_start_delay" default="5.0" />
  5. <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 $@' " />
  6. </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

  1. cd pcl-1.12
  2. mkdir build
  3. cd build
  4. cmake -DCMAKE_BUILD_TYPE=None -DCMAKE_INSTALL_PREFIX=/home/robot/Documents/pcl-1.12_installfile ..
  5. make
  6. make install
  7. make clean

③修改CmakeList文件

修改成如下:

  1. find_package(PCL 1.12 REQUIRED
  2. PATHS /home/robot/Documents/pcl-1.12_installfile
  3. )

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环境

  1. export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:/home/robot/orb_slam3/dense_ORB_SLAM3_detailed_comments/Examples/ROS/ORB_SLAM3
  2. # 保存完记得
  3. source ~/.bashrc

②修改CMakeList文件

③使用一键安装

  1. sudo chmod 777 build_ros.sh
  2. ./build_ros.sh

④pcl问题

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

则需要修改CMakeList文件

⑤C++版本问题

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

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

7.测试一下

①编写launch文件

  1. <?xml version="1.0"?>
  2. <launch>
  3. <!-- <include file="$(find ORB_SLAM3)/launch/rs_camera.launch"/> -->
  4. <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"/>
  5. <arg name="node_start_delay" default="5.0" />
  6. <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 $@' " />
  7. </launch>

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

  1. %YAML:1.0
  2. #--------------------------------------------------------------------------------------------
  3. # Camera Parameters. Adjust them!
  4. #--------------------------------------------------------------------------------------------
  5. # File.version: "1.0"
  6. Camera.type: "PinHole"
  7. # Right Camera calibration and distortion parameters (OpenCV)
  8. Camera.fx: 603.086
  9. Camera.fy: 603.23
  10. Camera.cx: 329.578
  11. Camera.cy: 232.509
  12. # distortion parameters
  13. Camera.k1: 0.15858
  14. Camera.k2: -0.492513
  15. Camera.k3: 0.4519
  16. Camera.p1: -0.00218088
  17. Camera.p2: 0.00021294
  18. # Camera resolution
  19. Camera.width: 640
  20. Camera.height: 480
  21. # Camera frames per second
  22. Camera.fps: 30
  23. # IR projector baseline times fx (aprox.)
  24. Camera.bf: 30.33325
  25. # Color order of the images (0: BGR, 1: RGB. It is ignored if images are grayscale)
  26. Camera.RGB: 1
  27. # Close/Far threshold. Baseline times.
  28. ThDepth: 40.0
  29. #Stereo.b: 0.0745
  30. DepthMapFactor: 1000.0
  31. # DepthMapFactor: 1.0
  32. # Depth map values factor
  33. # RGBD.DepthMapFactor: 1000.0
  34. #--------------------------------------------------------------------------------------------
  35. # ORB Parameters
  36. #--------------------------------------------------------------------------------------------
  37. # ORB Extractor: Number of features per image
  38. ORBextractor.nFeatures: 1000
  39. # ORB Extractor: Scale factor between levels in the scale pyramid
  40. ORBextractor.scaleFactor: 1.2
  41. # ORB Extractor: Number of levels in the scale pyramid
  42. ORBextractor.nLevels: 8
  43. # ORB Extractor: Fast threshold
  44. # Image is divided in a grid. At each cell FAST are extracted imposing a minimum response.
  45. # Firstly we impose iniThFAST. If no corners are detected we impose a lower value minThFAST
  46. # You can lower these values if your images have low contrast
  47. ORBextractor.iniThFAST: 20
  48. ORBextractor.minThFAST: 7
  49. #--------------------------------------------------------------------------------------------
  50. # Viewer Parameters
  51. #--------------------------------------------------------------------------------------------
  52. Viewer.KeyFrameSize: 0.05
  53. Viewer.KeyFrameLineWidth: 1.0
  54. Viewer.GraphLineWidth: 0.9
  55. Viewer.PointSize: 2.0
  56. Viewer.CameraSize: 0.08
  57. Viewer.CameraLineWidth: 3.0
  58. Viewer.ViewpointX: 0.0
  59. Viewer.ViewpointY: -0.7
  60. Viewer.ViewpointZ: -1.8
  61. Viewer.ViewpointF: 500.0
  62. PointCloudMapping.Resolution: 0.05
  63. meank: 50
  64. thresh: 1.0

发现源码颜色有点不对劲

修改源码:

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/647037
推荐阅读
相关标签
  

闽ICP备14008679号