Posted by
tejaswi on
URL: http://official-rtab-map-forum.206.s1.nabble.com/rtabmap-for-kinect-v2-on-ROS-Indigo-tp61p64.html
Hi,
I got the Kinect2 to work with the ROS version of rtabmap. Here is what I did.
I installed the ROS version of rtabmap as specified in the
installation page.
I am using libfreenect2 and the
iai_kinect2 package to integrate the sensor with ROS (indigo).
The rtabmap node expects the topics
/camera/rgb/image_rect_color
/camera/depth_registered/image_raw
/camera/depth_registered/camera_info
as inputs. The equivalent topics published by the kinect2_bridge node of the kinect2_bridge package that is part of iai_kinect2 are the following.
/kinect2_head/rgb_rect/image
/kinect2_head/depth_highres/image
/kinect2_head/depth_highres/camera_info
So, I wrote a launch file for launching the kinect2_bridge node that would remap the iai_kinect2 topics to the required rtabmap topics as follows.
<launch>
<arg name="publish_frame" default="false" />
<include file="$(find kinect2_bridge)/launch/include/kinect2_frames.launch">
<arg name="publish_frame" value="$(arg publish_frame)" />
</include>
<node name="kinect2_bridge" pkg="kinect2_bridge" type="kinect2_bridge" respawn="true" output="screen">
<remap from="/kinect2_head/rgb_rect/image" to="/camera/rgb/image_rect_color"/>
<remap from="/kinect2_head/depth_highres/image" to="/camera/depth_registered/image_raw"/>
<remap from="/kinect2_head/depth_highres/camera_info" to="/camera/depth_registered/camera_info"/>
</node>
</launch>
The other thing that needs to be changed is the "frame_id" of the headers of the kinect2_bridge images.
Rtabmap expects the frame_id s of the input images to be
base_link, while the kinect2_bridge outputs them as
"head_mount_kinect2_rgb_optical_frame".
For lack of a simpler (lazier) way to implement this modification, I just changed the entry for
K2_TF_RGB_FRAME in
kinect2_definitions.h file in the kinect2_bridge folder.
Now you can run
$ roscore
$ roslaunch kinect2_bridge <my_new_launch>.launch
$ roslaunch rtabmap rgbd_mapping.launch
or
$ roslaunch rtabmap rgbd_mapping_rviz.launch
and everything should work.
Thanks again for pointing me in the right direction.