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/

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM