ORK网站教程汇总 - 图文 下载本文

ORK教程目录

1 ORK之Install ................................................................................................................................. 2 2 ORK之Quick Guide ....................................................................................................................... 3 3 ORK之tutorials ............................................................................................................................. 5

3.1 对象识别数据库(DB) .................................................................................................. 5

3.1.1 简介 ......................................................................................................................... 5 3.1.2 准备对象的mesh ................................................................................................... 5 3.1.3 DB中创建对象 ....................................................................................................... 5 3.1.4 手动给对象添加mesh ........................................................................................... 6 3.1.5 对象可视化 ............................................................................................................. 6 3.1.6 删除对象 ................................................................................................................. 7 3.2 使用Tabletop进行对象识别 ............................................................................................ 7

3.2.1 设置工作环境 ......................................................................................................... 7 3.2.2 寻找平面 ................................................................................................................. 8 3.2.3 对象寻找 ................................................................................................................. 8 3.2.4 常见问题回答 ......................................................................................................... 9

4 ORK之Usage ............................................................................................................................... 10

4.1 ORK Infrastructure ........................................................................................................... 10

4.1.1 Database ................................................................................................................. 10 4.1.2配置文件 ................................................................................................................ 11 4.2 Data Capture ..................................................................................................................... 11

4.2.1 3D Camera ............................................................................................................. 12 4.2.2 Setup....................................................................................................................... 12 4.2.3 Capture ................................................................................................................... 13 4.2.4 upload ..................................................................................................................... 16 4.2.5 API: ..................................................................................................................... 17 4.3 Training ............................................................................................................................. 17

4.3.1 ConfigFile .............................................................................................................. 17 4.3.2 Use ......................................................................................................................... 17 4.3.3 CommandLineInterface .......................................................................................... 17 4.4Detection ............................................................................................................................ 18

4.4.1 Use ......................................................................................................................... 18 4.4.2 Command Line Interface ........................................................................................ 18 4.4.3 ConfigurationFile ................................................................................................... 19

5 ORK之ROS integration ............................................................................................................... 20

5.1 ROS消息 .......................................................................................................................... 20 5.2 对象信息服务 .................................................................................................................. 22 5.3 Actionlib服务 ................................................................................................................... 22 5.4 发布和订阅 ...................................................................................................................... 23 5.5 RViz插件 .......................................................................................................................... 24 6 ORK之Recognition Pipelines ...................................................................................................... 26

6.1 LINE-MOD ....................................................................................................................... 26 6.2 tabletop .............................................................................................................................. 26 6.3 TOD .................................................................................................................................. 30 6.4 transparent objects ............................................................................................................. 32 7 ORK之Tool之Reconstruction .................................................................................................... 35

1 / 36

1 ORK之Install

1 安装openni

sudo apt-get install openni2-utils

2 SensorKinect:

命令:$git clone https://github.com/avin2/SensorKinect.git 如果没有安装git,则sudo apt-get install之~

过程比较慢,结束后会在当前路径出现一个文件夹SensorKinect,cd进SensorKinect/Platform/Linux/CreateRedist,之后$ ./RedistMaker,这时在上层目录Linux下出现Redist文件夹。此时网上说进该目录$ ./install.sh,但实际上还要进一层目录才有instal.sh文件。但是貌似执行这个需要root权限,我不知道怎么弄,$sudo su后也不行,最后发现还是Redist文件夹里面有一个Final文件夹,里面有一个压缩包Sensor-Bin-Linux-x86-v5.0.5.1.tar.bz2,我索性把它拷出来,解压缩后进去 (?/SensorKinect/Platform/Linux/CreateRedist/Sensor-Bin-Linux-x86-v5.0.5.1/),在里面$./install.sh,竟然就可以了。顺便说一下,可能在这些过程中输入$ ./install.sh 会提示没有命令之类的,可以在install.sh文件上右击->属性->权限,选中“允许以程序执行文件”,就可以了。

或者在Redist文件夹找到install.sh文件,运行sudo ./install.sh

3 安装usb库--LibUSB

1) Run: sudo apt-get install libusb-1.0-0-dev 2) Run: sudo apt-get install freeglut3-dev

2 / 36

2 ORK之Quick Guide

1、数据库中可视化数据

rosrun object_recognition_core push.sh

2、设置环境

erminal 1:

roscore

Terminal 2:

roslaunch openni_launch openni.launch

3、获取对象 (1)预览

rosrun object_recognition_capture capture --seg_z_min 0.01 -o silk.bag --preview

(2)正式获取

rosrun object_recognition_capture capture --seg_z_min 0.01 -o silk.bag

(3)将数据上传到DB中

rosrun object_recognition_capture upload -i silk.bag -n 'Silk' milk soy silk --commit

4、训练对象

(1)生成mesh

rosrun object_recognition_reconstruction mesh_object --all --visualize --commit (2)查看

http://localhost:5984/or_web_ui/_design/viewer/meshes.html (3)训练

rosrun object_recognition_core training \\

-c `rospack find object_recognition_tod`/conf/training.ork \\ --visualize 5、检测对象

rosrun object_recognition_core detection \\

-c `rospack find object_recognition_tod`/conf/detection.ros.ork \\ --visualize

3 / 36

4 / 36

3 ORK之tutorials

3.1 对象识别数据库(DB)

在ORK中,所有的东西都存储在数据库里:对象、模型、训练数据。本教程讲述关于DB基础内容,以下:

(1)将一个对象的mesh添加到DB中; (2)学习如何手动添加对象到DB中; (3)ORK数据库中数据的可视化。

3.1.1 简介

你要确保遵循核心数据库指令的步骤,尤其是DB的3D可视化。我们将使用的例子是可乐罐,因具有其一定的通用性:现实生活中的实验,获取标志性的红色罐子,这些不应当有太多的外观变化。

3.1.2 准备对象的mesh

对象的mesh(网格)对于在ORK中进行对象检测是非常重要的,其格式是.stl/obj。你可以按照ORK的捕获过程(快速教程中有很好的解释)来准备对象的mesh。此外,你可以使用任何生成mesh的软件来准备mesh。或者,你可以使用网上免费的mesh。

