ROS kinetic + Realsens D435i + ORK + LINEMOD 物体识别

 

1. ORK

网址:https://wg-perception.github.io/object_recognition_core/

ORK (Object Recognition Kitchen) 是 ROS 集成的物体识别库,当前 Kinetic 版本的 ROS 只集成了部分功能包的二进制安装文件,所以需通过源码编译安装。

  • 安装依赖库
sudo apt-get install meshlab
sudo apt-get install libosmesa6-dev
sudo apt-get install python-pyside.qtcore
sudo apt-get install python-pyside.qtgui
  • 创建工作空间,下载功能包源码,编译
mkdir ork_ws && cd ork_ws
wstool init src https://raw.github.com/wg-perception/object_recognition_core/master/doc/source/ork.rosinstall.kinetic.plus
cd src && wstool update -j8
cd .. && rosdep install --from-paths src -i -y
catkin_make
  • 设置环境变量
echo "export ~/ork_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc

 

2. CouchDB 建立模型库

ORK 中的 LINEMOD 算法基于模板匹配,需要建立已知物体的数据模型,根据采集的信息逐一匹配,找到与数据库中匹配的物体。首先,用 CouchDB 工具创建数据库:

  • 安装
sudo apt-get install couchdb
  • 测试是否安装成功,如图所示,说明安装成功
curl -X GET http://localhost:5984

  • 在数据库中创建一条可乐罐模型的数据
rosrun object_recognition_core object_add.py -n "coke " -d "A universal can of coke" --commit
git clone https://github.com/wg-perception/ork_tutorials
  • 将 coke.stl 模型加载到数据中
rosrun object_recognition_core mesh_add.py bb01ae7a23033bdef1a1c3b76000092c ~/ork_ws/src/ork_tutorials/data/coke.stl --commit
  • 再次在浏览器中打开上面的网址,如下图所示

  • 安装 couchapp 工具,在浏览器中查看具体的模型
sudo pip install git+https://github.com/couchapp/couchapp.git
rosrun object_recognition_core push.sh
  • 在浏览器中查看 

 

 

 

3. 模型训练

rosrun object_recognition_core training -c `rospack find object_recognition_linemod`/conf/training.ork

训练完如下图所示

 

4. 物体识别

  • 启动 realsense d435i 相机
roslaunch realsense2_camera rs_camera.launch filters:=pointcloud

参考:https://github.com/IntelRealSense/realsense-ros

  • 运行下述命令,进行物体检测
rosrun object_recognition_core detection -c  `rospack find object_recognition_linemod`/conf/detection.ros.ork

我们发现,detection.ros.ork 订阅了下面几个话题:

realsense 发布的对应的话题为:

/camera/depth/camera_info
/camera/depth/image_rect_raw
/camera/color/camera_info
/camera/color/image_raw

因此需要用 topic_tools relay 做话题映射,如下所示:

rosrun topic_tools relay /camera/depth/camera_info    /camera/depth_registered/camera_info
rosrun topic_tools relay /camera/depth/image_rect_raw    /camera/depth_registered/image_raw
rosrun topic_tools relay /camera/color/camera_info    /camera/rgb/icamera_info
rosrun topic_tools relay /camera/color/image_raw   /camera/rgb/image_rect_color

但每次都做映射太麻烦,干脆修改一下 detection.ros.ork 订阅的话题名:

gedit `rospack find object_recognition_linemod`/conf/detection.ros.ork

修改如下:

  • 做完话题映射或上述设置后,再次运行 detection 命令:
rosrun object_recognition_core detection -c  `rospack find object_recognition_linemod`/conf/detection.ros.ork

此时会出现下图所示信息:

  • 打开 rviz 查看
    • 添加 Pointcloud2,选择话题 /camera/depth/color/points
    • 添加 OrkObject,选择话题 /recognized_object_array (若能够成功识别,则会发布此话题)

 

  • 查看   /recognized_object_array 话题的实时内容
rostopic echo /recognized_object_array

  • 查看节点图
rqt_graph

 

 

 

参考:

[1]. 官网:https://wg-perception.github.io/object_recognition_core/install.html#install

[2]. 《ROS机器人开发实践》胡春旭

[3].  https://blog.csdn.net/weixin_40799950/article/details/81911877

[4].  https://blog.techbridge.cc/2016/05/14/ros-object-recognition-kitchen/

 

posted @ 2019-08-07 04:56  Hongkai_Ding  阅读(7429)  评论(1编辑  收藏  举报