ROS學習筆記14 —— moveit配置及配置結果解析

在這裏插入圖片描述
概念:https://moveit.ros.org/documentation/concepts/

MoveIt! Setup Assistant

roslaunch moveit_setup_assistant setup_assistant.launch
  • Virtual Joints:可理解爲連接機器人和世界的關節,Child Link一般選擇機器人基座base
    在這裏插入圖片描述
    type類型:

    • Fixed
    • Floating(浮動基座):例如人形機器人
    • Planar(平面移動):例如youbot、PR2
  • Planning Groups:
    在這裏插入圖片描述
    Kin. Search Resolution: 關節空間的採樣密度
    Kin. Search TImeout: 求解時間

  • End Effectors:配置手爪控制器
    在這裏插入圖片描述

  • Passive Joints:被動關節

配置結果分析


miracle@miracle-robot:~/Desktop/catkin_moveit_config_ws$ tree
.
└── src
    ├── CMakeLists.txt -> /opt/ros/melodic/share/catkin/cmake/toplevel.cmake
    ├── lwr_description
    │   ├── CMakeLists.txt
    │   ├── package.xml
    │   └── urdf
    │       └── lwr_simplified.urdf
    └── lwr_moveit_config
        ├── CMakeLists.txt
        ├── config
        │   ├── chomp_planning.yaml
        │   ├── fake_controllers.yaml
        │   ├── joint_limits.yaml
        │   ├── kinematics.yaml
        │   ├── lwr.srdf
        │   ├── ompl_planning.yaml
        │   ├── ros_controllers.yaml
        │   └── sensors_3d.yaml
        ├── launch
        │   ├── chomp_planning_pipeline.launch.xml
        │   ├── default_warehouse_db.launch
        │   ├── demo_gazebo.launch
        │   ├── demo.launch
        │   ├── fake_moveit_controller_manager.launch.xml
        │   ├── gazebo.launch
        │   ├── joystick_control.launch
        │   ├── lwr_moveit_controller_manager.launch.xml
        │   ├── lwr_moveit_sensor_manager.launch.xml
        │   ├── move_group.launch
        │   ├── moveit.rviz
        │   ├── moveit_rviz.launch
        │   ├── ompl_planning_pipeline.launch.xml
        │   ├── planning_context.launch
        │   ├── planning_pipeline.launch.xml
        │   ├── ros_controllers.launch
        │   ├── run_benchmark_ompl.launch
        │   ├── sensor_manager.launch.xml
        │   ├── setup_assistant.launch
        │   ├── trajectory_execution.launch.xml
        │   ├── warehouse.launch
        │   └── warehouse_settings.launch.xml
        └── package.xml

6 directories, 36 files

重要文件功能說明

demo.launch
  1. 可設置啓用數據,數據庫路徑,調試模式
  2. 載入URDF, SRDF and other .yaml等配置文件
  3. 如果有需要,發佈靜態的tf. 如你的機器人基座不在世界座標的原點,你可以發佈一個靜態tf來描述機器人在世界座標中的位置.
  4. 發佈虛擬機器人狀態
  5. 發佈關節狀態
  6. 運行基本的move_group節點
  7. 運行Rviz和載入默認配置,查看move_group節點狀態
  8. 如果數據庫模式激活,啓動mongodb.
move_group.launch
  1. 載入規劃的上下文配置文件
  2. 是否開啓調試模式
  3. move_group節點設置
  4. 規劃庫設置, 這裏使用ompl運動規劃庫
  5. 軌跡執行功能
  6. 傳感器功能
  7. 啓動move_group節點和action服務器端
planning_context.launch
  1. 載入URDF文件
  2. 載入SRDF文件
  3. 載入關節限制參數
  4. 載入默認的運動學求解設置
setup_assistant.launch
  • 修改現有配置
  • roslaunch lwr_moveit_config setup_assistant.launch

config

  • fake_controllers.yaml:虛擬控制器配置文件,可在無設備情況下運行moveit(包括不啓動gazebo等仿真工具)
  • joint_limits.yaml:各關節位置速度等限制,用於規劃當中
  • kinematics.yaml:運動學求解器的配置文件
  • lwr.srdf:Moveit的配置文件,包含了我們在Setup Assistant中設置的東西。只要有srdf和urdf,即可完全定義一個機器人的moveit信息
  • ompl_planning.yaml:配置了OMPL算法的參數
  • chomp_planning.yaml:配置了與planning相關的參數,如最大迭代次數、最大求解次數等信息
  • ros_controllers.yaml:配置控制器信息,常見控制器見下:傳送門
    在這裏插入圖片描述

