ORB_SLAM2之RGBD测试

ORB_SLAM2的安装和编译这里不再讲,我前面的博客已经记录了。

这里直接开始自带Examples里面的RGBD测试。

1、添加环境变量

$gedit ~/.bashrc

在文件末尾添加:

export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home

/**/ORB_SLAM2/Examples/ROS

注意添加自己的路径(lu jing),居然打不出来,呜呜

2、在目录ORB_SLAM2/Examples/ROS/ORB_SLAM2/src

/ros_rgbd.cc中:因为kinect发布的topic改变了,不是程序中默认的,所

以需要改动.

$gedit ros_rgbd.cc

在函数int main(int argc, char **argv)里面

更改信息内容

message_filters::Subscriber::Image> rgb_sub(nh, "/kinect2/qhd/image_color_rect", 1);
message_filters::Subscriber::Image> depth_sub(nh, "/kinect2/qhd/image_depth_rect", 1);

也可以刚换成

/kinect2/hd/image_color 和/kinect2/hd

/image_color_rect,亲测可用。

新终端

$ roscore

新终端

$ roslaunch kinect2_bridge kinect2_bridge.launch
新终端

$ rostopic list

/kinect2/bond
/kinect2/hd/camera_info
/kinect2/hd/image_color
/kinect2/hd/image_color/compressed
/kinect2/hd/image_color_rect
/kinect2/hd/image_color_rect/compressed
/kinect2/hd/image_depth_rect
/kinect2/hd/image_depth_rect/compressed
/kinect2/hd/image_mono
/kinect2/hd/image_mono/compressed
/kinect2/hd/image_mono_rect
/kinect2/hd/image_mono_rect/compressed
/kinect2/hd/points
/kinect2/qhd/camera_info
/kinect2/qhd/image_color
/kinect2/qhd/image_color/compressed
/kinect2/qhd/image_color_rect
/kinect2/qhd/image_color_rect/compressed
/kinect2/qhd/image_depth_rect
/kinect2/qhd/image_depth_rect/compressed
/kinect2/qhd/image_mono
/kinect2/qhd/image_mono/compressed
/kinect2/qhd/image_mono_rect
/kinect2/qhd/image_mono_rect/compressed
/kinect2/qhd/points
/kinect2/sd/camera_info
/kinect2/sd/image_color_rect
/kinect2/sd/image_color_rect/compressed
/kinect2/sd/image_depth
/kinect2/sd/image_depth/compressed
/kinect2/sd/image_depth_rect
/kinect2/sd/image_depth_rect/compressed
/kinect2/sd/image_ir
/kinect2/sd/image_ir/compressed
/kinect2/sd/image_ir_rect
/kinect2/sd/image_ir_rect/compressed
/kinect2/sd/points
/rosout
/rosout_agg

3、重新编译ORB_SLAM2

chmod +x build_ros.sh

./build_ros.sh
4、更改kinect v2校准参数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

6、在ORB_SLAM2/Examples/ROS$目录执行

rosrun ORB_SLAM2 RGBD /home/×××/ORB_SLAM2

/Vocabulary/ORBvoc.txt /home/×××/ORB_SLAM2/Examples

/RGB-D/TUM1.yaml

走到这一步,就能看到输出结果了。

你可能感兴趣的:(ros)