ORB_SLAM2+kinect2+ros_indigo

来源:互联网 发布:linux嵌入式开发 编辑:程序博客网 时间:2024/06/07 10:35

1 安装依赖:
a、GLEW:

sudo apt-get install libglew-dev

b、Boost:

sudo apt-get install libboost-dev libboost-thread-dev libboost-filesystem-dev

c、Python2.7:

sudo apt-get install libpython2.7-dev

d、编译基础库

sudo apt-get install build-essential

e、安装Pangolin:

cd catkin_wscd srcgit clone https://github.com/stevenlovegrove/Pangolin.gitcd Pangolinmkdir buildcd buildcmake -DCPP11_NO_BOOST=1 ..make

f、安装libfreenect2 and iai_kinect2

http://www.cnblogs.com/hitcm/p/5118196.html

2 安装ORB_SLAM:

source ~/.bashrcexport ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/user/ORB_SLAM2/Examples/ROS

上面这个一定要做,否则会出错说找不到路径和包

(1)Clone the repository:

git clone https://github.com/raulmur/ORB_SLAM2.git ORB_SLAM2

(2)编译:

cd ORB_SLAM2chmod +x build.sh

修改./build.sh,安装vim

sudo apt-get install vimvim ./build.sh 

修改最后一行,改 make -j 为 make

./build.sh

ROS版本安装

chmod +x build_ros.sh./build_ros.sh

2.打开一个终端,运行:

roslaunch kinect2_bridge kinect2_bridge.launch

3.再打开另一个终端,输入:rostopic list查看此时Kinect2发布的topic,我用的是/kinect2/qhd/image_color_rect和/kinect2/qhd/image_depth_rect
4.找到源文件ros_rgbd.cc,按照上面3的topic修改里面的ros订阅的内容
5.重新编译工程

chmod +x build_ros.sh./build_ros.sh

6.在~/ORB_SLAM2/Examples/ROS$ 目录下,运行

rosrun ORB_SLAM2 RGBD /home/user/ORB_SLAM2/Vocabulary/ORBvoc.txt /home/user/ORB_SLAM2/Examples/RGB-D/kinect2_qhd.yaml

Kinect2的topic一共有三种,含不同的分辨率。其中hd是1920的,qhd是四分之一的960的,而sd是最小的。博主发现sd的效果不理想,而hd的图像又太大了,建议大家使用qhd的920大小啦!在调用orb-slam时,需要把相机参数通过一个yaml来告诉它,所以需要简单写一下你的kinect参数喽。比如像这样:

在/home/user/ORB_SLAM2/Examples/RGB-D/下创建:

kinect2_qhd.yaml

%YAML:1.0#--------------------------------------------------------------------------------------------# Camera Parameters. Adjust them!#--------------------------------------------------------------------------------------------# Camera calibration and distortion parameters (OpenCV) Camera.fx: 529.97Camera.fy: 526.97Camera.cx: 477.44Camera.cy: 261.87Camera.k1: 0.05627Camera.k2: -0.0742Camera.p1: 0.00142Camera.p2: -0.00169Camera.k3: 0.0241Camera.width: 960Camera.height: 540# 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: 50.0# Deptmap values factor DepthMapFactor: 1000.0#--------------------------------------------------------------------------------------------# ORB Parameters#--------------------------------------------------------------------------------------------# ORB Extractor: Number of features per imageORBextractor.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: 20ORBextractor.minThFAST: 7#--------------------------------------------------------------------------------------------# Viewer Parameters#--------------------------------------------------------------------------------------------Viewer.KeyFrameSize: 0.05Viewer.KeyFrameLineWidth: 1Viewer.GraphLineWidth: 0.9Viewer.PointSize:2Viewer.CameraSize: 0.08Viewer.CameraLineWidth: 3Viewer.ViewpointX: 0Viewer.ViewpointY: -0.7Viewer.ViewpointZ: -1.8Viewer.ViewpointF: 500
原创粉丝点击