(u_u)

ROS melodic:Kinect v2

Categories: [blog]
Tags: [ubuntu], [ubuntu18.04], [ros], [melodic], [image_view], [kinect v2], [kinect2_bridge]

基本的にはcode-iai/iai_kinect2: Tools for using the Kinect One (Kinect v2) in ROSの通りに設定すればOK。
ただ

[ERROR] [1558596062.383852321]: [DepthRegistrationOpenCL::init] [depth_registration_opencl.cpp](216) data->program.build(options.c_str()) failed: -11
[ERROR] [1558596062.383911249]: [DepthRegistrationOpenCL::init] failed to build program: -11
[ERROR] [1558596062.383937888]: [DepthRegistrationOpenCL::init] Build Status: -2
[ERROR] [1558596062.383976323]: [DepthRegistrationOpenCL::init] Build Options:  
[ERROR] [1558596062.384120111]: [DepthRegistrationOpenCL::init] Build Log:   stringInput.cl:190:31: error: call to 'sqrt' is ambiguous
/usr/lib/x86_64-linux-gnu/beignet/include/ocl_math.h:85:20: note: candidate function

というエラーが出てて実行できなかったので、Viewing Kinect v2 Point Clouds with ROS in Arch Linux – Lubosz's Blogにあるように、

$ rosrun kinect2_bridge kinect2_bridge _reg_method:=cpu

もしくは

$ roslaunch kinect2_bridge kinect2_bridge.launch reg_method:=cpu

とすると実行できた。
rostopicはこんな感じ。

takuya@takuya-ThinkPad-X240:~$ rostopic list
/kinect2/bond
/kinect2/hd/camera_info
/kinect2/hd/image_color
/kinect2/hd/image_color/compressed
/kinect2/hd/image_color_rect
/kinect2/hd/image_color_rect/compressed
/kinect2/hd/image_depth_rect
/kinect2/hd/image_depth_rect/compressed
/kinect2/hd/image_mono
/kinect2/hd/image_mono/compressed
/kinect2/hd/image_mono_rect
/kinect2/hd/image_mono_rect/compressed
/kinect2/hd/points
/kinect2/qhd/camera_info
/kinect2/qhd/image_color
/kinect2/qhd/image_color/compressed
/kinect2/qhd/image_color_rect
/kinect2/qhd/image_color_rect/compressed
/kinect2/qhd/image_depth_rect
/kinect2/qhd/image_depth_rect/compressed
/kinect2/qhd/image_mono
/kinect2/qhd/image_mono/compressed
/kinect2/qhd/image_mono_rect
/kinect2/qhd/image_mono_rect/compressed
/kinect2/qhd/points
/kinect2/sd/camera_info
/kinect2/sd/image_color_rect
/kinect2/sd/image_color_rect/compressed
/kinect2/sd/image_depth
/kinect2/sd/image_depth/compressed
/kinect2/sd/image_depth_rect
/kinect2/sd/image_depth_rect/compressed
/kinect2/sd/image_ir
/kinect2/sd/image_ir/compressed
/kinect2/sd/image_ir_rect
/kinect2/sd/image_ir_rect/compressed
/kinect2/sd/points
/rosout
/rosout_agg

この中から、例えばdepthの画像を取りたいときは、

$ rosrun image_view image_view image:=/kinect2/sd/image_depth

とすると見れる。