红联Linux门户
Linux帮助

两台kinect同时运行

发布时间:2017-02-26 09:58:21来源:linux网站作者:米姒翰
ubuntu14.04,indigo,kinect xbox,联想笔记本
运行环境:kinect V1,ubuntu14.04,ROS indigo,台式机(具备2个以上USB BUS,不是PORT)
 
lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 04f2:b541 Chicony Electronics Co., Ltd
Bus 001 Device 003: ID 8087:0a2a Intel Corp.
Bus 001 Device 010: ID 045e:02ae Microsoft Corp. Xbox NUI Camera
Bus 001 Device 008: ID 045e:02b0 Microsoft Corp. Xbox NUI Motor
Bus 001 Device 009: ID 045e:02ad Microsoft Corp. Xbox NUI Audio
Bus 001 Device 007: ID 0409:005a NEC Corp. HighSpeed Hub
Bus 001 Device 002: ID 17ef:6050 Lenovo
Bus 001 Device 014: ID 045e:02ae Microsoft Corp. Xbox NUI Camera
Bus 001 Device 012: ID 045e:02b0 Microsoft Corp. Xbox NUI Motor
Bus 001 Device 013: ID 045e:02ad Microsoft Corp. Xbox NUI Audio
Bus 001 Device 011: ID 0409:005a NEC Corp. HighSpeed Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
 
locate freenect.launch 得到文件位置,因为我的电脑用openni.launch检测不到kinect,未解决。
/opt/ros/indigo/share/freenect_launch/launch/freenect.launch
cd /opt/ros/indigo/share/freenect_launch/launch/
 
首先,需要自己写一个launch文件,doublekinect_test.launch(文件名自定):
sudo gedit doublekinect_test.launch
 
文件内容如下:
<launch>
<!-- Parameters possible to change-->
<arg name="camera1_id" default="#1" /><!--here you can change 1@0 by the serial number -->
<arg name="camera2_id" default="#2" /><!--here you can change 2@0 by the  number -->
<!--arg name="camera1_id" default="B00366600710131B" /--><!--here you can change 1@0 by the serial number -->
<!--arg name="camera2_id" default="B00364210621048B" /--><!--here you can change 2@0 by the serial number -->
<!--arg name="camera3_id" default="#3" /--><!--here you can change 3@0 by the serial number -->
<arg name="depth_registration" default="true"/>
<!-- Default parameters-->
<arg name="camera1_name" default="kinect1" />
<arg name="camera2_name" default="kinect2" />
<!--arg name="camera3_name" default="kinect3" /-->
<!-- Putting the time back to realtime-->
<rosparam>
/use_sim_time : false
</rosparam>
<!-- Launching first kinect-->
<include file="$(find freenect_launch)/launch/freenect.launch">
<arg name="device_id" value="$(arg camera1_id)"/>
<arg name="camera" value="$(arg camera1_name)"/>
<arg name="depth_registration" value="$(arg depth_registration)" />
<node name="rviz" pkg="rviz" type="rviz"/>
</include>
<!-- Launching second kinect-->
<include file="$(find freenect_launch)/launch/freenect.launch">
<arg name="device_id" value="$(arg camera2_id)"/>
<arg name="camera" value="$(arg camera2_name)"/>
<arg name="depth_registration" value="$(arg depth_registration)" />
<node name="rviz" pkg="rviz" type="rviz"/>
</include>
<!-- Launching third kinect-->
<!--include file="$(find openni_launch)/launch/openni.launch"-->
<!--arg name="device_id" value="$(arg camera3_id)"/-->
<!--arg name="camera" value="$(arg camera3_name)"/-->
<!--arg name="depth_registration" value="$(arg depth_registration)" /-->
<!--/include-->
</launch>
 
保存。
只要电脑配置有多个USB BUS,就可以接3个甚至更多个kinect。
 
打开终端,运行:
roslaunch freenect_launch doublekinect_test.launch
再打开一个终端,运行:
rosrun image_view image_view image:=/kinect1/rgb/image_color
rosrun image_view disparity_view image:=/kinect_1/depth/disparity 会出现第一台kinect的深度图
再打开一个终端,运行:
rosrun image_view image_view image:=/kinect2/rgb/image_color
 
本文永久更新地址:http://www.linuxdiyf.com/linux/28711.html