ubuntu16.04 kinect v2 ros kinetic配置踩坑 (详细笔记)

最近由于学习需要,开始对kinect v2进行配置。
一开始照着ros高效编程一书以及在ros wiki 上的搜索进行配置。
虽然关注到相关页面上的介绍可能时间有点久远了,但也未过多联想。

http://wiki.ros.org/openni_camera

sudo apt-get install ros-kinetic-openni-camera ros-kinect-openni-launch
rosstack profile && rospack profile

同时注意到:
To use the Microsoft Kinect you also need a driver:
PPA: https://launchpad.net/~yani/+archive/ubuntu/iatsl
Source: https://github.com/avin2/SensorKinect
还需要安装驱动,
之后去github上详细参照readme安装驱动,安装完成后启动

readme相关内容:
Linux:
Requirements:
1) GCC 4.x
From: http://gcc.gnu.org/releases.html
Or via apt:
sudo apt-get install g++
2) Python 2.6+/3.x
From: http://www.python.org/download/
Or via apt:
sudo apt-get install python
3) OpenNI 1.5.x.x
From: http://www.openni.org/Downloads/OpenNIModules.aspx
Building Sensor:
1) Go into the directory: “Platform/Linux/CreateRedist”.
Run the script: “./RedistMaker”.
This will compile everything and create a redist package in the “Platform/Linux/Redist” directory.
It will also create a distribution in the “Platform/Linux/CreateRedist/Final” directory.
2) Go into the directory: “Platform/Linux/Redist”.
Run the script: “sudo ./install.sh” (needs to run as root)
The install script copies key files to the following location:
Libs into: /usr/lib
Bins into: /usr/bin
Config files into: /usr/etc/primesense
USB rules into: /etc/udev/rules.d
Logs will be created in: /var/log/primesense
To build the package manually, you can run “make” in the “Platform\Linux\Build” directory.
Important: Please note that even though the directory is called Linux, you can also use it to compile it for 64-bit targets and pretty much any other linux based environment.

roscore
rosrun openni_camera openni_node
roslaunch openni_launch openni.launch

都报错,一直显示类似于无设备连接。
openni camera kinect no device connected

之后又去不断搜索,联想到驱动以及包都有问题,上述资料讲的大概率是kinect一代的配置,Kinect v2需要另外的配置,重新开始下载驱动以及包

驱动下载

git clone https://github.com/OpenKinect/libfreenect2.git
cd libfreenect2
sudo apt-get install build-essential cmake pkg-config libusb-1.0-0-dev libturbojpeg libjpeg-turbo8-dev libglfw3-dev libopenni2-dev beignet-dev
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/freenect2
make
make install

设定udev rules:
sudo cp ../platform/linux/udev/90-kinect2.rules /etc/udev/rules.d/

./bin/Protonect


You need to specify cmake -Dfreenect2_DIR=$HOME/freenect2/lib/cmake/freenect2 for CMake based third-party application to find libfreenect2.
Set up udev rules for device access: sudo cp ../platform/linux/udev/90-kinect2.rules /etc/udev/rules.d/, then replug the Kinect.
Run the test program: ./bin/Protonect
Run OpenNI2 test (optional): sudo apt-get install openni2-utils && sudo make install-openni2 && NiViewer2. Environment variable LIBFREENECT2_PIPELINE can be set to cl, cuda, etc to specify the pipeline.

相关可选内容:

Install OpenCL (optional) 
Intel GPU

    (Ubuntu 14.04 only) sudo apt-add-repository ppa:floe/beignet; sudo apt-get update; sudo apt-get install beignet-dev; sudo dpkg -i debs/ocl-icd*deb
    (Other) sudo apt-get install beignet-dev
    For older kernels, # echo 0 >/sys/module/i915/parameters/enable_cmd_parser is needed. See more known issues at https://www.freedesktop.org/wiki/Software/Beignet/.
Verify: You can install clinfo to verify if you have correctly set up the OpenCL stack


Install CUDA (optional, Nvidia only): 
    (Ubuntu 14.04 only) Download cuda-repo-ubuntu1404...*.deb ("deb (network)") from Nvidia website, follow their installation instructions, including apt-get install cuda which installs Nvidia graphics driver.
    (Jetson TK1) It is preloaded.
    (Nvidia/Intel dual GPUs) After apt-get install cuda, use sudo prime-select intel to use Intel GPU for desktop.
    (Other) Follow Nvidia website's instructions. You must install the samples package.


Install VAAPI (optional, Intel only) 
 Ubuntu 14.04 only) sudo dpkg -i debs/{libva,i965}*deb; sudo apt-get install -f
