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



参考文献:

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