關於ros_control的使用參見:傳送門1&傳送門2

launch

  • demo.launch:包含了其他launch文件,同時啓動需要啓動的節點

    <launch>
    
      <!-- 指定planning pipeline -->
      <arg name="pipeline" default="ompl" />
    
      <!-- 默認情況下,我們不啓動數據庫(它可能很大) -->
      <arg name="db" default="false" />
      <!-- 允許用戶指定數據庫位置 -->
      <arg name="db_path" default="$(find lwr_moveit_config)/default_warehouse_mongo_db" />
    
      <!-- 默認情況下,我們不處於調試模式 -->
      <arg name="debug" default="false" />
    
      <!--
      默認情況下,隱藏joint_state_publisher's GUI
    
      MoveIt!的“demo”模式將實際的機器人驅動程序替換爲joint_state_publisher。
      後者維護併發布了模擬機器人的當前關節配置。
      It also provides a GUI to move the simulated robot around "manually".
      這相當於在不使用MoveIt的情況下在真實的機器人周圍移動。
      -->
      <arg name="use_gui" default="false" />
    
      <!-- 在參數服務器上加載URDF,SRDF和其他.yaml配置文件 -->
      <include file="$(find lwr_moveit_config)/launch/planning_context.launch">
        <arg name="load_robot_description" value="true"/>
      </include>
    
      <!-- 如果需要,爲robot root發佈 static tf,當機器人基座不是世界座標系原點時,可通過發佈static tf來描述機器人在世界座標系中的位置 -->
      
    
      <!-- 我們沒有連接機器人,因此請發佈虛擬機器人狀態-->
      <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher">
        <param name="use_gui" value="$(arg use_gui)"/>
        <rosparam param="source_list">[move_group/fake_controller_joint_states]</rosparam>
      </node>
    
      <!-- 給定已發佈的joint states, 發佈tf for the robot links -->
      <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" respawn="true" output="screen" />
    
      <!-- 運行主MoveIt! 無需軌跡執行的可執行文件(默認情況下,我們沒有配置控制器) -->
      <include file="$(find lwr_moveit_config)/launch/move_group.launch">
        <arg name="allow_trajectory_execution" value="true"/>
        <arg name="fake_execution" value="true"/>
        <arg name="info" value="true"/>
        <arg name="debug" value="$(arg debug)"/>
        <arg name="pipeline" value="$(arg pipeline)"/>
      </include>
    
      <!-- 運行Rviz並加載默認配置以查看move_group節點的狀態 -->
      <include file="$(find lwr_moveit_config)/launch/moveit_rviz.launch">
        <arg name="rviz_config" value="$(find lwr_moveit_config)/launch/moveit.rviz"/>
        <arg name="debug" value="$(arg debug)"/>
      </include>
    
      <!-- 如果啓用了數據庫加載,請同時啓動mongodb -->
      <include file="$(find lwr_moveit_config)/launch/default_warehouse_db.launch" if="$(arg db)">
        <arg name="moveit_warehouse_database_path" value="$(arg db_path)"/>
      </include>
    
    </launch>
    
  • move_group.launch:啓動規劃組,默認使用ompl運動規劃庫

    <launch>
    
      <!-- GDB Debug Option -->
      <arg name="debug" default="false" />
      <arg unless="$(arg debug)" name="launch_prefix" value="" />
      <arg     if="$(arg debug)" name="launch_prefix"
    	   value="gdb -x $(find lwr_moveit_config)/launch/gdb_settings.gdb --ex run --args" />
    
      <!-- Verbose Mode Option -->
      <arg name="info" default="$(arg debug)" />
      <arg unless="$(arg info)" name="command_args" value="" />
      <arg     if="$(arg info)" name="command_args" value="--debug" />
    
      <!-- move_group 設置 -->
      <arg name="pipeline" default="ompl" />
      <arg name="allow_trajectory_execution" default="true"/>
      <arg name="fake_execution" default="false"/>
      <arg name="max_safe_path_cost" default="1"/>
      <arg name="jiggle_fraction" default="0.05" />
      <arg name="publish_monitored_planning_scene" default="true"/>
    
      <arg name="capabilities" default=""/>
      <arg name="disable_capabilities" default=""/>
      <!--加載這些非默認的MoveGroup功能(以空格分隔) -->
      <!--
      <arg name="capabilities" value="
                    a_package/AwsomeMotionPlanningCapability
                    another_package/GraspPlanningPipeline
                    " />
      -->
    
      <!-- 禁止使用這些默認的MoveGroup功能(以空格分隔) -->
      <!--
      <arg name="disable_capabilities" value="
                    move_group/MoveGroupKinematicsService
                    move_group/ClearOctomapService
                    " />
      -->
    
      <arg name="load_robot_description" default="true" />
      <!-- 加載URDF,SRDF和joint_limits配置 -->
      <include file="$(find lwr_moveit_config)/launch/planning_context.launch">
        <arg name="load_robot_description" value="$(arg load_robot_description)" />
      </include>
    
      <!-- Planning Functionality -->
      <include ns="move_group" file="$(find lwr_moveit_config)/launch/planning_pipeline.launch.xml">
        <arg name="pipeline" value="$(arg pipeline)" />
      </include>
    
      <!-- Trajectory Execution Functionality -->
      <include ns="move_group" file="$(find lwr_moveit_config)/launch/trajectory_execution.launch.xml" if="$(arg allow_trajectory_execution)">
        <arg name="moveit_manage_controllers" value="true" />
        <arg name="moveit_controller_manager" value="lwr" unless="$(arg fake_execution)"/>
        <arg name="moveit_controller_manager" value="fake" if="$(arg fake_execution)"/>
      </include>
    
      <!-- Sensors Functionality -->
      <include ns="move_group" file="$(find lwr_moveit_config)/launch/sensor_manager.launch.xml" if="$(arg allow_trajectory_execution)">
        <arg name="moveit_sensor_manager" value="lwr" />
      </include>
    
      <!-- 啓動實際的move_group node/action server -->
      <node name="move_group" launch-prefix="$(arg launch_prefix)" pkg="moveit_ros_move_group" type="move_group" respawn="false" output="screen" args="$(arg command_args)">
        <!-- 設置display變量,以防內部使用OpenGL代碼 -->
        <env name="DISPLAY" value="$(optenv DISPLAY :0)" />
    
        <param name="allow_trajectory_execution" value="$(arg allow_trajectory_execution)"/>
        <param name="max_safe_path_cost" value="$(arg max_safe_path_cost)"/>
        <param name="jiggle_fraction" value="$(arg jiggle_fraction)" />
        <param name="capabilities" value="$(arg capabilities)"/>
        <param name="disable_capabilities" value="$(arg disable_capabilities)"/>
    
    
        <!-- 發佈physical robot的計劃場景,以便rviz插件可以知道actual robot -->
        <param name="planning_scene_monitor/publish_planning_scene" value="$(arg publish_monitored_planning_scene)" />
        <param name="planning_scene_monitor/publish_geometry_updates" value="$(arg publish_monitored_planning_scene)" />
        <param name="planning_scene_monitor/publish_state_updates" value="$(arg publish_monitored_planning_scene)" />
        <param name="planning_scene_monitor/publish_transforms_updates" value="$(arg publish_monitored_planning_scene)" />
      </node>
    
    </launch>
    
  • planning_context.launch

    <launch>
      <!-- 默認情況下,我們不會覆蓋URDF。 將以下內容更改爲true以更改默認行爲 -->
      <arg name="load_robot_description" default="false"/>
    
      <!-- 加載URDF的參數名稱 -->
      <arg name="robot_description" default="robot_description"/>
    
      <!-- 加載通用機器人描述格式(URDF) -->
      <param if="$(arg load_robot_description)" name="$(arg robot_description)" textfile="$(find lwr_description)/urdf/lwr_simplified.urdf"/>
    
      <!-- 對應於URDF的語義描述 -->
      <param name="$(arg robot_description)_semantic" textfile="$(find lwr_moveit_config)/config/lwr.srdf" />
    
      <!-- 加載更新的關節極限(來自yaml的替代信息) -->
      <group ns="$(arg robot_description)_planning">
        <rosparam command="load" file="$(find lwr_moveit_config)/config/joint_limits.yaml"/>
      </group>
    
      <!-- 加載運動學的默認設置; 這些設置被節點名稱空間中的設置覆蓋 -->
      <group ns="$(arg robot_description)_kinematics">
        <rosparam command="load" file="$(find lwr_moveit_config)/config/kinematics.yaml"/>
      </group>
    
    </launch>
    
  • setup_assistant.launch:用來修改配置(基於當前文件)

    roslaunch lwr_moveit_config setup_assistant.launch
    

