1. 程式人生 > >ubuntu18.04+ROS-Melodic 配置moveit

ubuntu18.04+ROS-Melodic 配置moveit

 

                                                                                                持續更新......

轉載請標明出處!!!


在已經安裝ROS-melodic之後,再進行一下操作。如果你沒有安裝ROS,請務必先安裝。安裝方法可以檢視官網。

link:http://wiki.ros.org/melodic/Installation/Ubuntu


1    安裝moveit

去官網查詢安裝moveit的方式,link:http://moveit.ros.org/install/

選擇的是二進位制安裝方式:

在安裝之前先對安裝好的ROS系統更新一下,使用如下指令:

$ rosdep update

$ sudo apt-get update

$ sudo apt-get dist-upgrade

然後安裝moveit:

 $ sudo apt-get install ros-melodic-moveit

2    建立moveit的工作空間

為了區分開ROS的工作空間,新建一個ws_moveit的資料夾,作為moveit的工作空間

$ mkdir -p ws_moveit/src

然後下載教程演示的demo包到src資料夾下:

$ cd ws_moveit/src

git clone https://github.com/ros-planning/moveit_tutorials.git  #moveit_tutorials

git clone https://github.com/ros-planning/panda_moveit_config.git #panda_moveit_config模型配置包URDF的xml語法格式

然後按照官網的步驟是,執行一下指令自動配齊依賴包,

rosdep install -y --from-paths . --ignore-src --rosdistro kinetic

但是melodic現在沒有完整的這一方面的釋出包,執行會提示類似如下的錯誤資訊:


~/ws_moveit/src$ rosdep install -y --from-paths . --ignore-src --rosdistro melodic
ERROR: the following packages/stacks could not have their rosdep keys resolved
to system dependencies:
panda_moveit_config: Cannot locate rosdep definition for [franka_description]


或者:當我配好franka_description的包後,有提示下面的問題,這樣一直配置下去:

~/ws_moveit/src$ rosdep install -y --from-paths . --ignore-src --rosdistro melodic
ERROR: the following packages/stacks could not have their rosdep keys resolved
to system dependencies:
franka_visualization: Cannot locate rosdep definition for [libfranka]
franka_control: Cannot locate rosdep definition for [libfranka]
franka_hw: Cannot locate rosdep definition for [libfranka]
franka_example_controllers: Cannot locate rosdep definition for [libfranka]
franka_gripper: Cannot locate rosdep definition for [libfranka]

 


最後,總結:在下載好moveit_tutorials和模型配置包panda_moveit_config後,繼續在github上下載以下幾個包,解壓到src資料夾下,這樣手動配置以下這些melodic沒法自動配置的依賴包,然後繼續執行上面的命令就可以了!!

The following NEW packages will be installed:
  ros-melodic-nodelet ros-melodic-nodelet-topic-tools ros-melodic-pcl-ros
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/4,199 kB of archives.
After this operation, 23.9 MB of additional disk space will be used.
Selecting previously unselected package ros-melodic-nodelet.
(Reading database ... 288004 files and directories currently installed.)
Preparing to unpack .../ros-melodic-nodelet_1.9.16-0bionic.20180906.224839_amd64.deb ...
Unpacking ros-melodic-nodelet (1.9.16-0bionic.20180906.224839) ...
Selecting previously unselected package ros-melodic-nodelet-topic-tools.
Preparing to unpack .../ros-melodic-nodelet-topic-tools_1.9.16-0bionic.20180906.235625_amd64.deb ...
Unpacking ros-melodic-nodelet-topic-tools (1.9.16-0bionic.20180906.235625) ...
Selecting previously unselected package ros-melodic-pcl-ros.
Preparing to unpack .../ros-melodic-pcl-ros_1.6.2-0bionic.20180907.005643_amd64.deb ...
Unpacking ros-melodic-pcl-ros (1.6.2-0bionic.20180907.005643) ...
Setting up ros-melodic-nodelet (1.9.16-0bionic.20180906.224839) ...
Setting up ros-melodic-nodelet-topic-tools (1.9.16-0bionic.20180906.235625) ...
Setting up ros-melodic-pcl-ros (1.6.2-0bionic.20180907.005643) ...
#All required rosdeps installed successfully

因為配置資訊太長,就直接去最後提示成功的資訊了。


                              

最終src中是這些PKG,按照名字下載即可:

franka_ros:  https://github.com/frankaemika/franka_ros

libfranka:  https://github.com/frankaemika/libfranka-release/tree/release/kinetic/libfranka

moveit_visual_tools:    https://github.com/PickNikRobotics/moveit_visual_tools/tree/melodic-devel

注意一定要配齊每一個包的依賴關係:然後才不會編譯出錯!!!如果不知道怎麼配置每一個包各自的依賴包,請檢視我之前的一片文章學習一下:

link:    https://blog.csdn.net/SimileciWH/article/details/81332199

3    開始編譯moveit的包

執行以下指令:

cd ws_moveit
###catkin config --extend /opt/ros/melodic  #不要執行官網寫的這一行,下面我會解釋
catkin build

###catkin config --extend /opt/ros/melodic這一行是設定catkin編譯構建的環境目錄,對於melodic版本如果使用了,則預設的catkin構建目錄就不在是你ROS的那個工作目錄,全部非二進位制安裝的包,或者你為ROS寫的包,如果在move'it的使用find package去搜這些包,都會找不到,因為這一句講catkin的搜尋目錄設定在了安裝ROS的目錄。當然你可以自己新增,這裡避免不必要的麻煩,我不推薦執行這一句指令!!!

