1.参照官方教程安装depthai_ros;1.1. ROS1 noetic + depthai_ros教程 — DepthAI Docs 0.3.0.0 documentation
2.安装好depthai_ros之后测试下面指令:
roslaunch depthai_examples stereo_node.launch
此指令代表启动depthai_examples包下的stereo_node.launch节点,如下图所示
3.接下来下载编译OPR_SLAM3,参照安装ORB-SLAM3教程-CSDN博客
4.查看并修改相机参数。
4.1在dai_ws工作区下运行roslaunch depthai_examples stereo_node.launch指令,打开另外一个终端输入rostopic list 指令
输入以下指令可分别查看左右相机内参
rostopic echo -n 1 /stereo_publisher/left/camera_info
rostopic echo -n 1 /stereo_publisher/right/camera_info
之后即可出现内参信息
4.2参照下图分别得出内参信息:
4.3编写oak-d-pro-poe相机的内参文件 oak-d-pro-poe.yaml
%YAML:1.0
#--------------------------------------------------------------------------------------------
# Camera Parameters. Adjust them!
#--------------------------------------------------------------------------------------------
Camera.type: "PinHole"# Camera calibration and distortion parameters (OpenCV)
# Copied from the EEPROM data dump in depthai_demo.py.
Camera.fx: 836.39874268 #需要修改
Camera.fy: 836.66235352 #需要修改
Camera.cx: 636.00115967 #需要修改
Camera.cy: 357.10168457 #需要修改Camera.k1: 0.0
Camera.k2: 0.0
Camera.k3: 0.0
Camera.k4: 0.0
Camera.p1: 0.0
Camera.p2: 0.0Camera2.fx: 843.39074707 #需要修改
Camera2.fy: 843.87249756 #需要修改
Camera2.cx: 635.90380859 #需要修改
Camera2.cy: 359.52798462 #需要修改Camera2.k1: 0.0
Camera2.k2: 0.0
Camera2.k3: 0.0
Camera2.k4: 0.0
Camera2.p1: 0.0
Camera2.p2: 0.0Camera.bFishEye: 0
Camera.width: 1280
Camera.height: 720# Camera frames per second
Camera.fps: 30.0# stereo baseline times fx
Camera.bf: 62.729905701 #需要修改# 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: 37.5#--------------------------------------------------------------------------------------------
# ORB Parameters
#--------------------------------------------------------------------------------------------# ORB Extractor: Number of features per image
ORBextractor.nFeatures: 1200# 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
Viewer.GraphLineWidth: 0.9
Viewer.PointSize:2
Viewer.CameraSize: 0.08
Viewer.CameraLineWidth: 3
Viewer.ViewpointX: 0
Viewer.ViewpointY: -0.7
Viewer.ViewpointZ: -1.8
Viewer.ViewpointF: 500
根据4.1得到的内参信息对照4.2修改信息。
5.运行ORB SLAM3
5.1在dai_ws工作区中启动双目节点
roslaunch depthai_examples stereo_node.launch
5.2 在orb slam3中打开第二个终端
rosrun ORB_SLAM3 Stereo ORB_SLAM3/Vocabulary/ORBvoc.txt oak-d-pro-poe.yaml false
false 表示是否进行图像校正。在这里,设置为 "false" 表示不进行图像校正处理。
若出现报错
Usage: rosrun ORB_SLAM3 Stereo path_to_vocabulary path_to_settings do_rectify
则将指令中 ORBvoc.txt和oak-d-pro-poe.yaml的路径改为绝对路径。
效果如下图所示