ROS indigo下Kinect v2的驱动安装与调试
ROS indigo下Kinect v2的驱动安装与调试
一、libfreenect2源码安装与测试
github地址:https://github.com/OpenKinect/libfreenect2
最终测试终端显示如下:
yuanlibin@yuanlibin:~/libfreenect2/build$ ./bin/Protonect Version: 0.2.0 Environment variables: LOGFILE=<protonect.log> Usage: ./bin/Protonect [-gpu=<id>] [gl | cl | clkde | cuda | cudakde | cpu] [<device serial>] [-noviewer] [-norgb | -nodepth] [-help] [-version] [-frames <number of frames to process>] To pause and unpause: pkill -USR1 Protonect [Info] [Freenect2Impl] enumerating devices... [Info] [Freenect2Impl] 6 usb devices connected [Error] [Freenect2Impl] failed to open Kinect v2: @2:5 LIBUSB_ERROR_ACCESS Access denied (insufficient permissions) [Info] [Freenect2Impl] found 0 devices no device connected! yuanlibin@yuanlibin:~/libfreenect2/build$ sudo ./bin/Protonect Version: 0.2.0 Environment variables: LOGFILE=<protonect.log> Usage: ./bin/Protonect [-gpu=<id>] [gl | cl | clkde | cuda | cudakde | cpu] [<device serial>] [-noviewer] [-norgb | -nodepth] [-help] [-version] [-frames <number of frames to process>] To pause and unpause: pkill -USR1 Protonect [Info] [Freenect2Impl] enumerating devices... [Info] [Freenect2Impl] 6 usb devices connected [Info] [Freenect2Impl] found valid Kinect v2 @2:5 with serial 003254763247 [Info] [Freenect2Impl] found 1 devices [Info] [Freenect2DeviceImpl] opening... [Info] [Freenect2DeviceImpl] transfer pool sizes rgb: 20*16384 ir: 60*8*33792 [Info] [Freenect2DeviceImpl] opened [Info] [Freenect2DeviceImpl] starting... [Debug] [Freenect2DeviceImpl] status 0x090000: 9729 [Debug] [Freenect2DeviceImpl] status 0x090000: 9731 [Info] [Freenect2DeviceImpl] submitting rgb transfers... [Info] [Freenect2DeviceImpl] submitting depth transfers... [Info] [Freenect2DeviceImpl] started device serial: 003254763247 device firmware: 2.3.3913.0 [Debug] [DepthPacketStreamParser] not all subsequences received 0 [Debug] [DepthPacketStreamParser] skipping depth packet [Debug] [DepthPacketStreamParser] skipping depth packet [Debug] [DepthPacketStreamParser] skipping depth packet [Debug] [DepthPacketStreamParser] skipping depth packet [Debug] [RgbPacketStreamParser] skipping rgb packet! [Info] [DepthPacketStreamParser] 4 packets were lost [Info] [OpenGLDepthPacketProcessor] avg. time: 6.45557ms -> ~154.905Hz [Info] [TurboJpegRgbPacketProcessor] avg. time: 14.7065ms -> ~67.9972Hz [Debug] [DepthPacketStreamParser] skipping depth packet [Info] [DepthPacketStreamParser] 1 packets were lost [Info] [OpenGLDepthPacketProcessor] avg. time: 7.00361ms -> ~142.783Hz [Info] [TurboJpegRgbPacketProcessor] avg. time: 14.0946ms -> ~70.9491Hz [Debug] [DepthPacketStreamParser] skipping depth packet [Info] [DepthPacketStreamParser] 1 packets were lost [Info] [OpenGLDepthPacketProcessor] avg. time: 6.18776ms -> ~161.609Hz [Info] [TurboJpegRgbPacketProcessor] avg. time: 14.1463ms -> ~70.6897Hz [Info] [OpenGLDepthPacketProcessor] avg. time: 5.06018ms -> ~197.621Hz [Info] [TurboJpegRgbPacketProcessor] avg. time: 14.4458ms -> ~69.2242Hz [Info] [OpenGLDepthPacketProcessor] avg. time: 5.03082ms -> ~198.775Hz [Info] [TurboJpegRgbPacketProcessor] avg. time: 14.595ms -> ~68.5168Hz [Info] [OpenGLDepthPacketProcessor] avg. time: 5.10736ms -> ~195.796Hz [Info] [TurboJpegRgbPacketProcessor] avg. time: 15.1131ms -> ~66.1676Hz [Info] [OpenGLDepthPacketProcessor] avg. time: 5.05573ms -> ~197.795Hz [Info] [TurboJpegRgbPacketProcessor] avg. time: 14.2058ms -> ~70.3937Hz [Info] [OpenGLDepthPacketProcessor] avg. time: 5.19326ms -> ~192.557Hz [Info] [TurboJpegRgbPacketProcessor] avg. time: 13.9728ms -> ~71.5675Hz [Info] [OpenGLDepthPacketProcessor] avg. time: 5.41113ms -> ~184.804Hz [Info] [TurboJpegRgbPacketProcessor] avg. time: 14.4546ms -> ~69.1822Hz [Info] [OpenGLDepthPacketProcessor] avg. time: 5.85608ms -> ~170.763Hz [Info] [TurboJpegRgbPacketProcessor] avg. time: 14.8185ms -> ~67.4832Hz [Info] [OpenGLDepthPacketProcessor] avg. time: 6.48623ms -> ~154.173Hz [Info] [TurboJpegRgbPacketProcessor] avg. time: 14.9838ms -> ~66.7385Hz [Info] [OpenGLDepthPacketProcessor] avg. time: 9.83449ms -> ~101.683Hz [Info] [TurboJpegRgbPacketProcessor] avg. time: 15.2176ms -> ~65.7133Hz [Info] [OpenGLDepthPacketProcessor] avg. time: 11.5814ms -> ~86.3453Hz [Info] [TurboJpegRgbPacketProcessor] avg. time: 15.1936ms -> ~65.817Hz [Info] [OpenGLDepthPacketProcessor] avg. time: 11.2376ms -> ~88.9869Hz [Info] [TurboJpegRgbPacketProcessor] avg. time: 15.3206ms -> ~65.2715Hz [Info] [OpenGLDepthPacketProcessor] avg. time: 10.45ms -> ~95.6942Hz [Info] [TurboJpegRgbPacketProcessor] avg. time: 15.2756ms -> ~65.4638Hz [Info] [OpenGLDepthPacketProcessor] avg. time: 9.9264ms -> ~100.741Hz [Info] [TurboJpegRgbPacketProcessor] avg. time: 15.1589ms -> ~65.9679Hz [Info] [OpenGLDepthPacketProcessor] avg. time: 9.85152ms -> ~101.507Hz [Info] [TurboJpegRgbPacketProcessor] avg. time: 15.096ms -> ~66.2426Hz [Info] [OpenGLDepthPacketProcessor] avg. time: 9.81726ms -> ~101.861Hz [Info] [TurboJpegRgbPacketProcessor] avg. time: 14.9504ms -> ~66.8881Hz [Info] [OpenGLDepthPacketProcessor] avg. time: 9.81506ms -> ~101.884Hz [Info] [TurboJpegRgbPacketProcessor] avg. time: 14.9432ms -> ~66.9201Hz [Info] [OpenGLDepthPacketProcessor] avg. time: 9.83013ms -> ~101.728Hz [Info] [TurboJpegRgbPacketProcessor] avg. time: 14.9232ms -> ~67.0098Hz [Info] [OpenGLDepthPacketProcessor] avg. time: 7.37377ms -> ~135.616Hz [Info] [TurboJpegRgbPacketProcessor] avg. time: 14.6522ms -> ~68.2493Hz [Info] [OpenGLDepthPacketProcessor] avg. time: 7.17901ms -> ~139.295Hz [Info] [TurboJpegRgbPacketProcessor] avg. time: 14.5835ms -> ~68.5707Hz [Info] [OpenGLDepthPacketProcessor] avg. time: 7.17929ms -> ~139.289Hz [Info] [TurboJpegRgbPacketProcessor] avg. time: 15.2584ms -> ~65.5379Hz [Info] [Freenect2DeviceImpl] stopping... [Info] [Freenect2DeviceImpl] canceling rgb transfers... [Info] [Freenect2DeviceImpl] canceling depth transfers... [Info] [Freenect2DeviceImpl] stopped [Info] [Freenect2DeviceImpl] closing... [Info] [Freenect2DeviceImpl] releasing usb interfaces... [Info] [Freenect2DeviceImpl] deallocating usb transfer pools... [Info] [Freenect2DeviceImpl] closing usb device... [Info] [Freenect2DeviceImpl] closed [Info] [Freenect2DeviceImpl] closing... [Info] [Freenect2DeviceImpl] already closed, doing nothing
二、iai-kinect2源码安装与测试
github地址:https://github.com/code-iai/iai_kinect2
说明:
在安装依赖项中需要opencv2.4.*,不能用opencv3.*。
测试过程中先默认路径安装了opencv2.4.9,然后安装iai-kinect2,可以正常运行。但是指定路径安装了opencv3.1.0就无法运行了。
但是在默认路径安装了opencv2.4.9后,先指定路径安装了opencv3.1.0,最后安装iai-kinect2,是可以正常运行的。
1. 新建一个catkin_ws工作空间,编译安装iai-kinect2
mkdir catkin_ws cd catkin_ws mkdir src cd src
git clone https://github.com/code-iai/iai_kinect2.git
cd iai_kinect2
rosdep install -r --from-paths .
cd ~/catkin_ws
catkin_make -DCMAKE_BUILD_TYPE="Release"
rospack profile
2. 测试是否安装成功
roslaunch kinect2_bridge kinect2_bridge.launch
若出现以下错误:
[FATAL] [1479522843.484561710]: Failed to load nodelet '/kinect2_points_xyzrgb_qhd` of type `depth_image_proc/point_cloud_xyzrgb` to manager `kinect2' [FATAL] [1479522843.485011986]: Failed to load nodelet '/kinect2_points_xyzrgb_sd` of type `depth_image_proc/point_cloud_xyzrgb` to manager `kinect2' [FATAL] [1479522843.485174496]: Failed to load nodelet '/kinect2_bridge` of type `kinect2_bridge/kinect2_bridge_nodelet` to manager `kinect2' [kinect2-2] process has died [pid 14131, exit code -11, cmd /opt/ros/indigo/lib/nodelet/nodelet manager __name:=kinect2 __log:=/home/yuanlibin/.ros/log/a0154834-ae00-11e6-9636-1c1b0d61bf22/kinect2-2.log]. log file: /home/yuanlibin/.ros/log/a0154834-ae00-11e6-9636-1c1b0d61bf22/kinect2-2*.log [kinect2_bridge-3] process has died [pid 14138, exit code 255, cmd /opt/ros/indigo/lib/nodelet/nodelet load kinect2_bridge/kinect2_bridge_nodelet kinect2 __name:=kinect2_bridge __log:=/home/yuanlibin/.ros/log/a0154834-ae00-11e6-9636-1c1b0d61bf22/kinect2_bridge-3.log]. log file: /home/yuanlibin/.ros/log/a0154834-ae00-11e6-9636-1c1b0d61bf22/kinect2_bridge-3*.log [kinect2_bridge-3] restarting process process[kinect2_bridge-3]: started with pid [14349] [ INFO] [1479522843.775811528]: Loading nodelet /kinect2_bridge of type kinect2_bridge/kinect2_bridge_nodelet to manager kinect2 with the following remappings: [ INFO] [1479522843.777704976]: waitForService: Service [/kinect2/load_nodelet] could not connect to host [yuanlibin:45567], waiting... [kinect2_points_xyzrgb_sd-4] process has died [pid 14139, exit code 255, cmd /opt/ros/indigo/lib/nodelet/nodelet load depth_image_proc/point_cloud_xyzrgb kinect2 rgb/camera_info:=kinect2/sd/camera_info rgb/image_rect_color:=kinect2/sd/image_color_rect depth_registered/image_rect:=kinect2/sd/image_depth_rect depth_registered/points:=kinect2/sd/points __name:=kinect2_points_xyzrgb_sd __log:=/home/yuanlibin/.ros/log/a0154834-ae00-11e6-9636-1c1b0d61bf22/kinect2_points_xyzrgb_sd-4.log]. log file: /home/yuanlibin/.ros/log/a0154834-ae00-11e6-9636-1c1b0d61bf22/kinect2_points_xyzrgb_sd-4*.log [kinect2_points_xyzrgb_qhd-5] process has died [pid 14140, exit code 255, cmd /opt/ros/indigo/lib/nodelet/nodelet load depth_image_proc/point_cloud_xyzrgb kinect2 rgb/camera_info:=kinect2/qhd/camera_info rgb/image_rect_color:=kinect2/qhd/image_color_rect depth_registered/image_rect:=kinect2/qhd/image_depth_rect depth_registered/points:=kinect2/qhd/points __name:=kinect2_points_xyzrgb_qhd __log:=/home/yuanlibin/.ros/log/a0154834-ae00-11e6-9636-1c1b0d61bf22/kinect2_points_xyzrgb_qhd-5.log]. log file: /home/yuanlibin/.ros/log/a0154834-ae00-11e6-9636-1c1b0d61bf22/kinect2_points_xyzrgb_qhd-5*.log [kinect2_points_xyzrgb_sd-4] restarting process process[kinect2_points_xyzrgb_sd-4]: started with pid [14368] [kinect2_points_xyzrgb_qhd-5] restarting process process[kinect2_points_xyzrgb_qhd-5]: started with pid [14369] [kinect2_points_xyzrgb_hd-6] process has finished cleanly log file: /home/yuanlibin/.ros/log/a0154834-ae00-11e6-9636-1c1b0d61bf22/kinect2_points_xyzrgb_hd-6*.log [kinect2_points_xyzrgb_hd-6] restarting process process[kinect2_points_xyzrgb_hd-6]: started with pid [15202]
是因为在.bashrc文件中要添加如下代码,并且要注释掉原来的rgbdslam_catkin_ws的那行代码
#source /home/yuanlibin/rgbdslam_catkin_ws/devel/setup.bash
source /home/yuanlibin/catkin_ws/devel/setup.bash
最后测试
终端1
roslaunch kinect2_bridge kinect2_bridge.launch
终端2
rosrun kinect2_viewer kinect2_viewer
测试成功。
此时,可以按空格或者s键单张采集彩色图、深度图及其对应的点云图图像。
如果要连续采集图像,请参考博文:http://blog.csdn.net/sunbibei/article/details/51594824