ubuntu14.04 and ros indigo install kinect driver--16

weixin_34037977發表於2016-03-13

摘要: 原創部落格:轉載請表明出處:http://www.cnblogs.com/zxouxuewei/

 

今日多次測設ros indigo install kinect driver ,提示各種失敗,然後心情非常不好 ,時不時的吐槽一下沒有好的資料,在翻遍近百個貼後終於有初步結果。

1.在ubuntu上安裝kinect驅動比較繁瑣,需要安裝以下3個驅動包,

  OpenNI-Bin-Dev-Linux-x64-v1.5.7.10

  NITE-Bin-Dev-Linux-x64-v1.5.2.23

  Sensor-Bin-Linux-x64-v5.1.2.1

2.可以在我的git上下載:https://github.com/ZXWBOT/kinect_driver

git clone https://github.com/ZXWBOT/kinect_driver.git

也可以直接在網盤下載:http://pan.baidu.com/s/1hqHB10w 提取密碼:wrmn

3.下載好三個驅動包後,在相應的資料夾解壓。

4.然後一次安裝:

安裝之前首先說明一下:特殊壓縮的解壓方法:

xxx.tar.gz 解壓:tar xvzf xxx.tar.gz

xxx.zip  解壓:unzip  xxx.zip

xxx.tar.bz2  解壓:tar -jxvf xxx.tar.bz2

xxx.tar.zip 分兩步解壓  1> unzip xxx.tar.zip  結果為 xxx.tar.bz2

           2>  tar -jxvf xxx.tar.bz2

1>、安裝openni

cd !/kinect/OpenNI-Bin-Dev-Linux-x64-v1.5.7.10
sudo ./install.sh 

如果顯示如下

Installing OpenNI
****************************

copying shared libraries...OK
copying executables...OK
copying include files...OK
creating database directory...OK
registering module 'libnimMockNodes.so'...OK
registering module 'libnimCodecs.so'...OK
registering module 'libnimRecorder.so'...OK
creating java bindings directory...OK
Installing java bindings...OK

*** DONE ***
則安裝成功

2>、安裝NITE

cd ~/kinect/NITE-Bin-Linux-x64-v1.5.2.23
sudo ./install.sh

如果顯示如下:

Installing NITE
***************

Copying shared libraries... OK
Copying includes... OK
Installing java bindings... OK
Installing module 'Features_1_3_0'...
Registering module 'libXnVFeatures_1_3_0.so'... OK
Installing module 'Features_1_3_1'...
Registering module 'libXnVFeatures_1_3_1.so'... OK
Installing module 'Features_1_4_1'...
Registering module 'libXnVFeatures_1_4_1.so'... OK
Installing module 'Features_1_4_2'...
Registering module 'libXnVFeatures_1_4_2.so'... OK
Installing module 'Features_1_5_2'...
Registering module 'libXnVFeatures_1_5_2.so'... OK
Copying XnVSceneServer... OK
Installing module 'Features_1_5_2'
registering module 'libXnVHandGenerator_1_3_0.so'...OK
Installing module 'Features_1_5_2'
registering module 'libXnVHandGenerator_1_3_1.so'...OK
Installing module 'Features_1_5_2'
registering module 'libXnVHandGenerator_1_4_1.so'...OK
Installing module 'Features_1_5_2'
registering module 'libXnVHandGenerator_1_4_2.so'...OK
Installing module 'Features_1_5_2'
registering module 'libXnVHandGenerator_1_5_2.so'...OK
Adding license.. OK

*** DONE ***
則安裝成功

3>、安裝Sensor

cd ~/kinect/Sensor-Bin-Linux-x64-v5.1.2.1
sudo ./install.sh

如果顯示如下

Installing PrimeSense Sensor
****************************

creating config dir /usr/etc/primesense...OK
copying shared libraries...OK
copying executables...OK
registering module 'libXnDeviceSensorV2KM.so' with OpenNI...OK
registering module 'libXnDeviceFile.so' with OpenNI...OK
copying server config file...OK
setting uid of server...OK
creating server logs dir...OK
installing usb rules...OK
installing modprobe blacklist...OK

*** DONE ***
則安裝成功

5、執行示例
連上kinect的資料線

