Ubuntu16 ros下安装Kinect2驱动问题汇总

Ubuntu 16.04

CUDA 8.0

Opencv 2.4.13

(看到某位兄台说只能用Opencv 2.4.9,结果死活装不上去,还花了好多下载积分替换神马文件,毛用没有,就换用2.4.13,解决了,貌似是和CUDA不兼容)

一、安装libfreenect2 

安装教程 https://github.com/OpenKinect/libfreenect2 

1.下载包

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

2.

cd depends; ./download_debs_trusty.sh

 3.安装库

sudo apt-get install build-essential cmake pkg-config
sudo apt-get install libusb-1.0-0-dev
sudo apt-get install libturbojpeg libjpeg-turbo8-dev
sudo apt-get install libglfw3-dev
sudo apt-get install beignet-dev
apt-get install opencl-headers
apt-get install cuda
sudo apt-get install libopenni2-dev

4.build

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

修改CMakeLists.txt  41行,

OPTION(ENABLE_VAAPI "Enable VA-API support" ON )        改为

OPTION(ENABLE_VAAPI "Enable VA-API support" OFF)

问题: 

/home/ray/libfreenect2/src/cuda_kde_depth_packet_processor.cu:39:25: fatal error: helper_math.h: 没有那个文件或目录
compilation terminated.
CMake Error at cuda_compile_generated_cuda_kde_depth_packet_processor.cu.o.cmake:207 (message):
  Error generating
  /home/ray/libfreenect2/build/CMakeFiles/cuda_compile.dir/src/./cuda_compile_generated_cuda_kde_depth_packet_processor.cu.o


CMakeFiles/freenect2.dir/build.make:82: recipe for target 'CMakeFiles/cuda_compile.dir/src/cuda_compile_generated_cuda_kde_depth_packet_processor.cu.o' failed
make[2]: *** [CMakeFiles/cuda_compile.dir/src/cuda_compile_generated_cuda_kde_depth_packet_processor.cu.o] Error 1
CMakeFiles/Makefile2:136: recipe for target 'CMakeFiles/freenect2.dir/all' failed
make[1]: *** [CMakeFiles/freenect2.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

问题原因:helper_math.h should be in the CUDA samples directory. /Developer/NVIDIA/CUDA-8.0/samples/common/inc/helper_math.h on OSX. Install the samples or try to build without CUDA.

解决方式:

(1)安装CUDA samples

(2)$ cmake-gui 

Ubuntu16 ros下安装Kinect2驱动问题汇总_第1张图片

将默认ENABLE_CUDA 右边的勾去掉,点击Configure、 Generate,关掉窗口,重新cmake

二、安装opencv2.4.13

打开文件夹"opencv-2.4.13":
cd opencv-2.4.13
新建一个文件夹用于存放临时文件:
mkdir release
切换到该临时文件夹:
cd release
开始编译:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
make -j4    //开启线程 按照自己的配置
sudo make install

问题: 

[..]/modules/contrib/src/rgbdodometry.cpp:65:47: fatal error: 
           unsupported/Eigen/MatrixFunctions: No such file or directory

解决方式:

找到 unsupported/Eigen/MatrixFunctions的路径,我的是 /usr/include/eigen3/ 里面

然后在 modules/contrib/src/rgbdodometry.cpp 文件的第65行的include里添加 "eigen3/" 。

问题:

/usr/bin/ld: 找不到 -lopencv_dep_cudart 

解决方式:

1 在cmake的时候:~/你的路径/$ cmake -DCUDA_USE_STATIC_CUDA_RUNTIME=OFF

2 在CMakeList.txt中:在find_package(OpenCV REQUIRED)之前添加 set(CUDA_USE_STATIC_CUDA_RUNTIME OFF)

 

三、安装iai_kinect2

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

 启动

终端1

roscore

终端2

rosrun kinect2_bridge kinect2_bridge _depth_method:=cpu _reg_method:=cpu

或者

rosrun kinect2_bridge kinect2_bridge _depth_method:=opencl _reg_method:=opencl

 

终端3

rosrun kinect2_viewer kinect2_viewer

Ubuntu16 ros下安装Kinect2驱动问题汇总_第2张图片

中间还遇到很多问题,没来得及记,终于弄出来了,以后遇到再说吧。 

你可能感兴趣的:(Linux,ROS)