Install kinect2 drivers[1]
Assume have installed drivers successfully
Note: A new workspace[2] is needed for building with type "Release"
mkdir -p ~/kinect_ws/src
git clone https://github.com/code-iai/iai_kinect2.git
cd iai_kinect2
rosdep install -r --from-paths .
cd ~/kinect2_ws
catkin_make -DCMAKE_BUILD_TYPE="Release"
source ~/kinect2_ws/devel/setup.bash
Launch[3]
Launch kinect2
roslaunch kinect2_bridge kinect2_bridge.launch publish_tf:=true
Launch rtabmap_ros
rosrun tf static_transform_publisher 0 0 0 -1.5707963267948966 0 -1.5707963267948966 camera_link kinect2_link 100
roslaunch rtabmap_ros rtabmap.launch rtabmap_args:="--delete_db_on_start" rgb_topic:=/kinect2/qhd/image_color_rect depth_topic:=/kinect2/qhd/image_depth_rect camera_info_topic:=/kinect2/qhd/camera_info approx_sync:=false
or
roslaunch rtabmap_ros rgbd_mapping_kinect2.launch resolution:=qhd
rosbag record
rosbag record -O kinect_test /tf /kinect2/qhd/image_color_rect /kinect2/qhd/image_depth_rect /kinect2/qhd/camera_info
What matters to me but it might not be helpful to you
At first I am trying to build multiple packages in the catkin_ws
It seems redundant to create another ros workspace, but there are so many packages in catkin_ws, and -DCATKIN_WHITELIST_PACKAGES=[PACKAGE_NAME]
did not work in this situation for iai_kinect2
including several packages either.
Add source ~/kinect2_ws/devel/setup.bash
to ~/.bashrc
didnot work
Perhaps this line cannot be placed before one line source ~/test_ws/devel/setup.bash
.
In the end, it solved by putting the line source ~/kinect2_ws/devel/setup.bash
after source ~/test_ws/devel/setup.bash
.
I guess maybe the source order should be arranged by the time of the packages creating? I don't know.
References:
[1] Ubuntu16.04 安装Kinect2驱动 - CSDN博客
[2] ROS/Tutorials/CreatingPackage - ROS Wiki
[3] rtabmap_ros/Tutorials/HandHeldMapping - ROS Wiki