2018.03.08 leaning journal

呼~~~~~~~~~~~~~昨天刚结束开题答辩,今天开始干活啦。
从淘宝DIY的kinect v2相机的电源到了,今天配置下kinect v2在ubuntu下的驱动。

1. KinectV2驱动安装

本机环境:ubuntu14.04
kinectV2 for ubuntu14.04+ROS安装
CSDN博客 KinectV2安装
github–libfreenect2安装
Ubuntu_ROS中应用kinect v2笔记

cd mumu/KinectV2/
proxychains git clone https://github.com/OpenKinect/libfreenect2.git
cd libfreenect2/
 cd depends/
 ./download_debs_trusty.sh  
 sudo apt-get install build-essential cmake pkg-config
sudo apt-add-repository ppa:floe/libusb
sudo apt-get update
sudo apt-get install libusb-1.0-0-dev
sudo apt-get install libturbojpeg libjpeg-turbo8-dev

//Install OpenGL
//注意此时处于depends文件夹下
sudo dpkg -i debs/libglfw3*deb
 sudo apt-get install -f

//Setting->Software & Updates->Additional Drivers选择NVIDIA 最新version384(此时本机上显示的是384)的驱动
//重启
sudo proxychains apt-get install opencl-headers
//https://launchpad.net/ubuntu/xenial/amd64/ocl-icd-dev/2.2.8-1
//下载得到ocl-icd-dev_2.2.8-1_amd64.deb直接安装 
//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

//Install OpenNI2 (optional) 
sudo apt-get install openni2-utils

其实/libfreenect2/depends/debs/文件夹里面有ocl-icd*deb等的下载安装包

//Install VAAPI (optional, Intel only) (Ubuntu 14.04 only) 
//此部分需要在depends文件夹下
sudo dpkg -i debs/{libva,i965}*deb
//此步骤失败,失败见下面的代码,缺少Package libset-scalar-perl is not installed.
//安装依赖项就好了
sudo proxychains apt-get install libset-scalar-perl
sudo dpkg -i debs/{libva,i965}*deb
sudo apt-get install -f
relaybot@ubuntu:~$ cd mumu/KinectV2/libfreenect2/depends/
relaybot@ubuntu:~/mumu/KinectV2/libfreenect2/depends$ sudo dpkg -i debs/{libva,i965}*deb
(Reading database ... 398400 files and directories currently installed.)
Preparing to unpack debs/libva1_1.7.0-1_amd64.deb ...
Unpacking libva1:amd64 (1.7.0-1) over (1.3.0-2) ...
Selecting previously unselected package libva-dev:amd64.
Preparing to unpack .../libva-dev_1.7.0-1_amd64.deb ...
Unpacking libva-dev:amd64 (1.7.0-1) ...
Selecting previously unselected package libva-drm1:amd64.
Preparing to unpack .../libva-drm1_1.7.0-1_amd64.deb ...
Unpacking libva-drm1:amd64 (1.7.0-1) ...
Selecting previously unselected package libva-egl1:amd64.
Preparing to unpack .../libva-egl1_1.7.0-1_amd64.deb ...
Unpacking libva-egl1:amd64 (1.7.0-1) ...
Selecting previously unselected package libva-glx1:amd64.
Preparing to unpack .../libva-glx1_1.7.0-1_amd64.deb ...
Unpacking libva-glx1:amd64 (1.7.0-1) ...
Selecting previously unselected package libva-tpi1:amd64.
Preparing to unpack .../libva-tpi1_1.7.0-1_amd64.deb ...
Unpacking libva-tpi1:amd64 (1.7.0-1) ...
Selecting previously unselected package libva-wayland1:amd64.
Preparing to unpack .../libva-wayland1_1.7.0-1_amd64.deb ...
Unpacking libva-wayland1:amd64 (1.7.0-1) ...
Preparing to unpack .../libva-x11-1_1.7.0-1_amd64.deb ...
Unpacking libva-x11-1:amd64 (1.7.0-1) over (1.3.0-2) ...
Selecting previously unselected package i965-va-driver:amd64.
Preparing to unpack .../i965-va-driver_1.7.0-1_amd64.deb ...
Unpacking i965-va-driver:amd64 (1.7.0-1) ...
Setting up libva1:amd64 (1.7.0-1) ...
dpkg: dependency problems prevent configuration of libva-dev:amd64:
 libva-dev:amd64 depends on libset-scalar-perl; however:
  Package libset-scalar-perl is not installed.