cd ~/kinect/OpenNI-Bin-Dev-Linux-x64-v1.5.7.10/Samples/Bin/x64-Release
./NiViewer 

如果出現kinect畫面則配置成功

六、問題

1、注意如果出現:

One or more of the following nodes could not be enumerated:

Device: PrimeSense/SensorV2/5.1.6.6: The device is not connected!
Device: PrimeSense/SensorV2/5.1.0.41: The device is not connected!
Device: PrimeSense/SensorV2/5.1.6.6: The device is not connected!
Device: PrimeSense/SensorV2/5.1.0.41: The device is not connected!

Press any key to continue . . .

這樣的問題有可能是這三個包版本不匹配,我這裡的三個包親測是可用的。但是Sensor如果是5.1.6.6版本則出現上面報錯。
之前安裝好了驅動可以正常執行的,今天執行openni的節點卻發現不能正常開啟Kinect了,報錯如下:

Device: PrimeSense/SensorV2/5.1.0.41: The device is not connected!

於是我重新做了一遍步驟四

$ cd /home/siat/software/Sensor-Bin-Linux-x64-v5.1.2.1
$ sudo ./install.sh

再次執行示例程式成功啟動Kinect
我嘗試用32位版本的驅動來啟動xtion,還是提示連不上裝置,當我重新編譯上面三個64位驅動執行NiViewr的時候出現如下提示:

One or more of the following nodes could not be enumerated:

Device: PrimeSense/SensorKinect/5.1.2.1: The device is not connected!
Device: PrimeSense/SensorV2/5.1.0.41: The device is not connected!
Device: PrimeSense/SensorKinect/5.1.2.1: The device is not connected!
Device: PrimeSense/SensorV2/5.1.0.41: The device is not connected!

Press any key to continue . . .

我用./install.sh -u 解除安裝Openni和Sensor,用./uninstall.sh 解除安裝NITE,然後重新到原64位Sensor驅動下執行./install.sh 之後正常使用NiViewr開啟kinect。

2、注意openni2和NITE2版本的包現在只能用於xtion,kinect只能使用版本1的驅動
3、檢視版本

$ pkg-config --modversion opencv

會顯示版本號,比如2.4.11

可以將OpenCV替換為其他包名字,用Tab鍵補全以避免名字出錯

4、用apt-get方式安裝的一些包
kinect用的freenect:

$ sudo apt-get install ros-indigo-freenect-launch
$ sudo apt-get install ros-indigo-freenect-camera
$ sudo apt-get install ros-indigo-freenect-stack

xtion用的openni:

$ sudo apt-get install ros-indigo-openni-camera
$ sudo apt-get install ros-indigo-openni-launch
上面如果不行請使用下面的驅動
$ sudo apt-get install ros-indigo-openni2-camera
$ sudo apt-get install ros-indigo-openni2-launch

5、關於kinect和xtion切換的問題
openni預設的裝置是kinect,如果你用的是kinect,裝完上面的驅動之後執行NiViewer可以正常使用
但是如果你使用的裝置是xtion,直接執行NiViewer會出現如下報錯

Open failed: USB interface is not supported!

執行$ roslaunch openni_launch openni.launch 出現如下報錯

[ INFO] [1464612941.306334563]: Initializing nodelet with 4 worker threads.
[ INFO] [1464612947.664521213]: Number devices connected: 1
[ INFO] [1464612947.666982470]: 1. device on bus 002:04 is a SensorV2 (601) from PrimeSense (1d27) with serial id '1312120224'
[ INFO] [1464612947.667906288]: Searching for device with index = 1
[ INFO] [1464612947.670034045]: No matching device found.... waiting for devices. Reason: openni_wrapper::OpenNIDevice::OpenNIDevice(xn::Context&, const xn::NodeInfo&, const xn::NodeInfo&, const xn::NodeInfo&, const xn::NodeInfo&) @ /tmp/binarydeb/ros-indigo-openni-camera-1.9.5/src/openni_device.cpp @ 61 : creating depth generator failed. Reason: USB interface is not supported!

也是USB interface is not supported! 的問題
解決方案如下:參考部落格
修改GlobalDefaults.ini配置檔案

$ sudo gedit /etc/openni/GlobalDefaults.ini 

