首先需要说明使用的硬件设备,电脑用的是Macbook,系统用的是使用虚拟机安装的Ubantu 12.04,使用的ROS版本是Hydro,配合使用的是华硕的Xtion。
在之前看到网上的教程中以及在技术交流群中遇到的朋友说的虚拟机是无法使用xtion或者是kinect的,所以一直就被困住了,就没有试过这个,我使用的MacOS里的虚拟机是Parallels,也许这个和windows下的设备VMware不一样,这个就不深究了,下面我只是介绍一下自己是怎么设置实现的。
还是根据大多教程一样,在Ubantu下面,首先安装Openni,使用的命令都可以搜到:
sudo apt-get install ros-hydro-openni-camera 因为我的版本是hydro,所以用的就是hydro,对应好自己的版本就可以了,别弄乱了,还有的教程中给出的命令是:
sudo apt-get install ros-hydro-openni-kinect 这个我试了,在hydro里面是不可用的,不知道在别的版本上是怎么个情况。
回车之后开始自动开始安装,
然后输入
sudo apt-get install ros-hydro-openni-launch // sudo apt-get install ros-hydro-openni2-launch //roslaunch openni2_launch openni2.launch
完事儿之后运行节点
roslaunch openni_launch openni.launch
出现以下结果
... logging to /home/pangshuxin/.ros/log/3515616c-e6bf-11e5-a79b-001c422b5bfa/roslaunch-ubuntu-8290.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.
started roslaunch server http://ubuntu:54131/
SUMMARY
========
PARAMETERS
* /camera/camera_nodelet_manager/num_worker_threads
* /camera/depth_rectify_depth/interpolation
* /camera/depth_registered_rectify_depth/interpolation
* /camera/disparity_depth/max_range
* /camera/disparity_depth/min_range
* /camera/disparity_registered_hw/max_range
* /camera/disparity_registered_hw/min_range
* /camera/disparity_registered_sw/max_range
* /camera/disparity_registered_sw/min_range
* /camera/driver/depth_camera_info_url
* /camera/driver/depth_frame_id
* /camera/driver/depth_registration
* /camera/driver/device_id
* /camera/driver/rgb_camera_info_url
* /camera/driver/rgb_frame_id
* /rosdistro
* /rosversion
NODES
/camera/
camera_nodelet_manager (nodelet/nodelet)
debayer (nodelet/nodelet)
depth_metric (nodelet/nodelet)
depth_metric_rect (nodelet/nodelet)
depth_points (nodelet/nodelet)
depth_rectify_depth (nodelet/nodelet)
depth_registered_rectify_depth (nodelet/nodelet)
disparity_depth (nodelet/nodelet)
disparity_registered_hw (nodelet/nodelet)
disparity_registered_sw (nodelet/nodelet)
driver (nodelet/nodelet)
points_xyzrgb_hw_registered (nodelet/nodelet)
points_xyzrgb_sw_registered (nodelet/nodelet)
rectify_color (nodelet/nodelet)
rectify_ir (nodelet/nodelet)
rectify_mono (nodelet/nodelet)
register_depth_rgb (nodelet/nodelet)
/
camera_base_link (tf/static_transform_publisher)
camera_base_link1 (tf/static_transform_publisher)
camera_base_link2 (tf/static_transform_publisher)
camera_base_link3 (tf/static_transform_publisher)
ROS_MASTER_URI=http://localhost:11311
core service [/rosout] found
process[camera/camera_nodelet_manager-1]: started with pid [8308]
[ INFO] [1457616693.625158152]: Initializing nodelet with 4 worker threads.
process[camera/driver-2]: started with pid [8329]
process[camera/debayer-3]: started with pid [8345]
process[camera/rectify_mono-4]: started with pid [8361]
process[camera/rectify_color-5]: started with pid [8377]
process[camera/rectify_ir-6]: started with pid [8391]
process[camera/depth_rectify_depth-7]: started with pid [8405]
process[camera/depth_metric_rect-8]: started with pid [8419]
process[camera/depth_metric-9]: started with pid [8435]
process[camera/depth_points-10]: started with pid [8451]
[ INFO] [1457616694.196408029]: Number devices connected: 1
[ INFO] [1457616694.202560322]: 1. device on bus 001:09 is a SensorV2 (600) from PrimeSense (1d27) with serial id '1205230172'
[ INFO] [1457616694.203682333]: Searching for device with index = 1
process[camera/register_depth_rgb-11]: started with pid [8475]
[ INFO] [1457616694.252928411]: Opened 'SensorV2' on bus 1:9 with serial number '1205230172'
process[camera/points_xyzrgb_sw_registered-12]: started with pid [8535]
process[camera/depth_registered_rectify_depth-13]: started with pid [8549]
process[camera/points_xyzrgb_hw_registered-14]: started with pid [8563]
process[camera/disparity_depth-15]: started with pid [8577]
process[camera/disparity_registered_sw-16]: started with pid [8599]
process[camera/disparity_registered_hw-17]: started with pid [8613]
process[camera_base_link-18]: started with pid [8632]
process[camera_base_link1-19]: started with pid [8653]
process[camera_base_link2-20]: started with pid [8664]
[ INFO] [1457616695.095545000]: rgb_frame_id = '/camera_rgb_optical_frame'
[ INFO] [1457616695.095986429]: depth_frame_id = '/camera_depth_optical_frame'
process[camera_base_link3-21]: started with pid [8696]
[ WARN] [1457616695.202083367]: Camera calibration file /home/pangshuxin/.ros/camera_info/rgb_1205230172.yaml not found.
[ WARN] [1457616695.202257009]: Using default parameters for RGB camera calibration.
[ WARN] [1457616695.202354355]: Camera calibration file /home/pangshuxin/.ros/camera_info/depth_1205230172.yaml not found.
[ WARN] [1457616695.202535829]: Using default parameters for IR camera calibration.
最后出现的warn倒没啥影响。
然后打开新的命令行窗口运行显示影像的命令:
rosrun image_view image_view image:=/camera/rgb/image_color
结果出现影像:
运行:rosrun image_view disparity_view image:=/camera/depth/disparity
出现深度影像