一旦有了mesh,在将其上传到DB之前,确保其尺寸正确并注意其初始点。在blender的屏幕快照下,你可以看到罐子的mesh的初始点和瓶子的mesh不一样。

在ORK中,由ORK返回的对象位置是对象mesh的初始点的位置。

3.1.3 DB中创建对象

ORK主要是识别对象的,所以首先需要将对象存储在DB中。一些像ORK 3d capture这样的管道可以用来创建。但是你也要从内核(core)中用脚本对其进行处理。

rosrun object_recognition_core object_add.py -n coke -d \ 然后就可以通过访问网址来检查数据库中的这个对象。

http://localhost:5984/_utils/database.html?object_recognition/_design/objects/_view/by_object_name

5 / 36

点击对象,可以看到对象的信息,尤其是对象的id:

3.1.4 手动给对象添加mesh

首先,使用DB(包括对象)接口来检查对象的id:DB的每个元素都有其自己的哈希表作为唯一标识(防止你给不同的对象相同的命名),这就是你应当如何去参考对象。

上传mesh:

rosrun object_recognition_core mesh_add.py YOUR_OBJECT_ID `rospack find object_recognition_tutorials`/data/coke.obj --commit

3.1.5 对象可视化

现在,如何向将DB中的对象可视化,你可以去可视化URL:

http://localhost:5984/or_web_ui/_design/viewer/meshes.html

你将能够看到以下:

6 / 36

3.1.6 删除对象

删除对象(也可以删除数据库中的所有其他元素,像模型/训练数据)

rosrun object_recognition_core object_delete.py OBJECT_ID

3.2 使用Tabletop进行对象识别

Tabletop是一个用于对象识别的简单通道,仅需要一个用于训练/检测的对象mesh,以下内容:

(1)学习如何使用tabletop通道来发现平面;

(2)学习如何使用tabletop通道来法线特定对象的类型; (3)使用ORK Rviz插件。

3.2.1 设置工作环境

1)硬件

一个3D相机(例如Kinect、Xtion),一个能够运行ROS的计算机,一些较为平的表面(例如桌子、墙、地面),或者一些可乐罐子。

2)软件 计算机需要安装ORK。需要rqt_reconfigure和RViz来配置3D相机并对平面和对象进行可视化。如果要安装这些工具,运行一下命令:

sudo apt-get install ros--rviz ros--rqt_reconfigure ros--openni*

3)配置3D相机和RViz参数 在独立的终端,运行以下命令:

roslaunch openni2_launch openni2.launch rosrun rviz rviz

设置固定框架(RVix窗口的左上)到/camera_depth_optical_frame。添加PlintCloud2显示,设置标题到/camera/depth/points。背景换成亮灰色能够提高视觉。这是深度相机框架中的未注册的点云。它不能和RGB相机的图像匹配。现在,看一个注册过的点云,其与RGB数据保持一致。打开动态重配准界面:

7 / 36

rosrun rqt_reconfigure rqt_reconfigure

从下拉菜单中选择/camera/driver ,启动 depth_registration 复选框,退回到RViz,将PoindCloud2标题转换到/camera/depth_registered/points,设颜色变换到RGB8,将看到屏幕3D点云的一种颜色。详细说明可以参考 http://wiki.ros.org/openni2_launch。

3.2.2 寻找平面

为使用ORK_Tabletop发现平面,运行下列命令:

rosrun object_recognition_core detection -c `rospack find object_recognition_tabletop`/conf/detection.table.ros.ork

然后到Rviz图形窗口,添加ORKTable显示,如果你的相机正对着平面,可以看到通过ORK_Tabletop检测的一些平面。

3.2.3 对象寻找

