如何使用kinect2.0 跑通orbslamv2

今天记录一下如何使用orbslam跑通robslamv2:

首先需要安装kinect2.0的驱动,详见前面讲的博客。

接着需要标定kinect2,记住一定要进行标定,否则只要一动kinect,就会跑丢

好了,回到重点吧

step1:下载orbslam2,

git clone https://github.com/raulmur/ORB_SLAM2.git ORB_SLAM2
安装需要的安装的驱动,这里直接见https://github.com/raulmur/ORB_SLAM2

在执行一下代码之前,首先需要改动3个地方:

第一个地方:在目录Example/ROS/ORBSLAM2/src/ros_rgbd.cc中:因为kinect发布的topic改变了,不是程序中默认的,所以需要改动,在启动

roslaunch kinect_bridge kinect_bridge.launch 后,执行rostopic list,查看发布的话题,本文为:

"/kinect2/hd/image_color"和"kinect2/hd/image_depth_rect"


第二个地方就是在~/.bashrc加入下面的ros环境变量,便于查找路径,代码如下:

xport ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/lizhi/ORB_SLAM2/Examples/ROS


第三个地方就是之前你自己标定相机参数,在TUM1.yaml将他改过来,我自己的参数为:

%YAML:1.0

#--------------------------------------------------------------------------------------------
# Camera Parameters. Adjust them!
#--------------------------------------------------------------------------------------------

# Camera calibration and distortion parameters (OpenCV)
Camera.fx: 1.0467288481412274e+03
Camera.fy: 1.0481754542172425e+03
Camera.cx: 9.7306718807504012e+02
Camera.cy: 5.4801789979871785e+02

Camera.k1: 3.2019593488579724e-02
Camera.k2: -1.3038285760250972e-02
Camera.p1: 1.1981018792870713e-03
Camera.p2: -1.4350146086688656e-03
Camera.k3: -3.2574074881408052e-02

Camera.width: 1920
Camera.height: 1080

# Camera frames per second
Camera.fps: 30.0

# IR projector baseline times fx (aprox.)
Camera.bf: 40.0

# 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   yuanlai de shi 5000
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



step2:执行下面的代码就可跑数据集了

cd ORB_SLAM2

./build.sh
step3:用kinect2来实施跑动:

./build_ros.sh
接着执行:

rosrun ORB_SLAM2 RGBD  Vocabulary/ORBvoc.txt vi Examples/RGB-D/TUM1.yaml 即可

如果要跑通数据集,不需要第三步了,直接执行第二布即可。

你可能感兴趣的:(计算机视觉)