dpkg: error processing package libva-dev:amd64 (--install):
 dependency problems - leaving unconfigured
Setting up libva-drm1:amd64 (1.7.0-1) ...
Setting up libva-egl1:amd64 (1.7.0-1) ...
Setting up libva-tpi1:amd64 (1.7.0-1) ...
Setting up libva-wayland1:amd64 (1.7.0-1) ...
Setting up libva-x11-1:amd64 (1.7.0-1) ...
Setting up i965-va-driver:amd64 (1.7.0-1) ...
Setting up libva-glx1:amd64 (1.7.0-1) ...
Processing triggers for libc-bin (2.19-0ubuntu6.13) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Errors were encountered while processing:
 libva-dev:amd64
relaybot@ubuntu:~/mumu/KinectV2/libfreenect2/depends$
relaybot@ubuntu:~/mumu/KinectV2/libfreenect2/build$ cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/freenect2 -Dfreenect2_DIR=$HOME/freenect2/lib/cmake/freenect2
-- using tinythread as threading library
-- Could NOT find TegraJPEG (missing:  TegraJPEG_LIBRARIES TegraJPEG_INCLUDE_DIRS TegraJPEG_L4T_OK TegraJPEG_DRIVER_OK TegraJPEG_WORKS) 
CMake Warning at CMakeLists.txt:385 (MESSAGE):
  Your CUDA installation overrides OpenCL system library path.

-- RPATH set to /usr/lib/x86_64-linux-gnu
-- Linking with these libraries: 
 /usr/lib/x86_64-linux-gnu/libusb-1.0.so
 pthread
 va-drm
 va
 /usr/lib/x86_64-linux-gnu/libjpeg.so
 /usr/lib/x86_64-linux-gnu/libturbojpeg.so.0
 /usr/lib/x86_64-linux-gnu/libglfw.so
 /usr/lib/x86_64-linux-gnu/libGL.so
 /usr/lib/x86_64-linux-gnu/libOpenCL.so
 /usr/local/cuda/lib64/libcudart.so
-- Configurating examples
-- Using in-tree freenect2 target
-- Feature list:
--   CUDA    yes
--   CXX11    disabled
--   Examples    yes
--   OpenCL    yes
--   OpenGL    yes
--   OpenNI2    yes
--   TegraJPEG    no
--   Threading    tinythread
--   TurboJPEG    yes
--   VAAPI    yes
--   VideoToolbox    no (Apple only)
--   streamer_recorder    disabled
-- Configuring done
CMake Warning at CMakeLists.txt:413 (ADD_LIBRARY):
  Cannot generate a safe runtime search path for target freenect2 because
  files in some directories may conflict with libraries in implicit
  directories:
    runtime library [libOpenCL.so.1] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/cuda/lib64
  Some of these libraries may not be found correctly.

CMake Warning at CMakeLists.txt:461 (ADD_LIBRARY):
  Cannot generate a safe runtime search path for target freenect2-openni2
  because files in some directories may conflict with libraries in implicit
  directories:
    runtime library [libOpenCL.so.1] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/cuda/lib64

  Some of these libraries may not be found correctly.

CMake Warning at examples/CMakeLists.txt:76 (ADD_EXECUTABLE):
  Cannot generate a safe runtime search path for target Protonect because
  files in some directories may conflict with libraries in implicit
  directories:
    runtime library [libOpenCL.so.1] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/cuda/lib64

  Some of these libraries may not be found correctly.

-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:
    freenect2_DIR

-- Build files have been written to: /home/relaybot/mumu/KinectV2/libfreenect2/build
relaybot@ubuntu:~/mumu/KinectV2/libfreenect2/build$