如果你按照安装向导(http://wg-perception.github.io/object_recognition_core/install.html#install),就知道ORK使用couchDB来管理对象数据库。为得到tabletop检测对象,我们需要用对象3D模型来维持数据库。

当你首先安装ORK的时候,数据库是空的。幸运的是ork教程自带一个可乐罐子的3D模型,所以下载教程为:

git clone https://github.com/wg-perception/ork_tutorials

然后上传到ORK数据库中:

rosrun object_recognition_core object_add.py -n \\-d %universal can of coke\rosrun object_recognition_core mesh_add.py

如果你做了上传对象的步骤,然后当你打开链接http://localhost:5984/or_web_ui/_design/viewer/objects.html,你将看到可乐对象在数据库中列出。所有的都设置好,来看一下ork_tabletop如何检测可乐罐子,在终端运行

rosrun object_reconition_core detection -c `rospack find object_recognition_tabletop`/conf/detection.object.ros.ork`

回到RViz,添加OrkObject显示,现在如果有可乐罐子放在检测平面上,ork_tabletop将会看到他,漂亮的RViz界面将展示如下:

8 / 36

注意:在图像中,仅仅能够看到可乐,因为OrkTable在RViz接口里没有被选中。除非你确实没有选中盒子,否则在漂亮的RViz中不应当出现这样的情况。

3.2.4 常见问题回答

9 / 36

4 ORK之Usage

4.1 ORK Infrastructure

object_recognition_core用于对象识别,其提供一个基础构件用于简单开发和对象识别管道的使用。当使用/开发一个自己创建或发现的新方法是,通常总是再现如下的内容:

? 存储/查询使用训练数据 ? 存储/查询/使用模型 ? 训练对象

? 处理导入的数据(相机、ROSrosbag,ROStopics) ? 数据导出 ? 与ROS集成

? 多管道同时运行进行比较

ORK通过提供基础类和灵活的基础构件能够实现右侧的所有功能,甚至更多

4.1.1Database

1)Implementation

CouchDB:{'type':'CouchDB','root':'http://localhost:5984','collection':'object_recognition'} Filesystem:{'path':'/tmp','type':'filesystem','collection':'object_recognition'} Empty(onlyfortesting):{'type':'empty'} 2)CouchDB ? 下载:

sudoapt-getinstallcouchdb ? 测试

curl-XGEThttp://localhost:5984 返回结果:

%{\3)配置 ? 修改地址

[httpd]port=5984bind_address=0.0.0.0 ? 重启

sudoservicecouchdbrestart 4)WebUI

? 确认是否有couchapp: sudopipinstall-Ucouchapp; ? DB的可视化工具:

10 / 36

rosrunobject_recognition_corepush.sh; ? 浏览URL:

http://localhost:5984/or_web_ui/_design/viewer/index.html 5)库

对象识别工具使用libCURL或python-couchdb来操纵数据库。 http://localhost:5984/_utils

4.1.2配置文件

ORK中有两个步骤需要配置好:Training和Detection。这个步骤非常灵活,可以用好几种输入/输出或者任何管道来定义。其通过配置文件中的参数传递进行配置。配置文件定义一个或多个ecto单元,这些单元在管道中进行连接和执行。单元定义如下: cell_name:

type:class_of_the_ecto_cell

module:Python_module_where_the_class_is

inputs:['other_cell_name_1','other_cell_name_2'](Optional) outputs:['other_cell_name_3','other_cell_name_4'](Optional) parameters:(Optional) any_valid_JSON 一个管道可能会是: cell1:

type:class1 module:module1 outputs:[cell2] parameters: parameter1:value1 cell2:

type:class2 module:module2

inputs:[cell1](Optional:actuallydoesnotneedtobeasit'sdefinedforcell1)

第二个单元也可以有参数。一旦定义了这些关系,单元会一起被正确的初始化、连接和执行。这看起来似乎是稀疏的信息但是它真的就这么简单。最简单的就是查看不同管道的不同配置文件。

4.2 Data Capture

object_recognition_capture:数据获取。

执行对象识别所获取的数据需要以下:

11 / 36

? 知道在一个稳定世界框架下相机的位置; ? 知道被获取图像/场景中对象的位置; ? 获得能够足够覆盖对象表面的视角。

第三点依赖于用所获取数据做什么(例如计算3D模型的格网),以及通过一定数量的视图做什么。第一点目前由一个特征显著的模式(一个点模式或自定义的模式)实现,这在Setup部分有描述。第二点的解决是由分割出高于平面的任何物体来决定。Capture使用由object_recognition_core和object_recognition_capture所提供的数据库基础构件来存储获取的数据。

4.2.1 3D Camera

Kinect

4.2.2 Setup

捕获是基于视图的,需要一个严格的基于被观察对象的基准点。这使得相对准确角度的点姿态的估计、一致的对象坐标框架和简单的对象/背景分割成为可能。设置工作是假设您有一个RGB深度设备,如Kinect。我们有两个方法进行对象获取,其结果的质量大致相当:一个点模式和一个通用的模式(这是有用的,如果你不能打印点模式)

1)DotPattern

查看附件:capture_board_big_5x3.svg.png

http://wg-perception.github.io/capture/_downloads/capture_board_big_5x3.svg http://wg-perception.github.io/capture/_downloads/capture_board_big_5x3.svg.pdf

12 / 36

点模式有两套基准标记:白色上的黑点和黑色上的白点,这样两个基准在场景中会被检测到,并允许在闭合的标记场景中进行姿态的估算。拿到一个全尺寸打印的纸,上面有基准标记并将其放在平面上。

注意:模式(pattern)的物理尺寸其实并不重要,因为它是在3D和合适的比例尺中使用Kinect平面探测器发现的。

2)ORBTemplate

如果你不想打印点模式,你可以用一个平面特征很显著的表面。这涉及到的内容是,获取一个规范化的表面视图,以便后面可以建立一个对象坐标系统并执行分割。

首先获取一个capture工作空间的ORB模板。它应来自正前方平面视角,图像的中心应该由平面填充的。按“s”来保存图像。结果将被放置在给定的目录中,例如my_textured_plane。按“q”退出模板捕获程序。

rosrunobject_recognition_captureorb_template-omy_textured_plane

尝试追踪去看看你是否获得了一个良好的模板,按“q”退出。

rosrunobject_recognition_captureorb_track--track_directorymy_textured_plane

4.2.3 Capture

Capture是点的入口,以便使用对象获取系统。capture程序将估算每个视角下的姿势,以及基于深度的掩膜。这使得数据的ROS包有以下主题:

types: geometry_msgs/PoseStamped [d3812c3cbc69362b77dc0b19b345f8f5] sensor_msgs/CameraInfo [c9a58c1b0b154e0e6da7578cb991d214] sensor_msgs/Image [060021388200f6f0f447d0fcd9c64743] topics: /camera/depth/camera_info 72 msgs : sensor_msgs/CameraInfo /camera/depth/image 72 msgs : sensor_msgs/Image 13 / 36

/camera/mask 72 msgs : sensor_msgs/Image /camera/pose 72 msgs : geometry_msgs/PoseStamped /camera/rgb/camera_info 72 msgs : sensor_msgs/CameraInfo /camera/rgb/image_color 72 msgs : sensor_msgs/Image 要使用Capture,应当将对象放在基准面的中心,并和所有Capture场景保持位置一致。缓慢的转动基板,程序将捕获那些均匀分布在视角姿态范围内的视图。

在预览模式下运行捕获程序,确保姿态展示出来,同时对象的掩膜不为空。掩膜表示以姿态对象为中心的所有圆柱体的对象,并通过命令行指定尺寸。这就是所谓的对象集群,其用于训练。

如果用的是点模式,删除下面的-i选项:

Rosrun object_recognition_capture capture –I my_textured_plane --seg_z_min 0.01 –o silk.bag

--preview

您应该会看到一个弹出图片类似如下:

视角的样本序列通过使用一个反向点模式基准掩膜获取的。

当预览模式较为满意是,就让它真正开始运行。以下将捕获60个视图的包,每个视图正常分布在视角球面上。仅当获取新的视图时,掩膜和姿态才重新刷新。当获取360度视角时,程序将结束。按“q”提前退出。

14 / 36

rosrunobject_recognition_capturecapture-imy_textured_plane--seg_z_min0.01-osilk.bag 帮助: usage: capture [-h] [-o BAG_FILE] [-a RADIANS] [-n NVIEWS] [--preview] [-i,--input INPUT] [-m,--matches] [--fps FPS] [--res RES] [--seg_radius_crop SEG_RADIUS_CROP] [--seg_z_crop SEG_Z_CROP] [--seg_z_min SEG_Z_MIN] [--niter ITERATIONS] [--shell] [--gui] [--logfile LOGFILE] [--graphviz] [--dotfile DOTFILE] [--stats] Captures data appropriate for training object recognition pipelines. Assumes that there is a known fiducial in the scene, and captures views of the object sparsely, depending on the angle_thresh setting. optional arguments: -h, --help show this help message and exit -o BAG_FILE, --output BAG_FILE A bagfile to write to. -a RADIANS, --angle_thresh RADIANS The delta angular threshold in pose.Frames will not be recorded unless they are not closer to any other pose by this amount. default(0.174532925199) -n NVIEWS, --nviews NVIEWS Number of desired views. default(36) --preview Preview the pose estimator. -i,--input INPUT The directory of the template to use. If empty, it uses the opposite dot pattern -m,--matches Visualize the matches. camera: --fps FPS The temporal resolution of the captured data --res RES The image resolution of the captured data. seg options: --seg_radius_crop SEG_RADIUS_CROP The amount to keep in the x direction (meters) relative to the coordinate frame defined by the pose. ~ (default: 0.20000000298) --seg_z_crop SEG_Z_CROP The amount to keep in the z direction (meters) relative to the coordinate frame defined by the pose. ~ (default: 0.5) --seg_z_min SEG_Z_MIN The amount to crop above the plane, in meters. ~ (default: 0.00749999983236 15 / 36

4.2.3.1 multiple capture sessions

从不同视角的点获取一个对象的多个包,在上传之前需要连接。

Usage: concat.py OUTPUT INPUT1 [INPUT2 ...]

4.2.4 upload

一旦获取了视图的包,就会将包上传到数据库中。这个“upload”包含所有视图的包,添加一些对象的元信息。假设每个包都有一个对象,该对象有一个已知的坐标框架。

1)use % rosrun object_recognition_capture upload -a 'Ethan Rublee' -e 'erublee@willowgarage.com' -i silk.bag -n 'silk' -d 'A carton of Silk brand soy milk.' --commit milk, soy, kitchen, tod Uploaded session with id: 4ad9f2d3db57bbd414e5e987773490a0 如果没有“--commit”,脚本执行的时候不提交到任何的数据库中。 上传后,查看DB:

http://localhost:5984/_utils/database.html?object_recognition/_design/objects/_view/by_object_name

2)command line interface usage: upload [-h] [-i BAG_FILE] [-n OBJECT_NAME] [-d DESCRIPTION] [-a AUTHOR_NAME] [-e EMAIL_ADDRESS] [--visualize] [--db_type DB_TYPE] [--db_root DB_ROOT_URL] [--db_collection DB_COLLECTION] [--commit] [--niter ITERATIONS] [--shell] [--gui] [--logfile LOGFILE] [--graphviz] [--dotfile DOTFILE] [--stats] TAGS [TAGS ...] Uploads a bag, with an object description to the db. positional arguments: TAGS Tags to add to object description. optional arguments: -h, --help show this help message and exit -i BAG_FILE, --input BAG_FILE A bag file to upload. -n OBJECT_NAME, --object_name OBJECT_NAME -d DESCRIPTION, --description DESCRIPTION -a AUTHOR_NAME, --author AUTHOR_NAME -e EMAIL_ADDRESS, --email EMAIL_ADDRESS --visualize Turn on visualization Database Parameters: --db_type DB_TYPE The type of database used: one of [CouchDB]. Default: CouchDB --db_root DB_ROOT_URL 16 / 36

The database root URL to connect to. Default: http://localhost:5984 --db_collection DB_COLLECTION The database root URL to connect to. Default: object_recognition --commit Commit the data to the database

3)willowusers

一些之前获取的包存在于内部,备份如下:

rsync-vPa/wg/wgss0_shelf1/object_recognition_capture./

4.2.5 API:

咨询获取单元的API,点击:

http://wg-perception.github.io/capture/reference.html

4.3 Training

一旦观测数据存储在数据库中,就可以通过他们构建模型

4.3.1 ConfigFile

训练,就像识别,需要一个配置文件,但它通常只包含一个单元,其定义了一个从数据库中读取数据的管道并计算模型,从数据库中读取数据和计算模型。然后,可以同时通过执行好几个管道来训练好几个模型。

4.3.2 Use

训练脚本可以如下被执行: rosrunobject_recognition_coretraining\\

-c`rospackfindobject_recognition_tod`/conf/training.ork\\ --visualize

你可以选择任何配置文件,一部分在object_recognition_server/conf中提供。

一个典型的命令行会话像这样:

%apps/training-cconfig_training.txt--commit PrepareG2O:processingimage65/65 PerformingfullBA:

iteration=0chi2=168324165740673896546304.000000time=39.2803cumTime=39.2803lambda=154861.907021edges=64563schur=1Persisted

4.3.3 CommandLineInterface

usage: training [-h] [-c CONFIG_FILE] [--visualize] [--commit] optional arguments: -h, --help show this help message and exit -c CONFIG_FILE, --config_file CONFIG_FILE Config file --visualize If set and the pipeline supports it, it will display some windows with temporary results 17 / 36

--commit Commit the data to the database.

4.4Detection

4.4.1 Use

持续检测:

rosrun object_recognition_core detection -c `rospack find object_recognition_tod`/conf/detection.ros.ork

actionlibserver(在当前快照中检索标识的对象):

rosrun object_recognition_ros server -c` rospack find object_recognition_tod`/conf/detection.ros.ork

用客户端进行检测服务器: Rosrun object_recognition_ros client

使用roslaunch

roslaunch object_recognition_ros server.robot.launch

典型的命令行会话:

% apps/detection -c `rospack find object_recognition_tod`/conf/detection.ros.ork [ INFO] [1317692023.717854617]: Initialized ros. node_name: /ecto_node_1317692023710501315 Threadpool executing [unlimited] ticks in 5 threads. [ INFO] [1317692024.254588151]: Subscribed to topic:/camera/rgb/camera_info with queue size of 0 [ INFO] [1317692024.255467268]: Subscribed to topic:/camera/depth_registered/camera_info with queue size of 0 [ INFO] [1317692024.256186358]: Subscribed to topic:/camera/depth_registered/image with queue size of 0 [ INFO] [1317692024.256863212]: Subscribed to topic:/camera/rgb/image_color with queue size of 0 model_id: e2449bdc43fd6d9dd646fcbcd012daaa span: 0.433393 meters 1 ***Starting object: 0 * starting RANSAC added : 1 added : 0 * n inliers: 1824 [-0.056509789, 0.99800211, 0.028263446; 0.94346958, 0.062639669, -0.32548648; -0.32660651, 0.0082725696, -0.94512439] [-0.32655218; 0.03684178; 0.85040951] ********************* found 1poses [ INFO] [1317692117.187226953]: publishing to topic:/object_ids [ INFO] [1317692117.188155476]: publishing to topic:/poses

4.4.2 Command Line Interface

usage: detection [-h] [-c CONFIG_FILE] [--visualize] [--niter ITERATIONS] [--shell] [--gui] [--logfile LOGFILE] [--graphviz] [--dotfile DOTFILE] [--stats] optional arguments: -h, --help show this help message and exit 18 / 36

-c CONFIG_FILE, --config_file CONFIG_FILE Config file --visualize If set and the pipeline supports it, it will display some windows with temporary results Ecto runtime parameters: --niter ITERATIONS Run the graph for niter iterations. 0 means run until stopped by a cell or external forces. (default: 0) --shell 'Bring up an ipython prompt, and execute asynchronously.(default: False) --gui Bring up a gui to help execute the plasm. --logfile LOGFILE Log to the given file, use tail -f LOGFILE to see the live output. May be useful in combination with --shell --graphviz Show the graphviz of the plasm. (default: False) --dotfile DOTFILE Output a graph in dot format to the given file. If no file is given, no output will be generated. (default: ) --stats Show the runtime statistics of the plasm.

4.4.3 ConfigurationFile

主要配置:source、sink、pipeline

http://wg-perception.github.io/object_recognition_core/detection/detection.html#configuration-file

19 / 36

5 ORK之ROS integration

这个包定义了好几个ROS接口用于ORK。由于ORK对于ROS是未知的,其多种输入/输出单元是特定的ROS,同时也有RViz插件。

5.1 ROS消息

1)对象定义

OjjectId.msg中将一个对象唯一的定义成一种类型和数据库: ################################################## OBJECT ID ######################################################### # Contains information about the type of a found object. Those two sets of parameters together uniquely define an # object # The key of the found object: the unique identifier in the given db string key # The db parameters stored as a JSON/compressed YAML string. An object id does not make sense without the corresponding # database. E.g., in object_recognition, it can look like: \'root':'http://localhost'}\# There is no conventional format for those parameters and it's nice to keep that flexibility. # The object_recognition_core as a generic DB type that can read those fields # Current examples: # For CouchDB: # type: 'CouchDB' # root: 'http://localhost:5984' # collection: 'object_recognition' # For SQL household database: # type: 'SqlHousehold' # host: 'wgs36' # port: 5432 # user: 'willow' # password: 'willow' # name: 'household_objects' # module: 'tabletop' string db 更多的信息被ORK存储在数据库中,这些信息可以在ObjectInformation.msg中检索: ############################################## VISUALIZATION INFO ###################################################### ################### THIS INFO SHOULD BE OBTAINED INDEPENDENTLY FROM THE CORE, LIKE IN AN RVIZ PLUGIN ################### # The human readable name of the object string name # The full mesh of the object: this can be useful for display purposes, augmented reality ... but it can be big # Make sure the type is MESH shape_msgs/Mesh ground_truth_mesh # Sometimes, you only have a cloud in the DB 20 / 36

# Make sure the type is POINTS sensor_msgs/PointCloud2 ground_truth_point_cloud 2)识别对象

当对象被识别出的时候,被识别对象数组发布在RecognizedObjectArray.msg中: ##################################################### HEADER ########################################################### Header header # This message type describes a potential scene configuration: a set of objects that can explain the scene object_recognition_msgs/RecognizedObject[] objects ##################################################### SEARCH ########################################################### # The co-occurrence matrix between the recognized objects float32[] cooccurrence 其包含了好几个RecognizedObject.msg: ##################################################### HEADER ########################################################### # The header frame corresponds to the pose frame, NOT the point_cloud frame. Header header ################################################## OBJECT INFO ######################################################### # Contains information about the type and the position of a found object # Some of those fields might not be filled because the used techniques do not fill them or because the user does not # request them # The type of the found object object_recognition_msgs/ObjectType type #confidence: how sure you are it is that object and not another one. # It is between 0 and 1 and the closer to one it is the better float32 confidence ################################################ OBJECT CLUSTERS ####################################################### # Sometimes you can extract the 3d points that belong to the object, in the frames of the original sensors # (it is an array as you might have several sensors) sensor_msgs/PointCloud2[] point_clouds # Sometimes, you can only provide a bounding box/shape, even in 3d # This is in the pose frame shape_msgs/Mesh bounding_mesh # Sometimes, you only have 2d input so you can't really give a pose, you just get a contour, or a box # The last point will be linked to the first one automatically 21 / 36

geometry_msgs/Point[] bounding_contours #################################################### POSE INFO ######################################################### # This is the result that everybody expects : the pose in some frame given with the input. The units are radian/meters # as usual geometry_msgs/PoseWithCovarianceStamped pose 3)桌子

桌子对于识别对象是非常有用的,Tabletop探测器进行发现时,其有两个消息: # Informs that a planar table has been detected at a given location Header header # The pose gives you the transform that take you to the coordinate system # of the table, with the origin somewhere in the table plane and the # z axis normal to the plane geometry_msgs/Pose pose # There is no guarantee that the table does NOT extend further than the # convex hull; this is just as far as we've observed it. # The origin of the table coordinate system is inside the convex hull # Set of points forming the convex hull of the table geometry_msgs/Point[] convex_hull Header header # Just an array of tables object_recognition_msgs/Table[] tables 5.2 对象信息服务

有一个获取对象信息的服务:对其查询,将检索任何已知的事物。其定义如下: # Retrieve extra data from the DB for a given object # The type of the object to retrieve info from object_recognition_msgs/ObjectType type --- # Extra object info object_recognition_msgs/ObjectInformation information 5.3 Actionlib服务

Actionlib服务有助于在当前快照中对已确认的对象进行检索,其定义如下: # Optional ROI to use for the object detection bool use_roi float32[] filter_limits --- 22 / 36

# Send the found objects, see the msg files for docs object_recognition_msgs/RecognizedObjectArray recognized_objects --- #no feedback 如果要运行,需要通过以下来启动: rosrun object_recognition_server server -c whatever_config_file.ork 也可以用client来测试(在客户端进行测试的意思): rosrun object_recognition_server client 应该会显示接收到的消息。

若要测试,甚至可以用一个测试管道来运行服务器:

rosrun object_recognition_server server -c `rospack find object_recognition_ros`/conf/detection.test.ros.ork 5.4 发布和订阅

这个包提供了对于ROS来说比较特别的发布和订阅。 1)资源 BagReader: type: BagReader module: object_recognition_ros.io.source.bag_reader parameters: # The bag file name. bag: data.bag # If the cropper cell is enabled crop_enabled: True # The ROS topic for the depth camera info. depth_camera_info: /camera/depth_registered/camera_info # The ROS topic for the depth image. depth_image_topic: /camera/depth_registered/image_raw # The ROS topic for the RGB camera info. rgb_camera_info: /camera/rgb/camera_info # The ROS topic for the RGB image. rgb_image_topic: /camera/rgb/image_color # The maximum x value (in the camera reference frame) x_max: 3.40282346639e+38 # The minimum x value (in the camera reference frame) x_min: -3.40282346639e+38 # The maximum y value (in the camera reference frame) y_max: 3.40282346639e+38 # The minimum y value (in the camera reference frame) y_min: -3.40282346639e+38 # The maximum z value (in the camera reference frame) z_max: 3.40282346639e+38 # The minimum z value (in the camera reference frame) z_min: -3.40282346639e+38 RosKinect: type: RosKinect module: object_recognition_ros.io.source.ros_kinect parameters: # If the cropper cell is enabled crop_enabled: True 23 / 36

# The ROS topic for the depth camera info. depth_camera_info: /camera/depth_registered/camera_info # The ROS topic for the depth image. depth_image_topic: /camera/depth_registered/image_raw # The ROS topic for the RGB camera info. rgb_camera_info: /camera/rgb/camera_info # The ROS topic for the RGB image. rgb_image_topic: /camera/rgb/image_color # The maximum x value (in the camera reference frame) x_max: 3.40282346639e+38 # The minimum x value (in the camera reference frame) x_min: -3.40282346639e+38 # The maximum y value (in the camera reference frame) y_max: 3.40282346639e+38 # The minimum y value (in the camera reference frame) y_min: -3.40282346639e+38 # The maximum z value (in the camera reference frame) z_max: 3.40282346639e+38 # The minimum z value (in the camera reference frame) z_min: -3.40282346639e+38 2)sinks Publisher: type: Publisher module: object_recognition_ros.io.sink.publisher parameters: # The DB parameters db_params: # Determines if the topics will be latched. latched: True # The ROS topic to use for the marker array. markers_topic: markers # The ROS topic to use for the object meta info string object_ids_topic: object_ids # The ROS topic to use for the pose array. pose_topic: poses # Sets whether the point cloud clusters have to be published or not publish_clusters: True # The ROS topic to use for the recognized object recognized_object_array_topic: recognized_object_array 5.5 RViz插件

RViz是ROS的可视化工具,ROS对于对象的自检(introspection)支持两种插件。 1)Table插件

这个插件可以展示一个Table.msg,Tabletop管道中可以找到实例。它展示桌子凸面的外形、一个边界框和一个顶部桌子顶部的向量。

24 / 36

2)对象插件

对象插件可以展示RecognizedObject.msgs,ORK的默认输出。

25 / 36

6 ORK之Recognition Pipelines

框架中可以运行好几种对象识别通道: Techniques LINE-MOD2D/3D 2D and/or 3D ? ? ? Types of object rigid, Lambertian rigid, Lambertian rotationally symmetric also finds planar surfaces rigid, Lambertian textured rigid and transparent ? ? Limitations does not work with partial occlusions scales linearly with the number of objects the object is assumed to be on a table with no 3d rotation ? ? tabletop3D ? TOD2D and 3D 2D and 3D ? ? ? transparent objectsTraining has to be done on a painted version of the object

6.1 LINE-MOD

object_recognition_linemod:用LINE-MOD进行对象识别。

该通道运行LINE-MOD,了解更多的信息查看网页http://ar.in.tum.de/Main/StefanHinterstoisser。它是用于识别一般刚性物体的最好方法之一,其使用非常快速的模型匹配来处理。这个包中所使用的版本和初始的论文(OpenCV)是一样的,但让其正常工作的技巧在前/后的处理步骤中。

1)预处理步骤

使用一个“视图自动生成器”来生成所有的模型。平面内相机多样化的旋转着,处理不同的尺度和观察点。带有深度和掩膜的成千上万的图像被生成,并提供给OpenCV训练器。

2)处理步骤

OpenCV探测器被简单的称为(原文后面也没有)。。。。 3)后续处理步骤

执行一个ICP步骤类似于ACCV,可能是:

Linear Least-Squares Optimization for Point-to-Plane ICPSurface Registration

6.2 tabletop

Tabletop是http://www.ros.org/wiki/tabletop_object_detector中方法的一部分,其最初由Marius Muja在FLANN框架中开发。

这个对象检测方法有两部分:一个桌子探测器(finder)和一个对象识别器。识别部分只能够识别那些旋转对称的对象。Tabletop所使用的传感器数据由来自狭窄的立体照片或Kinect相机中的点云组成。Tabletop执行以下步骤:

? 分割:通过发现点云中的支撑平面来探测桌子,而点云是基于3D法向量进行分析

的;桌子上方的点被认为属于易抓举的对象。我们使用聚类算法来识别单个对象。

26 / 36

我们将点统一考虑到一个单一的对象中作为簇。

? 识别:对每一个簇,用一个简单的迭代拟合技术(类似ICP)来查看其与模型数据

库中的每个mesh对应的怎么样。如果找到了一个很好的匹配,模型的数据库id和簇同时返回;注意当前的匹配方法是在2D中操作的,因为急于我们的假设(对象静止垂直在已知桌子的表面)其他4个维度是固定的。 1)桌子探测器

桌子探测器寻找场景中的平面,并在其上进行对象分割。如果你需要将簇作为给一个预处理步骤,这个方法本身是有用的???。

执行下面命令启动管道:

rosrun object_recognition_ros server -c `rospack find object_recognition_tabletop`/conf/detection.table.ork

在ROS模式中发表了好几个主题:

? 用于平面上簇的MarkerArray.msg(/tabletop/clusters) ? 用于不同桌子(RViz ork插件用于对其可视化)的Table.msg 2)对象探测器

管道识别对象功能的部分如下:从上一阶段中而来的对簇进行分割,在数据库中找到可能的候选者,然后在最终的ICP步骤中,试图将其mesh匹配到被观察的簇中。

执行这些任务tabletop依赖如下假设;

? 对象放在桌子上,而桌子是场景中的支撑平面;

? 两个物体之间的最小距离超过一个给定的阈值(演示中是3厘米);

? 此外,对象识别仅仅只能处理两个自由度:沿着x和y轴(z轴假定相对于桌子指

向“向上”)转化。因此,为了识别一个对象: ? 其必须是旋转对称的;

? 必须有一个已知的定向,例如一个杯子或碗垂直坐落在桌子上。

组件的输出包括桌子的位置、确认的点簇和相应的数据库对象id,以及法线类似于数据库对象的点簇的匹配姿态。Tabletop使用CouchDB数据库,其包含有关对象识别的细节。这些细节包括对象id(对象添加到数据库是其id自动生成)、对象名称、对象作者、对象标记的3D格网。在识别步骤中3D格网将被tabletop使用。设置一个CouchDB和管理对象都会在这里被解释。

3)管理tabletop的输入参数

Tabletop管理一定数量的参数,像输入图像流、数据库细节和检测阈值,所有的这些参数定义在一个配置文件中,在tabletop命令中以-c参数。配置文件需要以YAML格式形式。一个例子由openni_launch包发布的、用于tabletop处理图像的配置文件如下: source1: type: RosKinect module: 'object_recognition_ros.io' 27 / 36

parameters: rgb_frame_id: camera_rgb_optical_frame rgb_image_topic: /camera/rgb/image_rect_color rgb_camera_info: /camera/rgb/camera_info depth_image_topic: /camera/depth_registered/image_raw depth_camera_info: /camera/depth_registered/camera_info sink1: type: TablePublisher module: 'object_recognition_tabletop' inputs: [source1] sink2: type: Publisher module: 'object_recognition_ros.io' inputs: [source1] pipeline1: type: TabletopTableDetector module: 'object_recognition_tabletop' inputs: [source1] outputs: [sink1] parameters: table_detector: min_table_size: 4000 plane_threshold: 0.01 pipeline2: type: TabletopObjectDetector module: 'object_recognition_tabletop' inputs: [source1, pipeline1] outputs: [sink2] parameters: object_ids: 'all' tabletop_object_ids: 'REDUCED_MODEL_SET' threshold: 0.85 db: type: CouchDB root: http://localhost:5984 collection: object_recognition “source1”定义了tabletop需要检测步骤的图像标题。基本上,tabletop需要一个深度图像标题、一个惭色图像标题和作为输入的相机信息。“sink1”和“sink2”定义tabletop的

28 / 36

输出如何能够进一步的处理。在这个例子中,他们考虑发布tabletop的检测结果。“pipelin1”考虑检测平面的表面。“pipelin2”考虑检测主平面上的对象。

你可以修改这些参数,例如输入图像标题、检测阈值、CouchDB的URI等等 4)实例

这里是场景什么样子

接着通道找到平面和其上面的簇

然后确认簇作为数据库中的对象

29 / 36

6.3 TOD

object_recognition_tod: 纹理对象检测。 1)训练

在配置文件中需要指定所使用的功能/描述符以及搜索参数。DB参数是标准的ObjectDbParameters 参数。一个典型的配置文件像以下所示:

# info about the db pipeline1: type: TodTrainer module: object_recognition_tod submethod: descriptor: type: 'ORB' parameters: feature: type: ORB module: ecto_opencv.features2d n_features: 1000 n_levels: 3 scale_factor: 1.2 descriptor: type: ORB module: ecto_opencv.features2d search: key_size: 24 multi_probe_level: 2 n_tables: 8 radius: 55 ratio: 0.8 type: 'LSH' db: type: 'CouchDB' root: 'http://localhost:5984' collection: 'object_recognition' # The list of object_ids to analyze 30 / 36

object_ids: \ 训练时,对象特征和描述在不同的视角被提取。对每个视角来说,如果获取(这是唯一支持的方法,强烈推荐)了深度值,则3D位置也会被存储。你也可以通过启动 apps/feature_viewer应用程序来查看特征值的点云。

$ /home/vrabaud/workspace/recognition_kitchen_groovy/src/object_recognition_tod/doc/source/../../apps/feature_viewer --help usage: feature_viewer [-h] [--db_type DB_TYPE] [--db_root DB_ROOT_URL] [--db_collection DB_COLLECTION] [--commit] [--niter ITERATIONS] [--shell] [--gui] [--logfile LOGFILE] [--graphviz] [--dotfile DOTFILE] [--stats] object_id positional arguments: object_id The id of the object for which the TOD model will be displayed. optional arguments: -h, --help show this help message and exit Database Parameters: --db_type DB_TYPE The type of database used: one of [CouchDB]. Default: CouchDB --db_root DB_ROOT_URL The database root URL to connect to. Default: http://localhost:5984 --db_collection DB_COLLECTION The database root URL to connect to. Default: object_recognition --commit Commit the data to the database. Ecto runtime parameters: --niter ITERATIONS Run the graph for niter iterations. 0 means run until stopped by a cell or external forces. (default: 0) --shell 'Bring up an ipython prompt, and execute asynchronously.(default: False) --gui Bring up a gui to help execute the plasm. --logfile LOGFILE Log to the given file, use tail -f LOGFILE to see the live output. May be useful in combination with --shell --graphviz Show the graphviz of the plasm. (default: False) --dotfile DOTFILE Output a graph in dot format to the given file. If no file is given, no output will be generated. (default: ) --stats Show the runtime statistics of the plasm. 2)检测

一个典型的配置文件如下:

source1: type: 'OpenNI' module: 'object_recognition_core.io.source' parameters: image_mode: 'SXGA_RES' depth_mode: 'VGA_RES' 31 / 36

image_fps: 'FPS_15' depth_fps: 'FPS_30' #Use this instead to receive images via ROS #source1: # type: ros_kinect # rgb_frame_id: '/camera_rgb_optical_frame' pipeline1: type: 'TodDetector' module: 'object_recognition_tod' subtype: type: 'ORB' inputs: [source1] parameters: object_ids: \ feature: type: ORB module: ecto_opencv.features2d n_features: 5000 n_levels: 3 scale_factor: 1.2 descriptor: type: ORB module: ecto_opencv.features2d search: type: LSH module: ecto_opencv.features2d key_size: 16 multi_probe_level: 1 n_tables: 10 radius: 35 ratio: 0.8 n_ransac_iterations: 2500 min_inliers: 8 sensor_error: 0.01 db: type: CouchDB root: http://localhost:5984 collection: object_recognition 检测时,计算当前图像的特征值/描述符号,并将其与数据库进行比较。然后,用最邻近法()来检查这些描述符号的最邻近是否有类似的3D配置。如果输入的数据是3D,那么它是一个3D对3D的比较,但是如果输入数据位2D,那么它是一个PnP类型的问题()。所以基本上,你只能得到一个以RGBD输入的对象的姿态。

6.4 transparent objects

object_recognition_transparent_objects: 透明对象的识别。

假定已有一个对象的点云模型,那么Transparent bojects管道可以检测和估算透明对象的姿态。管道完全集成到ROK里,所以对象识别中的正常的训练和检测可用于后续的抓举。查看ROS快速向导或对象识别来详细了解如何使用它。

1)例子

你可以不使用对象识别来运行一个快速实例,看看算法如何工作以及如何使用它的。所有必需的数据和源代码位于sample文件夹。Sample编译到bin文件里,你可以通过sample

32 / 36

目录路径作为命令行参数运行,例如:

./bin/sample ../or-transparent-objects/sample/ 一会后你就会看到输入数据

以及算法的结果类似于

33 / 36

2)参考

[1] Ilya Lysenkov, Victor Eruhimov, and Gary Bradski, “Recognition and Pose Estimation of Rigid Transparent Objects with a Kinect Sensor,” 2013 Robotics: Science and Systems Conference (RSS), 2013.

[2] Ilya Lysenkov, and Vincent Rabaud, “Pose Estimation of Rigid Transparent Objects in

Transparent Clutter”, 2013 IEEE International Conference on Robotics and Automation (ICRA), 2013.

34 / 36

7 ORK之Tool之Reconstruction

Ojject_recognition_reconstruction:3D对象重建。

Reconstruction提供了一个实用程序来创建一个对象的3D重建。其根据capture中来的数据来创建一个近似的特征不明显的mesh。算法是仅仅从多个视角来合并了深度图像,并稍微的对其进行光滑处理。没做什么巧妙的事情。

1)安装依赖关系

首先安装meshlab,其用于将深度地图聚合到mesh。 sudo apt-get install meshlab 2)命令行 从命令行中,你想执行下列命令来计算所有的mesh并提交给本地的数据库: rosrun object_recognition_reconstruction mesh_object --all --visualize --commit 或者使用适当的命令行参数来调优: $ /home/vrabaud/workspace/recognition_kitchen_groovy/src/object_recognition_reconstruction/doc/source/../../apps/mesh_object --help usage: mesh_object [-h] [-s SESSION_ID] [--all] [--visualize] [--db_type DB_TYPE] [--db_root DB_ROOT_URL] [--db_collection DB_COLLECTION] [--commit] [--niter ITERATIONS] [--shell] [--gui] [--logfile LOGFILE] [--graphviz] [--dotfile DOTFILE] [--stats] Computes a surface mesh of an object in the database optional arguments: -h, --help show this help message and exit -s SESSION_ID, --session_id SESSION_ID The session id to reconstruct. --all Compute meshes for all possible sessions. --visualize Turn on visualization Database Parameters: --db_type DB_TYPE The type of database used: one of [CouchDB]. Default: CouchDB --db_root DB_ROOT_URL The database root URL to connect to. Default: http://localhost:5984 --db_collection DB_COLLECTION The database root URL to connect to. Default: object_recognition --commit Commit the data to the database.

3)Web接口

重建也提供了一个Web接口,可以可视化不同的mesh。在所建的文件夹中运行: make or_web_ui 然后在http://localhost:5984/or_web_ui/_design/viewer/index.html可视化mesh。 4)技巧

在meshlab里将彩色点云创建一个特征显著的mesh

35 / 36

http://www.youtube.com/watch?v=JzmODsVQV7w(打不开?)

36 / 36