其他文件的解析:

  • demo.launch
    • move_group.launch
      • trajectory_execution.launch.xml
        • $(arg moveit_controller_manager)_moveit_controller_manager.launch.xml

修改配置文件以滿足實際機器人

大多數時候我們會直接自己寫相關的launch文件和yaml文件,原理同下:

config

  • controllers.yaml:根據實際驅動中的action修改,主要配置action的名字、類型及關節名字

  • sensors.yaml:主要定義了點雲消息名稱、OctoMap屬性等(根據需要添加)

launch

  • 機器人的啓動文件(drive)
  • robotName_moveit_controller_manager.launch:加載controller.yaml文件,併發布正確的action
  • robotName_sensor_manager.launch:作用同上,只不過加載的是傳感器的controller
  • 其他
    如industrial_robot_simulator、warehouse、joystick、規劃器、規劃算法庫等

具體操作如下:

  • ① 將demo.launch中的fake_execution修改爲false

      <!-- 運行主MoveIt! 無需軌跡執行的可執行文件(默認情況下,我們沒有配置控制器) -->
      <include file="$(find lwr_moveit_config)/launch/move_group.launch">
        <arg name="allow_trajectory_execution" value="true"/>
        <arg name="fake_execution" value="false"/>      <!--修改此處爲false-->
        <arg name="info" value="true"/>
        <arg name="debug" value="$(arg debug)"/>
        <arg name="pipeline" value="$(arg pipeline)"/>
      </include>
    

    同時要註釋一下代碼:

      <!-- 我們沒有連接機器人,因此請發佈虛擬機器人狀態-->
    <!--
      <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher">
        <param name="use_gui" value="$(arg use_gui)"/>
        <rosparam param="source_list">[move_group/fake_controller_joint_states]</rosparam>
      </node>
    -->
    

    這是一段發佈模擬狀態的代碼,如果不註釋掉這段代碼,rviz中顯示的機械臂狀態會不斷的跳變,這是真是機器人與虛擬機器人衝突的結果!

  • ②修改move_group.launchmoveit_controller_manager的參數

      <!-- Trajectory Execution Functionality -->
      <!-- moveit_controller_manager的值,要麼等於我們設置的,要麼等於fake,接下來此參數會傳給trajectory_execution.launch.xml文件 -->
      <include ns="move_group" file="$(find lwr_moveit_config)/launch/trajectory_execution.launch.xml" if="$(arg allow_trajectory_execution)">
        <arg name="moveit_manage_controllers" value="true" />
        <arg name="moveit_controller_manager" value="lwr" unless="$(arg fake_execution)"/><!--unless前的value改爲自己的機器人名稱,作爲前綴-->
        <arg name="moveit_controller_manager" value="fake" if="$(arg fake_execution)"/>
      </include>
    

    打開trajectory_execution.launch.xml發現最後有一句:

      <include file="$(find lwr_moveit_config)/launch/$(arg moveit_controller_manager)_moveit_controller_manager.launch.xml" />
    

    按照原先的設置,本應該啓動fake_moveit_controller_manager.launch.xml,你可以去moveit配置文件夾下去找,這個文件是存在的,而現在一個叫做lwr_moveit_controller_manager.launch.xml將會被啓動,而這個文件moveit也應該已經幫你創建好了,當你使用先前的moveit嚮導加載機器人模型時,機器人模型中寫明的機器人名稱(name屬性),就會作爲前綴寫入這個文件的文件名,所以,“lwr”這個名稱源自於你模型文件裏寫明的機器人名稱,請前後保持統一,理解各個文件之間的調用關係。

    如果執行軌跡時,軌跡執行時間超時,如下錯誤(圖片轉自博主愛學習的草莓熊):
    在這裏插入圖片描述
    解決方案如下:

    • 方案1: 增加參數以延長允許執行軌跡的時間,通過加入如下參數設置
      	<!--允許軌跡執行時間的一個放大倍數,可以根據實際情況自行修改-->
      	<param name="trajectory_execution/allowed_execution_duration_scaling" value="6"/>    
      	<!--超時的一個百分比範圍-->  
      	<param name="trajectory_execution/allowed_goal_duration_margin" value="0.5"/>
      
    • 方案2:關閉軌跡執行情況的一個monitoring,通過加入如下參數設置
      <param name="trajectory_execution/execution_duration_monitoring" value="false"/>
      
  • ③ 修改lwr_moveit_controller_manager.launch.xml

    <launch>
    
      <!-- 在參數服務器上加載moveit_controller_manager作爲參數
         如果沒有傳遞任何參數,將設置moveit_simple_controller_manager -->
      <arg name="moveit_controller_manager" default="moveit_simple_controller_manager/MoveItSimpleControllerManager" />
      <param name="moveit_controller_manager" value="$(arg moveit_controller_manager)"/>
    
      <!-- 將ros_controllers加載到參數服務器 -->
      <rosparam file="$(find lwr_moveit_config)/config/ros_controllers.yaml"/>
    
    </launch>
    

    最新版本中,助手會幫我們自動生成ros_controllers,已經不需要進行修改,或者也可以將默認的ros_controllers該爲其他自定義的xxx_controllers

  • ④ 編寫ros_controllers配置文件

    controller_list:
      - name: "lwr"
        action_ns: follow_joint_trajectory
        type: FollowJointTrajectory
        Joints:
        - lwr_arm_0_joint
        - lwr_arm_1_joint
        - lwr_arm_2_joint
        - lwr_arm_3_joint
        - lwr_arm_4_joint
        - lwr_arm_5_joint
        - lwr_arm_6_joint
    

    參數介紹:

    1. name:寫一個與自己機器人相關的名稱,便於使用
    2. action_ns:服務器名稱定義,follow_joint_trajectory即爲後續action名字的一部分,整體名稱爲:name/action_ns
    3. type:定義action的類型,FollowJointTrajectory是ros自帶action類型,是一種控制機械臂運動軌跡的數據結構,其他action類型請參考:傳送門
    4. joints:來自urdf文件中描述的關節名稱,直接複製fake_controllers.yaml中的即可!

