Linux防健忘日誌No.41-Ubuntu 10.10 KINECT IN UBUNTU!



繼上次硬要再Ubuntu上星海爭霸2之後
前幾天入手kinect…但入手不是拿來玩電動
主要是學術用途,其他附加價值才是玩電動啦(呵欠)

材料清單:
Kinect感應器一台
Kinect變壓器連接線(因為上面有slim版接頭轉USB,這樣才能正常連接到電腦上)
“有點”程式基礎,以及會用linux的大腦
配備還不錯且有安裝Ubuntu的電腦

這次要介紹的是ROS套件

先講ROS
這是外國一個社群團體
我不太清楚是誰來主導…可能是某間學校吧?
但再電腦上跑Kinect大多需要ROS或者Openkinect當作基底

網路上各大神人大多以這兩個基底套件做延伸開發(至少再微軟還沒公開釋出SDK的時候是這樣)

安裝過程相當冗長且無聊
請有心理準備…我這邊還是中文解說咧…

1.把ROS加入PPA中
sudo sh -c 'echo “deb http://code.ros.org/packages/ros/ubuntu maverick main” > /etc/apt/sources.list.d/ros-latest.list'

2.取得ROS的金鑰
wget http://code.ros.org/packages/ros.key -O – | sudo apt-key add –

3.更新一下PPA
sudo apt-get install update

4.接著視功能安裝需要的套件,這邊安裝base(詳細請參照下面的參考鏈)
sudo apt-get install ros-cturtle-base

5.把環境變數設定好
echo “source /opt/ros/cturtle/setup.sh” >> ~/.bashrc
. ~/.bashrc
 
以上是基本ROS安裝,接著要安裝表層SDK..

1.抓取表層SDK
sudo apt-get install ros-cturtle-kinect ros-cturtle-visualization

這時候把你的Kinect插上主機
 
2.變更USB Port口存取權限
sudo chmod 777 -R /dev/bus/usb

3.自行新增kinect描述檔到 /etc/udev/rules.d/53-kinect.rules

 # /etc/udev/rules.d/53-kinect.rules
# make kinect device mount with writing permissions
#(default is read only for unknown devices)
# ATTR{product}==”Xbox NUI Motor”
SUBSYSTEM==”usb”, ATTR{idVendor}==”045e”, ATTR{idProduct}==”02b0″, MODE=”0666″

# ATTR{product}==”Xbox NUI Audio”
SUBSYSTEM==”usb”, ATTR{idVendor}==”045e”, ATTR{idProduct}==”02ad”, MODE=”0666″

# ATTR{product}==”Xbox NUI Camera”
SUBSYSTEM==”usb”, ATTR{idVendor}==”045e”, ATTR{idProduct}==”02ae”, MODE=”0666″

4.重新將裝置服務重開
sudo service udev reload

5.開啟第一個終端機啟動驅動Kinect程序
. /opt/ros/cturtle/setup.sh
roslaunch kinect_camera kinect_with_tf.launch

 
6.然後再建立一個基本設定檔讓表層SDK去load..這邊建立在/home/nathaniel/kinect/kinect.vcg檔裡
 
Background\ ColorR=0
Background\ ColorG=0
Background\ ColorB=0
Fixed\ Frame=/kinect_depth
Target\ Frame=
Camera.Alpha=0.5
Camera.Enabled=1
Camera.Image\ Topic=/kinect/rgb/image_raw
Camera.Transport\ Hint=raw
Camera2.Alpha=0.5
Camera2.Enabled=1
Camera2.Image\ Topic=/kinect/depth/image_raw
Camera2.Transport\ Hint=raw
Grid.Alpha=0.5
Grid.Cell\ Size=1
Grid.ColorR=0.5
Grid.ColorG=0.5
Grid.ColorB=0.5
Grid.Enabled=1
Grid.Line\ Style=0
Grid.Line\ Width=0.03
Grid.Normal\ Cell\ Count=0
Grid.OffsetX=0
Grid.OffsetY=0
Grid.OffsetZ=0
Grid.Plane=0
Grid.Plane\ Cell\ Count=50
Grid.Reference\ Frame=
Point\ Cloud2.Alpha=0.5
Point\ Cloud2.Billboard\ Size=0.001
Point\ Cloud2.Color\ Transformer=Flat Color
Point\ Cloud2.Decay\ Time=0
Point\ Cloud2.Enabled=1
Point\ Cloud2.Position\ Transformer=XYZ
Point\ Cloud2.Selectable=1
Point\ Cloud2.Style=2
Point\ Cloud2.Topic=/kinect/depth/points2
Point\ Cloud2..Flat\ ColorColorR=1
Point\ Cloud2..Flat\ ColorColorG=1
Point\ Cloud2..Flat\ ColorColorB=1
Point\ Cloud2..IntensityAutocompute\ Intensity\ Bounds=1
Point\ Cloud2..IntensityMax\ ColorR=1
Point\ Cloud2..IntensityMax\ ColorG=1
Point\ Cloud2..IntensityMax\ ColorB=1
Point\ Cloud2..IntensityMax\ Intensity=4096
Point\ Cloud2..IntensityMin\ ColorR=0
Point\ Cloud2..IntensityMin\ ColorG=0
Point\ Cloud2..IntensityMin\ ColorB=0
Point\ Cloud2..IntensityMin\ Intensity=0
Tool\ 2D\ Nav\ GoalTopic=move_base_simple/goal
Tool\ 2D\ Pose\ EstimateTopic=initialpose
Camera\ Type=rviz::OrbitViewController
Camera\ Config=2.88559 6.26704 6.20208 0.118644 2.18674 -0.179489
Property\ Grid\ State=selection=Camera2.Enabled.Camera2.Image Topic;expanded=.Global Options,Point Cloud2.Enabled,Camera.Enabled,Camera2.Enabled;scrollpos=0,0;splitterpos=330,660;ispageselected=1
[Display0]
Name=Grid
Package=rviz
ClassName=rviz::GridDisplay
[Display1]
Name=Point Cloud2
Package=rviz
ClassName=rviz::PointCloud2Display
[Display2]
Name=Camera
Package=rviz
ClassName=rviz::CameraDisplay
[Display3]
Name=Camera2
Package=rviz
ClassName=rviz::CameraDisplay

7.再開一個終端機,然後啟動表層SDK
. /opt/ros/cturtle/setup.sh
rosrun rviz rviz -d /home/nathaniel/kinect/kinect.vcg& 


8.接著你就能看到表層示範sdk的畫面~可以玩看看

 
 
thx for:

http://www.ros.org/wiki/cturtle/Installation/Ubuntu
http://www.ros.org/wiki/kinect/Tutorials/Getting%20Started

 
番外加映kmouse…是利用kinect捕捉人手的移動,跟關鍵報告一樣…
 
但我拖太久才打文章…已經忘記途中有個地方需要自己手動除錯
我花了一些時間再Openkinect安裝上…但是我真的忘了怎麽除錯成功的

所以有需要的人自己抓kmouse跟openkinect回來,裏面有readme自己加減看啦…基本上就是cmake跟make指令再那裡輪流
但會碰到有錯誤的地方,請自行解決=”=

https://github.com/OpenKinect/libfreenect/
https://github.com/Ooblik/Kinect-Mouse/
 
 

Leave a comment

這個網站採用 Akismet 服務減少垃圾留言。進一步瞭解 Akismet 如何處理網站訪客的留言資料