上一段時間安裝測試了linemod的ROS程序包,跑了一下,使用的是kinec v2 ,安裝過程也是很麻煩,出現了很怪異的問題,具體據說是因爲kinect的分辨率問題導致的,實際上還有一個因爲mesa庫的問題導致的。具體看下面吧~
安裝過程主要是參考了
https://blog.techbridge.cc/2016/05/14/ros-object-recognition-kitchen/
http://wg-perception.github.io/ork_tutorials/tutorial03/tutorial.html#setup-the-working-environment
http://wg-perception.github.io/object_recognition_core/install.html#install 官方教程
這兩個教程,ORK Object Recognition Kitchen 物體識別程序包,裏面集成了很多物體識別的C++開源算法,我們主要是使用目前效果較好,較爲常用的linemod算法。主要看一下這個包的安裝過程與配置。我使用的是源代碼安裝的過程,推薦源安裝,因爲到最後,確實出現了問題,在修改了源代碼之後,才解決問題。
1.在catkin_ws/src下建立ORK包,並cd進入其中,執行:
git clone http://github.com/wg-perception/object_recognition_core
git clone http://github.com/wg-perception/capture
git clone http://github.com/wg-perception/reconstruction
git clone http://github.com/wg-perception/linemod
git clone http://github.com/wg-perception/ork_renderer
git clone http://github.com/wg-perception/tabletop
git clone http://github.com/wg-perception/tod
git clone http://github.com/wg-perception/transparent_objects
2.安裝關於ROS的東西
git clone http://github.com/wg-perception/object_recognition_msgs
git clone http://github.com/wg-perception/object_recognition_ros
git clone http://github.com/wg-perception/object_recognition_ros_visualization
3.推到catkin_ws執行catkin_make 注意最好先執行
rosdep check --from-paths /home/zzurobotics/catkin_ws/src/ork --ignore-src
rosdep install --from-paths /home/zzurobotics/catkin_ws/src/ork --ignore-src
會自動檢查相關程序包的依賴關係,並且安裝。
出現錯誤的時候,只要再次輸入catkin_make 執行編譯,就會繼續進行下去,如果有些錯誤始終存在,就需要執行上面的兩句話了。
Linemod算法程序包是一個相對獨立的程序包,需要單獨安裝一下,但是安裝之後,根據指令啓動之後,並不能使用,表現是,電腦變得很卡,然後終端拋出錯誤,節點終止。總共出現的問題有兩個
這是第一個,解決之後,會出現第二個
問題1的原因是關於mesa庫的問題導致的,簡單給出解決方法是,修改ork_renderer程序包中的CMakeList.txt文件。將mesa的方法替換爲GLUT
之後再編譯就行了,參考https://github.com/JimmyDaSilva/ork_renderer/commit/4bdd53e3c418e7d02be0212ece04598619b4323a
問題2的原因是因爲kinectV2的特殊分辨率導致的,具體的修改辦法是
參考 https://github.com/wg-perception/linemod/issues/28,這個問題需要修改linemod程序包的源文件,以及linemod包中conf文件夾下的training.ork配置文件,修改如下所示
至此,就能正常運行linemod算法了。
使用linemod算法步驟:上面的步驟完成之後,還不能用,他只是裝好了ork相關的東西,但是linemod算法是基於模板匹配的算法,所以可以想到,肯定要有一個已知的模型,而且好要針對它進行訓練纔可以識別。
首先安裝模板對比庫
sudo apt-get install couchdb
添加可樂罐模型
rosrun object_recognition_core object_add.py -n "coke " -d "A universal can of coke" --commit
點擊下面鏈接查看模型是否建立和物體的ID編號http://localhost:5984/_utils/database.html?object_recognition/_design/objects/_view/by_object_name
上面只是建立了編號,還沒有模型,現在要指定並提供模型文件,下載官方的教程包,裏面有一個可樂罐的stl模型。
git clone https://github.com/wg-perception/ork_tutorials
cd .. && catkin_make
向數據庫添加模型
rosrun object_recognition_core mesh_add.py 0be612246c9b0a00baaa4adefb0009eb /home/rosindigo/catkin_ws/src/ork_tutorials/data/coke.stl --commit
1.啓動kinect驅動節點
roslaunch kinect2_bridge kinect2_bridge.launch publish_tf:=true reg_method:=opencl //啓動kinect節點
2.映射話題節點
rosrun topic_tools relay /kinect2/qhd/image_depth_rect /camera/depth_registered/image_raw
rosrun topic_tools relay /kinect2/qhd/image_color_rect /camera/rgb/image_rect_color
rosrun topic_tools relay /kinect2/qhd/camera_info /camera/rgb/camera_info
rosrun topic_tools relay /kinect2/qhd/camera_info /camera/depth_registered/camera_info
rosrun topic_tools relay /kinect2/qhd/points /camera/depth_registered/points
rosrun tf static_transform_publisher 0 0 0 0 0 0 kinect2_ir_opticalrame camera_depth_optical_frame 40
3.啓動識別節點
rosrun object_recognition_core detection -c `rospack find object_recognition_linemod`/conf/detection.ros.ork
4.啓動rviz
最終識別結果中可樂罐位姿和實際位置有偏差,並且不斷在跳躍,不知道爲什麼,在網上查到很多人都有這個問題,不知道是不是和kinect內參標定有關係,但是可以看到識別的可信度一直在93%左右。
我也貼上我的節點圖
也可以參考這位同學的呀~
https://blog.csdn.net/weixin_40799950/article/details/81911877