(Other) sudo apt-get install libva-dev libjpeg-dev
Linux kernels 4.1 to 4.3 have performance regression. Use 4.0 and earlier or 4.4 and later (Though Ubuntu kernel 4.2.0-28.33~14.04.1 has backported the fix).

Install OpenNI2 (optional)

    (Ubuntu 14.04 only) sudo apt-add-repository ppa:deb-rob/ros-trusty && sudo apt-get update (You don't need this if you have ROS repos), then sudo apt-get install libopenni2-dev
    (Other) sudo apt-get install libopenni2-dev

Follow the instructions and enable C++11 by using cmake … -DENABLE_CXX11=ON instead of cmake … If you are compiling libfreenect2 with CUDA, use cmake … -DENABLE_CXX11=ON -DCUDA_PROPAGATE_HOST_FLAGS=off.
针对于上述命令中最后一行指令, 需要说明的是, 如果前面libfreenect2你安装的位置不是标准的两个路径下, 需要提供参数指定libfreenect2所在路径:
catkin_make -Dfreenect2_DIR=path_to_freenect2/lib/cmake/freenect2 -DCMAKE_BUILD_TYPE=“Release”

usb3.0问题:
上述包提到了需要满足要求:
USB 3.0 controller. USB 2 is not supported.
Intel and NEC USB 3.0 host controllers are known to work. ASMedia controllers are known to not work.

Virtual machines likely do not work, because USB 3.0 isochronous transfer is quite delicate.

网上据别人科普:usb3.0 端口为蓝色 usb2.0端口为黑色
我插的笔记本口为黑色,但标有ss,插上设备后可以看到是识别了3个微软接口,同时可以通过 lsusb -t 查看各类设备

~/catkin_ws/src$ lsusb
Bus 002 Device 001:  Linux Foundation 3.0 root hub
Bus 001 Device 004: Chicony Electronics Co., Ltd 
Bus 001 Device 006: Logitech, Inc. 
Bus 001 Device 005:  Atheros Communications, Inc. 
Bus 001 Device 001:  Linux Foundation 2.0 root hub
~/catkin_ws/src$ lsusb
Bus 002 Device 005:  Microsoft Corp. 
Bus 002 Device 004:  Microsoft Corp. 
Bus 002 Device 001: Linux Foundation 3.0 root hub
Bus 001 Device 004:  Chicony Electronics Co., Ltd 
Bus 001 Device 006:  Logitech, Inc. 
Bus 001 Device 005: Atheros Communications, Inc. 
Bus 001 Device 007: Microsoft Corp. 
Bus 001 Device 001: Linux Foundation 2.0 root hub

这里打开Protonect可以看到4个显示界面,说明成功了。

下载相关功能包

相关功能包连接了ros与kinect
连接:

https://github.com/code-iai/iai_kinect2

步骤:

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

中间出错:

  • +++ processing catkin package: ‘kinect2_bridge’
    – ==> add_subdirectory(iai_kinect2/kinect2_bridge)
    CMake Error at iai_kinect2/kinect2_bridge/CMakeLists.txt:22 (find_package):
    Could not find a package configuration file provided by “freenect2” with
    any of the following names:

    freenect2Config.cmake
    freenect2-config.cmake

    Add the installation prefix of “freenect2” to CMAKE_PREFIX_PATH or set
    “freenect2_DIR” to a directory containing one of the above files. If
    “freenect2” provides a separate development package or SDK, be sure it has
    been installed.
    解决方案  
    在src目录下下载freenect2包,再次执行
    catkin_make -DCMAKE_BUILD_TYPE=“Release”
    结果:
    [ 93%] Built target kinect2_calibration
    [ 93%] Built target kinect2_bridge_nodelet
    [ 93%] Built target kinect2_bridge
    [100%] Linking CXX executable /home/bigfacecat/catkin_ws/devel/lib/kinect2_viewer/kinect2_viewer
    [100%] Built target kinect2_viewer
    成功!!!!!!

这里执行 roslaunch kinect2_bridge kinect2_bridge.launch
报错:

 Failed to load nodelet '/kinect2_bridge` of type `kinect2_bridge/kinect2_bridge_nodelet` to manager `kinect2' [kinect2_bridge-2] process has died

其实是相关配置没做好,针对cpu以及gpu的配置,可以设定硬件,比如在launch文件中修改相关参数,或者

roscore
rosrun kinect2_bridge kinect2_bridge _depth_method:=cpu _reg_method:=cpu
rosrun kinect2_viewer kinect2_viewer
rosrun rqt_image_view rqt_image_view

如果要在 rviz 中查看PointCloud2(注意修改Fixed Frame),则运行如下命令:
roslaunch kinect2_bridge kinect2_bridge.launch publish_tf:=true

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值