硬件配置:HP ProDesk 480 G6 MT
系统内存:8G
处理器:Intel i7-8700 CPU
操作系统:Ubuntu 18.04
相机配置:Intel Realsense D435i
创建的ROS工作空间:catkin_ws
一、前期准备工作
1、新建名称为catkin_ws的工作空间,步骤可百度ROS基础教程相关知识
2、ROS Melodic下调通D435i
3、利用公开数据集单机跑通ORB_SLAM2
二、配置相关必要条件
1、修改环境变量
gedit ~/.bashrc
//在末尾加上ORB_SLAM2的地址,此处的PATH为用户名
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:home/PATH/catkin_ws/ORB_SLAM2/Examples/ROS
//保存后
source ~/.bashrc
2、编译./build_ros.sh文件
cd catkin_ws/src/ORB_SLAM2
chmod +x build_ros.sh
./build_ros.sh
3、书写D435i对应的yaml文件
cd Exampls/RGB-D
touch D435i.yaml
vim D435i.yaml
D435I.yaml内容如下:
%YAML:1.0
#--------------------------------------------------------------------------------------------
# Camera Parameters. Adjust them!
#--------------------------------------------------------------------------------------------
# Camera calibration and distortion parameters (OpenCV)
Camera.fx: 615.9417724609375
Camera.fy: 616.0935668945312
Camera.cx: 322.3533630371094
Camera.cy: 240.44674682617188
Camera.k1: 0.0
Camera.k2: 0.0
Camera.p1: 0.0
Camera.p2: 0.0
Camera.p3: 0.0
Camera.width: 640
Camera.height: 480
# Camera frames per second
Camera.fps: 30.0
# IR projector baseline times fx (aprox.)
# bf = baseline (in meters) * fx, D435i的 baseline = 50 mm
Camera.bf: 30.797
# 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
# Deptmap values factor
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
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、修改相机节点
根据前期单机运行相机的topic,可以看出相机节点发布的rgbd图和depth图话题名与ORB-SLAM2的订阅RGB图和depth图话题名不同,需要在ORB-SLAM2/Examples/ROS/ORB-SLAM2/src中修改ros_rgbd.cc的topic订阅
5、编译
./build_ros.sh
三、运行
分别在/home、/catkin_ws、/catkin_ws/src/ORB_SLAM2打开终端,分别执行如下命令
/home:启动ROS
roscore
/catkin_ws:运行相机节点
roslaunch realsense2_camera rs_rgbd.launch
/catkin_ws/src/ORB_SLAM2:运行SLAM
rosrun ORB_SLAM2 RGBD Vocabulary/ORBvoc.txt Examples/RGB-D/D435i.yaml