kinect v2 + gpd + ubuntu 14.04.5

   花了很多时间把kinect v2 在我的Ubuntu14.04.5系统上加入到 gpd(grasp pose detector,美国西北大学的一个手臂抓取算法),该算法是《High precision grasp pose detection in dense clutter》的代码。

详细介绍参考https://github.com/atenpas/gpd。这里介绍将Kinect v2参考该代码集中的tutorail1中的步骤连接并工作。


目录:

    1、Kinect v2 驱动安装

    2、gpd编译

    3、细节更改和运行

1、kinectv2 驱动安装

    libfreenect安装参考:https://github.com/OpenKinect/libfreenect2,

    kinectv2 ros下连接驱动iai_kinect安装:https://github.com/code-iai/iai_kinect2

   我之前系统是Ubuntu14.04.3,显卡是AMD的,装完这两个驱动后总是会报一些莫名其妙的问题,所以系统推荐基于Ubuntu14.04.5。


2、gpd编译

    因为gpd是基于caffe框架的,所以编译gpd之前要先安装caffe,之前的博客中详细分享过,这里就不在赘述。 

    编译gpd之前还有一步,要先编译该论文中提出的一个生成抓取的算法grasp pose generator,论文作者将两部分分开放到github上的,所以要分开编译

    gpg(grasp pose generator)编译

        Clone the grasp_pose_generator repository into some folder:

$ cd 
$ git clone https://github.com/atenpas/gpg.git

Build and install the grasp_pose_generator:

$ cd gpg
$ mkdir build && cd build
$ cmake ..
$ make
$ sudo make install

  这里也有一个蛋疼的bug,不知是我的电脑问题,还是哪个依赖的问题,当我在Ubuntu14.04.3上编译通过,但运行时calculate surface normal的函数返回时总会报一个free()错的error,程序中断,但这个算法在Ubuntu14.04.5和Ubuntu16.04上亲测没有什么问题,后来我以为是gcc版本的问题,我升级了gcc和g++版本,但问题依然没在Ubuntu14.04.3上解决,所以我强烈推荐基于Ubuntu14.04.5上。

gpd(grasp pose detector)编译:

$ cd 
$ git clone https://github.com/atenpas/gpd.git

$ cd 
$ catkin_make

  这里编译是可能会遇到找不到Caffe的错,这是因为你还没对caffe进行cmake编译:

$ cd path_to_caffe...
$ mkdir build
$ cd build
$ cmake ..
$ make all
$ make install
$ make runtest

  这里很抱歉caffe安装博客里忘了这一步,外部使用这一步是必须的,不然find_package(Caffe)时会报找不到caffe的错。后面我会到caffe安装中去补完整。

3、细节更改和运行

这一步我是参考该算法中的tutorial1进行的。

   第一步、 和原算法中的相机不一样的前提下,将原文中的$ roslaunch openni2_launch openni2.launch改为:

$ roslaunch kinect2_launch kinect2.launch publish_tf:=true
后面的publish_tf:true很重要,不然在rviz中不能显示Kinectv2的点云图。

  第二步、 启动rviz,把左侧Fixed Frame的值改为kinect2_link,并添加相机点云topic: /Kinect2/qhd/points,这时点云就出现在rviz中了。

kinect v2 + gpd + ubuntu 14.04.5_第1张图片

  第三步、保存这个rviz的config,找到保存的.rviz文件打开,也打开算法中给的openni1.rviz。对比两个配置文档,首先将openni.rviz中的相机点云Topic修改为:

 Topic: /kinect2/qhd/points,同时将topic上一行的style改为:Style: Flat Squares,还有里面的fixed frame改为: Fixed Frame: kinect2_link。

  第四步、将修改后的openni.rviz在rviz中打开,这时有grasp array的点云图就有了。

  最后一步、修改tutorial1.launch文档,依然将cloud topic改为Kinect2的点云topic:

 

,并launch tutorial1:

$ roslaunch gpd tutorial1.launch
这里如果caffe是安装不支持GPU的话,这里运行时会报使用了只支持CPU的caffe,但用了GPU的layer。只要

gpd/launch/caffe/classifier_15channels.launch中使用GPU改为false就行。一切OK。重新运行,会在rviz中看到candidate grasp生成

你可能感兴趣的:(kinect v2 + gpd + ubuntu 14.04.5)