Build (if you have run cd depends previously, cd .. back to the libfreenect2 root directory first.)
退回到libfreenect2文件夹下执行以下命令

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

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.

2.iai_kinect2安装(ROS)

ROS下iai_kinect2安装

cd ~/catkin_ws/src/
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"

结束后按照kinectV2 for ubuntu14.04+ROS安装做遇到问题:各种稀奇古怪的问题【bug…..bug……bug……】

其实这里是ROS的环境变量出了问题

bug记录:

relaybot@ubuntu:~/catkin_ws$ rospack profile
rospack: error while loading shared libraries: librospack.so: cannot open shared object file: No such file or directory

需要输入以下指令配置环境变量:

source /opt/ros/indigo/setup.bash 

以下是本机终端记录:

relaybot@ubuntu:~/catkin_ws$ source /opt/ros/indigo/setup.bash 
relaybot@ubuntu:~/catkin_ws$ rospack profile
Full tree crawl took 0.091655 seconds.
Directories marked with (*) contain no manifest.  You may
want to delete these directories.
To get just of list of directories without manifests,
re-run the profile with --zombie-only
-------------------------------------------------------------
0.088192   /opt/ros/indigo/share
0.000132 * /opt/ros/indigo/share/man
0.000100 * /opt/ros/indigo/share/doc
0.000029 * /opt/ros/indigo/share/man/man1
0.000014 * /opt/ros/indigo/share/doc/liborocos-kdl

不过还是有问题:

relaybot@ubuntu:~/catkin_ws$ roslaunch kinect2_bridge kinect2_bridge.launch
[kinect2_bridge.launch] is neither a launch file in package [kinect2_bridge] nor is [kinect2_bridge] a launch file name
The traceback for the exception was written to the log file

解决方案:
如果 roslaunch kinect2_bridge kinect2_bridge.launch``[kinect2_bridge.launch] is neither a launch file in package [kinect2_bridge.launch] nor is [kinect2_bridge.launch] a launch file name traceback for the exception was written to the log file
或者
如果执行$ roscd kinect2_bridge命令roscd说类似于:No such package/stack 'kinect2_bridge'你需要启动环境变量设置的文件,像你之前在create_a_workspace教程末尾中做的一样。

$ cd ~/catkin_ws
$ source devel/setup.bash
$ roscd kinect2_bridge
//这样子设置好当前终端下的环境变量

所以呢,执行以下命令:

relaybot@ubuntu:~/catkin_ws$ source devel/setup.bash 

本机终端记录:

relaybot@ubuntu:~/catkin_ws$ source devel/setup.bash 
relaybot@ubuntu:~/catkin_ws$ roscd kinect2_bridge
relaybot@ubuntu:~/catkin_ws/src/iai_kinect2/kinect2_bridge$ roslaunch kinect2_bridge kinect2_bridge.launch
... logging to /home/relaybot/.ros/log/98d8ab4e-22a6-11e8-92d8-68f728588803/roslaunch-ubuntu-17094.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://ubuntu:33666/

SUMMARY
========

PARAMETERS
 * /kinect2_bridge/base_name: kinect2
 * /kinect2_bridge/base_name_tf: kinect2
 * /kinect2_bridge/bilateral_filter: True
 * /kinect2_bridge/calib_path: /home/relaybot/ca...
 * /kinect2_bridge/depth_device: -1
 * /kinect2_bridge/depth_method: default
 * /kinect2_bridge/edge_aware_filter: True
 * /kinect2_bridge/fps_limit: -1.0
 * /kinect2_bridge/jpeg_quality: 90
 * /kinect2_bridge/max_depth: 12.0
 * /kinect2_bridge/min_depth: 0.1
 * /kinect2_bridge/png_level: 1
 * /kinect2_bridge/publish_tf: False
 * /kinect2_bridge/queue_size: 5
 * /kinect2_bridge/reg_device: -1
 * /kinect2_bridge/reg_method: default
 * /kinect2_bridge/sensor: 
 * /kinect2_bridge/use_png: False
 * /kinect2_bridge/worker_threads: 4
 * /kinect2_points_xyzrgb_hd/queue_size: 5
 * /kinect2_points_xyzrgb_qhd/queue_size: 5
 * /kinect2_points_xyzrgb_sd/queue_size: 5
 * /rosdistro: indigo
 * /rosversion: 1.11.21

