ROS kinetic + Realsens D435i + ORK + LINEMOD 物體識別

 

1. ORKhtml

網址:https://wg-perception.github.io/object_recognition_core/python

ORK (Object Recognition Kitchen) 是 ROS 集成的物體識別庫,當前 Kinetic 版本的 ROS 只集成了部分功能包的二進制安裝文件,因此需經過源碼編譯安裝。git

  • 安裝依賴庫
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 創建模型庫github

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. 物體識別bash

  • 啓動 realsense d435i 相機
roslaunch realsense2_camera rs_camera.launch filters:=pointcloud

參考:https://github.com/IntelRealSense/realsense-rosapp

  • 運行下述命令,進行物體檢測
rosrun object_recognition_core detection -c  `rospack find object_recognition_linemod`/conf/detection.ros.ork

咱們發現,detection.ros.ork 訂閱了下面幾個話題:curl

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/

相關文章
相關標籤/搜索