將第60行前面的分號去掉(即取消註釋)

;UsbInterface=2

再次嘗試執行openni.launch 或者NiViewer 就可以用xtion了,如果不行還需要重啟一下電腦


關於xtion博主還有一個一直很困擾的問題,在剛裝系統的電腦上安裝上面三個驅動使用xtion很正常,但是在使用了一段時間的電腦上裝這三個驅動卻一直提示the device is not connected!,試了上面所有的方案都不行,估計是驅動衝突,我解除安裝了所有openni、nite相關的包重新安裝驅動也不行,最後只好無奈的使用微軟的Kinect才正常

6、Open failed: Xiron OS failed to wait on event!
執行如下命令:

$ sudo chmod +x /usr/bin/XnSensorServer

7、博主重灌了32位ubuntu14.04,然後下載上面三個驅動對應的32位驅動,編譯之後可以驅動華碩的xtion pro live,值得注意的是有可能遇到如下問題

Open failed: Failed to set USB interface!

這個問題跟前面的類似,需要改GlobalDefaults.ini 檔案,但是32位驅動的這個配置檔案不在/etc/openni/下了,搜尋了一下資料夾找到這個檔案原來是在/usr/etc/primesense/

$ sudo gedit /usr/etc/primesense/GlobalDefaults.ini 

將第60行前面的分號去掉(即取消註釋)

;UsbInterface=2

再次嘗試執行openni.launch 或者NiViewer 就可以用xtion了,如果不行還需要重啟一下電腦

8、Find user generator failed: Error!
我使用xtion遇到這個問題如下報錯,重新把壓縮包拷到電腦上解壓之後編譯openni、Sensor、NITE這三個驅動,然後取消GlobalDefaults.ini檔案裡;UsbInterface=2 行的註釋就好了

$ ./Sample-NiSimpleSkeleton 
Reading config from: '../../Config/SamplesConfig.xml'
Could not find data file /usr/etc/primesense/Features_1_5_2/s.dat
current working directory = /home/robot/software/OpenNI-Bin-Dev-Linux-x86-v1.5.7.10/Samples/Bin/x86-Release
Find user generator failed: Error!

9、No devices connected…. waiting for devices to be connected
如果出現如下報錯:

roslaunch openni_launch openni.launch
[ INFO] [1470382635.817744169]: Initializing nodelet with 4 worker threads.
[ INFO] [1470382643.589318569]: No devices connected.... waiting for devices to be connected
  • 首先是驅動問題
    檢查前面說的驅動是否正確安裝
    如果之前是正常使用的,驅動沒有問題
  • 再檢查USB裝置
    執行lsusb
$ lsusb 
Bus 004 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 004: ID 04f2:b398 Chicony Electronics Co., Ltd 
Bus 003 Device 012: ID 04ca:2007 Lite-On Technology Corp. 
Bus 003 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 029: ID 045e:02ad Microsoft Corp. Xbox NUI Audio
Bus 001 Device 027: ID 045e:02c2 Microsoft Corp. Kinect for Windows NUI Motor
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

如果只有Microsoft Corp.裝置只有一個或沒有說明Kinect線沒插上或者供電不足,檢查Kinect分叉線的連線處和電源介面處是否正確連線,並檢查電量。

比如我的turtlebot2在底盤電量顯示還有30%左右的時候用lsusb 檢視裝置發現只有Microsoft Corp. Kinect for Windows NUI Motor 而找不到Microsoft Corp. Xbox NUI Audio ,換一個外部供電的Kinect可以正常使用,lsusb 顯示的也是兩個裝置。這也是很無奈的事情,只好乖乖充電了,也許底盤電量顯示不符合實際。

10、turtlebot官網的驅動安裝

  • 首先按照前面說的安裝openni
    請參照 二、安裝OpenNI
  • 安裝SensorKinect
mkdir ~/kinectdriver 
cd ~/kinectdriver 
git clone https://github.com/avin2/SensorKinect 
cd SensorKinect/Bin/
tar xvjf SensorKinect093-Bin-Linux-x64-v5.1.2.1.tar.bz2
cd Sensor-Bin-Linux-x64-v5.1.2.1/
sudo ./install.sh

 

相關文章