測試

rviz中加載一個障礙物

  • 新建障礙物文件test.scene
  • Scene ObjectsImport From Text
  • Publish Scene

在這裏插入圖片描述
在這裏插入圖片描述

LWR的Moveit配置結果解析

文件級:


├── CMakeLists.txt
├── config #配置文件目錄
│ ├── fake_controllers.yaml #虛擬控制器配置文件,方便我們在沒有實體機器人,甚至沒有任何模擬器(如gazebo)開啓的情況下也能運行MoveIt
│ ├── joint_limits.yaml #記錄了機器人各個關節的位置速度加速度的極限
│ ├── kinematics.yaml #初始化運動學求解庫
│ ├── lwr.srdf #配置助手設置參數,包含組,位姿,末端執行器,虛擬關節及碰撞免測矩陣ACM等的定義。
│ └── ompl_planning.yaml #配置OMPL各種算法及參數
├── launch #啓動文件腳本目錄
│ ├── default_warehouse_db.launch #如果激活數據庫載入方式,會啓動mongodb.被demo.launch調用,
│ ├── demo.launch #啓動配置包的入口文件
│ ├── fake_moveit_controller_manager.launch.xml #調用fake_controllers.yaml
│ ├── joystick_control.launch #遊戲杆控制
│ ├── lwr_moveit_controller_manager.launch.xml #控制管理器定義,在trajectory_execution.launch.xml被調用
│ ├── lwr_moveit_sensor_manager.launch.xml #傳感器管理器定義,在sensor_manager.launch.xml被調用
│ ├── move_group.launch #move_group節點
│ ├── moveit.rviz #rviz相關參數文件
│ ├── moveit_rviz.launch #rviz啓動文件
│ ├── ompl_planning_pipeline.launch.xml #ompl規劃管道啓動,在planning_pipeline.launch.xml被調用
│ ├── planning_context.launch #載入URDF, SRDF,正向運動學求解等設置
│ ├── planning_pipeline.launch.xml #總的規劃管道啓動
│ ├── run_benchmark_ompl.launch #針對ompl庫的壓力測試,需要指定.cfg文件列表。
│ ├── sensor_manager.launch.xml #傳感器啓動文件
│ ├── setup_assistant.launch #重配置oveIt!包
│ ├── trajectory_execution.launch.xml #軌跡執行啓動文件
│ ├── warehouse.launch #運行數據庫
│ └── warehouse_settings.launch.xml #數據庫配置文件
└── package.xml



參考文獻:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章