NODES
  /
    kinect2 (nodelet/nodelet)
    kinect2_bridge (nodelet/nodelet)
    kinect2_points_xyzrgb_hd (nodelet/nodelet)
    kinect2_points_xyzrgb_qhd (nodelet/nodelet)
    kinect2_points_xyzrgb_sd (nodelet/nodelet)

auto-starting new master
process[master]: started with pid [17106]
ROS_MASTER_URI=http://localhost:11311

setting /run_id to 98d8ab4e-22a6-11e8-92d8-68f728588803
process[rosout-1]: started with pid [17119]
started core service [/rosout]
process[kinect2-2]: started with pid [17131]
process[kinect2_bridge-3]: started with pid [17136]
process[kinect2_points_xyzrgb_sd-4]: started with pid [17137]
[ INFO] [1520495956.667492444]: Loading nodelet /kinect2_bridge of type kinect2_bridge/kinect2_bridge_nodelet to manager kinect2 with the following remappings:
process[kinect2_points_xyzrgb_qhd-5]: started with pid [17147]
[ INFO] [1520495956.674327197]: waitForService: Service [/kinect2/load_nodelet] has not been advertised, waiting...
process[kinect2_points_xyzrgb_hd-6]: started with pid [17157]
[ERROR] [1520495956.880399787]: Skipping XML Document "/opt/ros/indigo/share/gmapping/nodelet_plugins.xml" which had no Root Element.  This likely means the XML is malformed or missing.
[ INFO] [1520495957.095547508]: Initializing nodelet with 4 worker threads.
[ INFO] [1520495957.113090433]: waitForService: Service [/kinect2/load_nodelet] is now available.
[ INFO] [1520495957.464561289]: [Kinect2Bridge::initialize] parameter:
        base_name: kinect2
           sensor: default
        fps_limit: -1
       calib_path: /home/relaybot/catkin_ws/src/iai_kinect2/kinect2_bridge/data/
          use_png: false
     jpeg_quality: 90
        png_level: 1
     depth_method: default
     depth_device: -1
       reg_method: default
       reg_device: -1
        max_depth: 12
        min_depth: 0.1
       queue_size: 5
 bilateral_filter: true
edge_aware_filter: true
       publish_tf: false
     base_name_tf: kinect2
   worker_threads: 4
