Playing Kinect 2 with ROS in Ubuntu 16.04: Hello World

来源:互联网 发布:linux 查看时钟同步 编辑:程序博客网 时间:2024/04/24 20:38

OS: Ubuntu 16.04.02 x64
ROS: Kinetic
Device: Kinect 2
OpenCV: 2.4.13.3
USB 3.0 Controller is essential

Now we begin to talk about how to play kinect2 with ROS. Note that OpenCV 2.4.X is essential and OpenCV 3 will not work. You can check the verison of your OpenCV by type in:

pkg-config --modversion opencv 

Install libfreenect2

There are some ways to drive kinect 2 in linux. Here we only talk about libfreenect2, which is very convenient. You can follow this instruction to install it if you want more details. However, if you would like to play with kinect 2 as soon as possible, just go ahead.

Download libfreenect2:

git clone https://github.com/OpenKinect/libfreenect2.gitcd libfreenect2

Install build tools:

sudo apt-get install build-essential cmake pkg-config

Install libusb: (version >= 1.0.20), TurboJPEG and OpenGL

sudo apt-get install libusb-1.0-0-devsudo apt-get install libturbojpeg libjpeg-turbo8-devsudo apt-get install libglfw3-dev

Build

mkdir build && cd buildcmake .. -DENABLE_CXX11=ON -DCMAKE_INSTALL_PREFIX=$HOME/freenect2makemake install

A Test

Run a program: (Never forget to plug your Kinect 2)

./bin/Protonect

Then you will see the following window if nothing goes wrong.
Protonect

Install IAI Kinect2

Now go to your catkin workspace. Let’s try to get the iai_kinect2 package and make it.
Follow this instruction if you want more details.

cd $YOUR_CATKIN_WORKSPACE_PATH/srcgit clone https://github.com/code-iai/iai_kinect2.gitcd iai_kinect2rosdep install -r --from-paths .

rosdep will output errors on not being able to locate [kinect2_bridge] and [depth_registration]. Never mind, that is fine because they are all part of the iai_kinect2 package and rosdep does not know these packages.

cd ~/YOUR_CATKIN_WORKSPACE_PATHcatkin_make -DCMAKE_BUILD_TYPE="Release"

Run kinect2_bridge :

roslaunch kinect2_bridge kinect2_bridge.launch

Then you can see that some nodes are running:

/kinect2/kinect2_bridge/kinect2_points_xyzrgb_hd/kinect2_points_xyzrgb_qhd/kinect2_points_xyzrgb_sd/rosout

Go Ahead

Now you can use your kinect 2 in your ROS system to do some robotics research. Here are some references you may need:

  1. Calibrate your sensor using the kinect2_calibration.
  2. Add the calibration files to the kinect2_bridge/data.
  3. Restart kinect2_bridge and view the results using rosrun kinect2_viewer kinect2_viewer kinect2 sd cloud.
原创粉丝点击