3.1   在執行catkin build時提示,

1)[missing] /home/simileciwh/ws_moveit/logs
2)[missing] /home/simileciwh/ws_moveit/build   )

3)[missing] /home/simileciwh/ws_moveit/devel

這是因為我們沒有在工作空間建立Log,Build,Devel三個資料夾,執行這個之後會自動建立,繼續執行build命令

3.2  提示:/ws_moveit/src/moveit_tutorials-kinetic-devel/doc/pick_place/src/pick_place_tutorial.cpp:94:43: error: ‘tf’ has not been declared

點開/ws_moveit/src/moveit_tutorials-kinetic-devel/doc/pick_place/src/pick_place_tutorial.cpp檔案後發現確實沒有加入標頭檔案tf.h所以在檔案開頭,新增即可解決錯誤

include  <tf/tf.h>


至此構建成功!!!

~/ws_moveit$ catkin build 
---------------------------------------------------------------
Profile:                     default
Extending:        [explicit] /home/simileciwh/catkin_ws/devel
Workspace:                   /home/simileciwh/ws_moveit
---------------------------------------------------------------
Source Space:       [exists] /home/simileciwh/ws_moveit/src
Log Space:          [exists] /home/simileciwh/ws_moveit/logs
Build Space:        [exists] /home/simileciwh/ws_moveit/build
Devel Space:        [exists] /home/simileciwh/ws_moveit/devel
Install Space:      [unused] /home/simileciwh/ws_moveit/install
DESTDIR:            [unused] None
---------------------------------------------------------------
Devel Space Layout:          linked
Install Space Layout:        None
---------------------------------------------------------------
Additional CMake Args:       -DCMAKE_BUILD_TYPE=Release
Additional Make Args:        None
Additional catkin Make Args: None
Internal Make Job Server:    True
Cache Job Environments:      False
---------------------------------------------------------------
Whitelisted Packages:        None
Blacklisted Packages:        None
---------------------------------------------------------------
Workspace configuration appears valid.
---------------------------------------------------------------
[build] Found '12' packages in 0.0 seconds.                                              
[build] Package table is up to date.                                                     
Starting  >>> franka_description                                                         
Starting  >>> franka_msgs                                                                
Starting  >>> libfranka                                                                  
Starting  >>> moveit_visual_tools                                                        
Finished  <<< franka_description                        [ 0.2 seconds ]                  
Starting  >>> panda_moveit_config                                                        
Finished  <<< moveit_visual_tools                       [ 0.3 seconds ]                  
Finished  <<< panda_moveit_config                       [ 0.2 seconds ]                  
Starting  >>> moveit_tutorials                                                           
Finished  <<< franka_msgs                               [ 0.6 seconds ]                  
Finished  <<< moveit_tutorials                          [ 37.9 seconds ]                 
Finished  <<< libfranka                                 [ 4 minutes and 3.4 seconds ]    
Starting  >>> franka_gripper                                                             
Starting  >>> franka_hw                                                                  
Starting  >>> franka_visualization                                                       
Finished  <<< franka_visualization                      [ 13.2 seconds ]                 
Finished  <<< franka_hw                                 [ 16.0 seconds ]                 
Finished  <<< franka_gripper                            [ 38.5 seconds ]                 
Starting  >>> franka_control                                                             
Finished  <<< franka_control                            [ 22.3 seconds ]                 
Starting  >>> franka_example_controllers                                                 
Finished  <<< franka_example_controllers                [ 38.6 seconds ]                 
[build] Summary: All 11 packages succeeded!                                              
[build]   Ignored:   1 packages were skipped or are blacklisted.                         
[build]   Warnings:  None.                                                               
[build]   Abandoned: None.                                                               
[build]   Failed:    None.                                                               
[build] Runtime: 5 minutes and 43.1 seconds total.                                       
[build] Note: Workspace packages have changed, please re-source setup files to use them.

4    將編譯好的包加入到環境中

$ source ~/ws_moveit/devel/setup.bash

也可以直接新增到.bashrc檔案中,讓其在開啟新的終端時自動載入環境

$ echo 'source ~/ws_moveit/devel/setup.bash' >> ~/.bashrc

 

5    執行效果

執行以下命令執行demo:

$ roslaunch panda_moveit_config demo.launch rviz_tutorial:=true

最終結果,如下所示:

                     

                               !!!!!在此之前,需要先設定一下RVIZ,否則什麼都不會顯示的!!!!!!                               

設定如下:

(1)點選開啟的空白rviz視窗左側的add按鈕,找到MotionPlanning,確定。如下圖所示:

設定完成,會看到下圖內容:

繼續設定:

在“Global Options”標籤處,子視窗“Displays”選項卡,設定 Fixed Frame為/panda_link0

然後點選“MotionPlanning”標籤,找到如下顯示的標籤,做修改:

Robot Description---->設定成robot_description

 Planning Scene Topic---->設定成/planning_scene

Planning Request---->設定成panda_arm

Planned Path---->設定成/move_group/display_planned_path

完成這些全部設定,就和我的截圖一樣效果了。

可以參考官網繼續完後設計了:

link:https://ros-planning.github.io/moveit_tutorials/doc/quickstart_in_rviz/quickstart_in_rviz_tutorial.html

updating