[Info] [CudaDepthPacketProcessorImpl] device 0: GeForce 840M @ 1124MHz Memory 4044MB
[Info] [CudaDepthPacketProcessorImpl] selected device 0
libva info: VA-API version 0.39.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_0_39
libva info: va_openDriver() returns 0
[Info] [VaapiRgbPacketProcessorImpl] driver: Intel i965 driver for Intel(R) Haswell Mobile - 1.7.0
[Info] [Freenect2Impl] enumerating devices...
[Info] [Freenect2Impl] 10 usb devices connected
[Info] [Freenect2Impl] found valid Kinect v2 @3:17 with serial 002586753647
[Info] [Freenect2Impl] found 1 devices
[ INFO] [1520495957.644813764]: [Kinect2Bridge::initDevice] Kinect2 devices found: 
[ INFO] [1520495957.644873048]: [Kinect2Bridge::initDevice]   0: 002586753647 (selected)
[Info] [Freenect2DeviceImpl] opening...
[Info] [Freenect2DeviceImpl] transfer pool sizes rgb: 20*16384 ir: 60*8*33792
[Info] [Freenect2DeviceImpl] opened
[ INFO] [1520495957.736972270]: [Kinect2Bridge::initDevice] starting kinect2
[Info] [Freenect2DeviceImpl] starting...
[Info] [Freenect2DeviceImpl] submitting rgb transfers...
[Info] [Freenect2DeviceImpl] submitting depth transfers...
[Info] [Freenect2DeviceImpl] started
[ INFO] [1520495958.365036846]: [Kinect2Bridge::initDevice] device serial: 002586753647
[ INFO] [1520495958.365078875]: [Kinect2Bridge::initDevice] device firmware: 4.0.3916.0
[Info] [Freenect2DeviceImpl] stopping...
[Info] [Freenect2DeviceImpl] canceling rgb transfers...
[Info] [Freenect2DeviceImpl] canceling depth transfers...
[Info] [Freenect2DeviceImpl] stopped
[ WARN] [1520495958.633960719]: [Kinect2Bridge::initCalibration] using sensor defaults for color intrinsic parameters.
[ WARN] [1520495958.634014198]: [Kinect2Bridge::initCalibration] using sensor defaults for ir intrinsic parameters.
[ WARN] [1520495958.634046844]: [Kinect2Bridge::initCalibration] using defaults for rotation and translation.
[ WARN] [1520495958.634080744]: [Kinect2Bridge::initCalibration] using defaults for depth shift.
[ INFO] [1520495958.733665980]: [DepthRegistration::New] Using OpenCL registration method!
[ INFO] [1520495958.733728924]: [DepthRegistration::New] Using OpenCL registration method!
X server found. dri2 connection failed! 
X server found. dri2 connection failed! 
X server found. dri2 connection failed! 
X server found. dri2 connection failed! 
X server found. dri2 connection failed! 
X server found. dri2 connection failed! 
X server found. dri2 connection failed! 
X server found. dri2 connection failed! 
[ INFO] [1520495958.833337497]: [DepthRegistrationOpenCL::init] devices:
[ INFO] [1520495958.833408027]: [DepthRegistrationOpenCL::init]   0: Intel(R) HD Graphics Haswell Ultrabook GT2 Mobile
[ INFO] [1520495958.833748806]: [DepthRegistrationOpenCL::init]   1: GeForce 840M
[ INFO] [1520495958.833793716]: [DepthRegistrationOpenCL::init] selected device: Intel(R) HD Graphics Haswell Ultrabook GT2 Mobile
X server found. dri2 connection failed! 
X server found. dri2 connection failed! 
X server found. dri2 connection failed! 
X server found. dri2 connection failed! 
X server found. dri2 connection failed! 
X server found. dri2 connection failed! 
X server found. dri2 connection failed! 
[ INFO] [1520495958.977488033]: [DepthRegistrationOpenCL::init] devices:
[ INFO] [1520495958.977531922]: [DepthRegistrationOpenCL::init]   0: Intel(R) HD Graphics Haswell Ultrabook GT2 Mobile
[ INFO] [1520495958.977864882]: [DepthRegistrationOpenCL::init]   1: GeForce 840M
[ INFO] [1520495958.977894502]: [DepthRegistrationOpenCL::init] selected device: Intel(R) HD Graphics Haswell Ultrabook GT2 Mobile
X server found. dri2 connection failed! 
X server found. dri2 connection failed! 
X server found. dri2 connection failed! 
[ INFO] [1520495959.086099907]: [Kinect2Bridge::main] waiting for clients to connect

首先,运行 roslaunch kinect2_bridge kinect2_bridge.launch
这时,kinect2的红外灯会亮一会然后熄灭, 白灯也会过一段时间熄灭。
出现打印
INFO] [1478769022.036459690]: [Kinect2Bridge::main] waiting for clients to connect
表示kinect2启动成功

之后再开一个终端
才能输入rosrun等命令!
这里写图片描述

//但是,为了保证每次打开bash的时候,保证workspace在环境中,我们还需要做一些工作:
//在用户的主文件夹下找到”.bashrc”文件 
gedit ~/.bashrc     
 //然后在最后加上
source /opt/ros/indigo/setup.bash
source ~/catkin_ws/devel/setup.bash
//这两句一定加在最后面

重启搜狗输入法:
https://www.findhao.net/res/786

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值