Kinect2 Setup Guide

Welcome to the Setup Guide for Kinect2.

System

The following instructions has been tested on Ubuntu 14.04 with ros indigo and Ubuntu 18.04 with ros melodic

Install libfreenect2 on Ubuntu 18

Install necessary libs clone the libfreenect2 to your home folder (at least not the ros folder, as this is not a ros project)

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

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

sudo apt-get install libusb-1.0-0-dev

sudo apt-get install libturbojpeg0-dev

sudo apt-get update
sudo apt-get install libglfw3-dev

sudo apt-get install beignet-dev # (find the appropriate one)

Then install the python freenect2 lib

add the following line export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/freenect2/lib/pkgconfig and export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/freenect2/lib to ~/.bashrc.

Build:

mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/freenect2 -Dfreenect2_DIR=$HOME/freenect2/lib/cmake/freenect2
make
make install

Setup and test:

sudo cp ../platform/linux/udev/90-kinect2.rules /etc/udev/rules.d/
./bin/Protonect

If it runs successfully, You will see the demo. You may need to replug kinect.

Install libfreenect2 on Ubuntu 14

Install necessary libs clone the libfreenect2 to your home folder (at least not the ros folder, as this is not a ros project)

git clone https://github.com/OpenKinect/libfreenect2.git
cd libfreenect2
cd depends; ./download_debs_trusty.sh
cd ..
sudo apt-get install build-essential cmake pkg-config
sudo dpkg -i debs/libusb*deb
sudo apt-get install libturbojpeg libjpeg-turbo8-dev
sudo dpkg -i debs/libglfw3*deb; sudo apt-get install -f
sudo apt-add-repository ppa:floe/beignet; sudo apt-get update; sudo apt-get install beignet-dev; sudo dpkg -i debs/ocl-icd*deb #(find the appropriate one)

Then install the python freenect2 lib

add the following line export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/freenect2/lib/pkgconfig and export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/freenect2/lib to ~/.bashrc.

Build:

mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/freenect2 -Dfreenect2_DIR=$HOME/freenect2/lib/cmake/freenect2
make
make install

Setup and test:

sudo cp ../platform/linux/udev/90-kinect2.rules /etc/udev/rules.d/
./bin/Protonect

If it runs successfully, You will see the demo. You may need to replug kinect.

Install iai-kinect2

clone the repo to your ros workspace

git clone https://github.com/code-iai/iai_kinect2.git
cd iai_kinect2
rosdep install -r --from-paths .
cd ../..
catkin build iai_kinect2 -DCMAKE_BUILD_TYPE="Release"

It is totally ok to see the following error messages and you can safely ignore them:

ERROR: the following packages/stacks could not have their rosdep keys resolved
to system dependencies:
kinect2_viewer: Cannot locate rosdep definition for [cv_bridge]
kinect2_registration: Cannot locate rosdep definition for [cv_bridge]
iai_kinect2: Cannot locate rosdep definition for [kinect2_registration]
kinect2_calibration: Cannot locate rosdep definition for [cv_bridge]
kinect2_bridge: Cannot locate rosdep definition for [cv_bridge]

Test

roslaunch kinect2_bridge kinect2_bridge.launch

If you see the error message [ERROR] [DepthRegistrationOpenCL::init] Build Log: stringInput.cl:190:31: error: call to 'sqrt' is ambiguous. To fix this, in kinect2_bridge.launch, update depth_method to opengl(Or the one works for you), and reg_method to cpu (reference: https://lubosz.wordpress.com/2016/03/29/viewing-kinect-v2-point-clouds-with-ros-in-arch-linux/)

To view the results

rosrun kinect2_viewer kinect2_viewer kinect2 sd cloud

Kinect Calibration

Following the instructions from: https://github.com/code-iai/iai_kinect2/tree/master/kinect2_calibration

To save a frame, make sure your focus is on the image (i.e., click on the image) and press the keys.

You can safely ignore the errors like:

[ERROR] Tried to advertise a service that is already advertised in this node [/kinect2_calib_1593699935406844953/compressed/set_parameters]
[ERROR] Tried to advertise a service that is already advertised in this node [/kinect2_calib_1593699935406844953/compressed/set_parameters]

Useful commands:

roslaunch kinect2_bridge kinect2_bridge.launch fps_limit:=2

rosrun kinect2_calibration kinect2_calibration chess5x7x0.03 record color

rosrun kinect2_calibration kinect2_calibration chess5x7x0.03 calibrate color

rosrun kinect2_calibration kinect2_calibration chess5x7x0.03 record ir

rosrun kinect2_calibration kinect2_calibration chess5x7x0.03 calibrate ir

rosrun kinect2_calibration kinect2_calibration chess5x7x0.03 record sync

rosrun kinect2_calibration kinect2_calibration chess5x7x0.03 calibrate sync

rosrun kinect2_calibration kinect2_calibration chess5x7x0.03 calibrate depth

References

https://github.com/code-iai/iai_kinect2 https://github.com/OpenKinect/libfreenect2/blob/master/README.md#linux

Collaboration

  • Please edit this file to add things you think are going to be useful. You can edit it by modifying this file

Dissertation Guide

Guide for the dissertation process and paperwork needed Continue reading

Hello Stretch Setup Guide

Published on January 22, 2021

Azure Kinect Setup and Startup Guide

Published on August 31, 2020