|
码农家园
ROS学习笔记14 —— moveit配置及配置结果解析
2020-06-02
movmoveros
文章目录
- MoveIt! Setup Assistant
- 配置结果分析
- 重要文件功能说明
- demo.launch
- move_group.launch
- planning_context.launch
- setup_assistant.launch
- config
- launch
- 修改配置文件以满足实际机器人
- 测试
- LWR的Moveit配置结果解析

概念:https://moveit.ros.org/documentation/concepts/
MoveIt! Setup Assistant
1 | roslaunch moveit_setup_assistant setup_assistant.launch |
- Virtual Joints:可理解为连接机器人和世界的关节,Child Link一般选择机器人基座base

type类型:
- Fixed
- Floating(浮动基座):例如人形机器人
- Planar(平面移动):例如youbot、PR2
Kin. Search Resolution: 关节空间的采样密度
Kin. Search TImeout: 求解时间
配置结果分析
<hr/>12345678910111213141516171819202122232425262728293031323334353637383940414243444546 | <font color=&#34;#8AE234&#34;><b>miracle@miracle-robot</b></font>:<font color=&#34;#729FCF&#34;><b>~/Desktop/catkin_moveit_config_ws</b></font>$ tree<font color=&#34;#729FCF&#34;><b>.</b></font>└── <font color=&#34;#729FCF&#34;><b>src</b></font> ├── <font color=&#34;#34E2E2&#34;><b>CMakeLists.txt</b></font> -> /opt/ros/melodic/share/catkin/cmake/toplevel.cmake ├── <font color=&#34;#729FCF&#34;><b>lwr_description</b></font> │ ├── CMakeLists.txt │ ├── package.xml │ └── <font color=&#34;#729FCF&#34;><b>urdf</b></font> │ └── lwr_simplified.urdf └── <font color=&#34;#729FCF&#34;><b>lwr_moveit_config</b></font> ├── CMakeLists.txt ├── <font color=&#34;#729FCF&#34;><b>config</b></font> │ ├── chomp_planning.yaml │ ├── fake_controllers.yaml │ ├── joint_limits.yaml │ ├── kinematics.yaml │ ├── lwr.srdf │ ├── ompl_planning.yaml │ ├── ros_controllers.yaml │ └── sensors_3d.yaml ├── <font color=&#34;#729FCF&#34;><b>launch</b></font> │ ├── 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.xml6 directories, 36 files |
<hr/>重要文件功能说明
demo.launch
- 可设置启用数据,数据库路径,调试模式
- 载入URDF, SRDF and other .yaml等配置文件
- 如果有需要,发布静态的tf. 如你的机器人基座不在世界坐标的原点,你可以发布一个静态tf来描述机器人在世界坐标中的位置.
- 发布虚拟机器人状态
- 发布关节状态
- 运行基本的move_group节点
- 运行Rviz和载入默认配置,查看move_group节点状态
- 如果数据库模式激活,启动mongodb.
move_group.launch
- 载入规划的上下文配置文件
- 是否开启调试模式
- move_group节点设置
- 规划库设置, 这里使用ompl运动规划库
- 轨迹执行功能
- 传感器功能
- 启动move_group节点和action服务器端
planning_context.launch
- 载入URDF文件
- 载入SRDF文件
- 载入关节限制参数
- 载入默认的运动学求解设置
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文件,同时启动需要启动的节点
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 | <launch> <!-- 指定planning pipeline --> <arg name=&#34;pipeline&#34; default=&#34;ompl&#34; /> <!-- 默认情况下,我们不启动数据库(它可能很大) --> <arg name=&#34;db&#34; default=&#34;false&#34; /> <!-- 允许用户指定数据库位置 --> <arg name=&#34;db_path&#34; default=&#34;$(find lwr_moveit_config)/default_warehouse_mongo_db&#34; /> <!-- 默认情况下,我们不处于调试模式 --> <arg name=&#34;debug&#34; default=&#34;false&#34; /> <!-- 默认情况下,隐藏joint_state_publisher&#39;s GUI MoveIt!的“demo”模式将实际的机器人驱动程序替换为joint_state_publisher。 后者维护并发布了模拟机器人的当前关节配置。 It also provides a GUI to move the simulated robot around &#34;manually&#34;. 这相当于在不使用MoveIt的情况下在真实的机器人周围移动。 --> <arg name=&#34;use_gui&#34; default=&#34;false&#34; /> <!-- 在参数服务器上加载URDF,SRDF和其他.yaml配置文件 --> <include file=&#34;$(find lwr_moveit_config)/launch/planning_context.launch&#34;> <arg name=&#34;load_robot_description&#34; value=&#34;true&#34;/> </include> <!-- 如果需要,为robot root发布 static tf,当机器人基座不是世界坐标系原点时,可通过发布static tf来描述机器人在世界坐标系中的位置 --> <!-- 我们没有连接机器人,因此请发布虚拟机器人状态--> <node name=&#34;joint_state_publisher&#34; pkg=&#34;joint_state_publisher&#34; type=&#34;joint_state_publisher&#34;> <param name=&#34;use_gui&#34; value=&#34;$(arg use_gui)&#34;/> <rosparam param=&#34;source_list&#34;>[move_group/fake_controller_joint_states]</rosparam> </node> <!-- 给定已发布的joint states, 发布tf for the robot links --> <node name=&#34;robot_state_publisher&#34; pkg=&#34;robot_state_publisher&#34; type=&#34;robot_state_publisher&#34; respawn=&#34;true&#34; output=&#34;screen&#34; /> <!-- 运行主MoveIt! 无需轨迹执行的可执行文件(默认情况下,我们没有配置控制器) --> <include file=&#34;$(find lwr_moveit_config)/launch/move_group.launch&#34;> <arg name=&#34;allow_trajectory_execution&#34; value=&#34;true&#34;/> <arg name=&#34;fake_execution&#34; value=&#34;true&#34;/> <arg name=&#34;info&#34; value=&#34;true&#34;/> <arg name=&#34;debug&#34; value=&#34;$(arg debug)&#34;/> <arg name=&#34;pipeline&#34; value=&#34;$(arg pipeline)&#34;/> </include> <!-- 运行Rviz并加载默认配置以查看move_group节点的状态 --> <include file=&#34;$(find lwr_moveit_config)/launch/moveit_rviz.launch&#34;> <arg name=&#34;rviz_config&#34; value=&#34;$(find lwr_moveit_config)/launch/moveit.rviz&#34;/> <arg name=&#34;debug&#34; value=&#34;$(arg debug)&#34;/> </include> <!-- 如果启用了数据库加载,请同时启动mongodb --> <include file=&#34;$(find lwr_moveit_config)/launch/default_warehouse_db.launch&#34; if=&#34;$(arg db)&#34;> <arg name=&#34;moveit_warehouse_database_path&#34; value=&#34;$(arg db_path)&#34;/> </include></launch> |
- move_group.launch:启动规划组,默认使用ompl运动规划库
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 | <launch> <!-- GDB Debug Option --> <arg name=&#34;debug&#34; default=&#34;false&#34; /> <arg unless=&#34;$(arg debug)&#34; name=&#34;launch_prefix&#34; value=&#34;&#34; /> <arg if=&#34;$(arg debug)&#34; name=&#34;launch_prefix&#34; value=&#34;gdb -x $(find lwr_moveit_config)/launch/gdb_settings.gdb --ex run --args&#34; /> <!-- Verbose Mode Option --> <arg name=&#34;info&#34; default=&#34;$(arg debug)&#34; /> <arg unless=&#34;$(arg info)&#34; name=&#34;command_args&#34; value=&#34;&#34; /> <arg if=&#34;$(arg info)&#34; name=&#34;command_args&#34; value=&#34;--debug&#34; /> <!-- move_group 设置 --> <arg name=&#34;pipeline&#34; default=&#34;ompl&#34; /> <arg name=&#34;allow_trajectory_execution&#34; default=&#34;true&#34;/> <arg name=&#34;fake_execution&#34; default=&#34;false&#34;/> <arg name=&#34;max_safe_path_cost&#34; default=&#34;1&#34;/> <arg name=&#34;jiggle_fraction&#34; default=&#34;0.05&#34; /> <arg name=&#34;publish_monitored_planning_scene&#34; default=&#34;true&#34;/> <arg name=&#34;capabilities&#34; default=&#34;&#34;/> <arg name=&#34;disable_capabilities&#34; default=&#34;&#34;/> <!--加载这些非默认的MoveGroup功能(以空格分隔) --> <!-- <arg name=&#34;capabilities&#34; value=&#34; a_package/AwsomeMotionPlanningCapability another_package/GraspPlanningPipeline &#34; /> --> <!-- 禁止使用这些默认的MoveGroup功能(以空格分隔) --> <!-- <arg name=&#34;disable_capabilities&#34; value=&#34; move_group/MoveGroupKinematicsService move_group/ClearOctomapService &#34; /> --> <arg name=&#34;load_robot_description&#34; default=&#34;true&#34; /> <!-- 加载URDF,SRDF和joint_limits配置 --> <include file=&#34;$(find lwr_moveit_config)/launch/planning_context.launch&#34;> <arg name=&#34;load_robot_description&#34; value=&#34;$(arg load_robot_description)&#34; /> </include> <!-- Planning Functionality --> <include ns=&#34;move_group&#34; file=&#34;$(find lwr_moveit_config)/launch/planning_pipeline.launch.xml&#34;> <arg name=&#34;pipeline&#34; value=&#34;$(arg pipeline)&#34; /> </include> <!-- Trajectory Execution Functionality --> <include ns=&#34;move_group&#34; file=&#34;$(find lwr_moveit_config)/launch/trajectory_execution.launch.xml&#34; if=&#34;$(arg allow_trajectory_execution)&#34;> <arg name=&#34;moveit_manage_controllers&#34; value=&#34;true&#34; /> <arg name=&#34;moveit_controller_manager&#34; value=&#34;lwr&#34; unless=&#34;$(arg fake_execution)&#34;/> <arg name=&#34;moveit_controller_manager&#34; value=&#34;fake&#34; if=&#34;$(arg fake_execution)&#34;/> </include> <!-- Sensors Functionality --> <include ns=&#34;move_group&#34; file=&#34;$(find lwr_moveit_config)/launch/sensor_manager.launch.xml&#34; if=&#34;$(arg allow_trajectory_execution)&#34;> <arg name=&#34;moveit_sensor_manager&#34; value=&#34;lwr&#34; /> </include> <!-- 启动实际的move_group node/action server --> <node name=&#34;move_group&#34; launch-prefix=&#34;$(arg launch_prefix)&#34; pkg=&#34;moveit_ros_move_group&#34; type=&#34;move_group&#34; respawn=&#34;false&#34; output=&#34;screen&#34; args=&#34;$(arg command_args)&#34;> <!-- 设置display变量,以防内部使用OpenGL代码 --> <env name=&#34;DISPLAY&#34; value=&#34;$(optenv DISPLAY :0)&#34; /> <param name=&#34;allow_trajectory_execution&#34; value=&#34;$(arg allow_trajectory_execution)&#34;/> <param name=&#34;max_safe_path_cost&#34; value=&#34;$(arg max_safe_path_cost)&#34;/> <param name=&#34;jiggle_fraction&#34; value=&#34;$(arg jiggle_fraction)&#34; /> <param name=&#34;capabilities&#34; value=&#34;$(arg capabilities)&#34;/> <param name=&#34;disable_capabilities&#34; value=&#34;$(arg disable_capabilities)&#34;/> <!-- 发布physical robot的计划场景,以便rviz插件可以知道actual robot --> <param name=&#34;planning_scene_monitor/publish_planning_scene&#34; value=&#34;$(arg publish_monitored_planning_scene)&#34; /> <param name=&#34;planning_scene_monitor/publish_geometry_updates&#34; value=&#34;$(arg publish_monitored_planning_scene)&#34; /> <param name=&#34;planning_scene_monitor/publish_state_updates&#34; value=&#34;$(arg publish_monitored_planning_scene)&#34; /> <param name=&#34;planning_scene_monitor/publish_transforms_updates&#34; value=&#34;$(arg publish_monitored_planning_scene)&#34; /> </node></launch> |
123456789101112131415161718192021222324 | <launch> <!-- 默认情况下,我们不会覆盖URDF。 将以下内容更改为true以更改默认行为 --> <arg name=&#34;load_robot_description&#34; default=&#34;false&#34;/> <!-- 加载URDF的参数名称 --> <arg name=&#34;robot_description&#34; default=&#34;robot_description&#34;/> <!-- 加载通用机器人描述格式(URDF) --> <param if=&#34;$(arg load_robot_description)&#34; name=&#34;$(arg robot_description)&#34; textfile=&#34;$(find lwr_description)/urdf/lwr_simplified.urdf&#34;/> <!-- 对应于URDF的语义描述 --> <param name=&#34;$(arg robot_description)_semantic&#34; textfile=&#34;$(find lwr_moveit_config)/config/lwr.srdf&#34; /> <!-- 加载更新的关节极限(来自yaml的替代信息) --> <group ns=&#34;$(arg robot_description)_planning&#34;> <rosparam command=&#34;load&#34; file=&#34;$(find lwr_moveit_config)/config/joint_limits.yaml&#34;/> </group> <!-- 加载运动学的默认设置; 这些设置被节点名称空间中的设置覆盖 --> <group ns=&#34;$(arg robot_description)_kinematics&#34;> <rosparam command=&#34;load&#34; file=&#34;$(find lwr_moveit_config)/config/kinematics.yaml&#34;/> </group></launch> |
- setup_assistant.launch:用来修改配置(基于当前文件)
1 | 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
12345678 | <!-- 运行主MoveIt! 无需轨迹执行的可执行文件(默认情况下,我们没有配置控制器) --> <include file=&#34;$(find lwr_moveit_config)/launch/move_group.launch&#34;> <arg name=&#34;allow_trajectory_execution&#34; value=&#34;true&#34;/> <arg name=&#34;fake_execution&#34; value=&#34;false&#34;/> <!--修改此处为false--> <arg name=&#34;info&#34; value=&#34;true&#34;/> <arg name=&#34;debug&#34; value=&#34;$(arg debug)&#34;/> <arg name=&#34;pipeline&#34; value=&#34;$(arg pipeline)&#34;/> </include> |
同时要注释一下代码:
1234567 | <!-- 我们没有连接机器人,因此请发布虚拟机器人状态--><!-- <node name=&#34;joint_state_publisher&#34; pkg=&#34;joint_state_publisher&#34; type=&#34;joint_state_publisher&#34;> <param name=&#34;use_gui&#34; value=&#34;$(arg use_gui)&#34;/> <rosparam param=&#34;source_list&#34;>[move_group/fake_controller_joint_states]</rosparam> </node>--> |
这是一段发布模拟状态的代码,如果不注释掉这段代码,rviz中显示的机械臂状态会不断的跳变,这是真是机器人与虚拟机器人冲突的结果!
- ②修改move_group.launch中moveit_controller_manager的参数
1234567 | <!-- Trajectory Execution Functionality --> <!-- moveit_controller_manager的值,要么等于我们设置的,要么等于fake,接下来此参数会传给trajectory_execution.launch.xml文件 --> <include ns=&#34;move_group&#34; file=&#34;$(find lwr_moveit_config)/launch/trajectory_execution.launch.xml&#34; if=&#34;$(arg allow_trajectory_execution)&#34;> <arg name=&#34;moveit_manage_controllers&#34; value=&#34;true&#34; /> <arg name=&#34;moveit_controller_manager&#34; value=&#34;lwr&#34; unless=&#34;$(arg fake_execution)&#34;/><!--unless前的value改为自己的机器人名称,作为前缀--> <arg name=&#34;moveit_controller_manager&#34; value=&#34;fake&#34; if=&#34;$(arg fake_execution)&#34;/> </include> |
打开trajectory_execution.launch.xml发现最后有一句:
1 | <include file=&#34;$(find lwr_moveit_config)/launch/$(arg moveit_controller_manager)_moveit_controller_manager.launch.xml&#34; /> |
按照原先的设置,本应该启动fake_moveit_controller_manager.launch.xml,你可以去moveit配置文件夹下去找,这个文件是存在的,而现在一个叫做lwr_moveit_controller_manager.launch.xml将会被启动,而这个文件moveit也应该已经帮你创建好了,当你使用先前的moveit向导加载机器人模型时,机器人模型中写明的机器人名称(name属性),就会作为前缀写入这个文件的文件名,所以,“lwr”这个名称源自于你模型文件里写明的机器人名称,请前后保持统一,理解各个文件之间的调用关系。
如果执行轨迹时,轨迹执行时间超时,如下错误(图片转自博主爱学习的草莓熊):
解决方案如下:
- 方案1: 增加参数以延长允许执行轨迹的时间,通过加入如下参数设置
1234 | <!--允许轨迹执行时间的一个放大倍数,可以根据实际情况自行修改--> <param name=&#34;trajectory_execution/allowed_execution_duration_scaling&#34; value=&#34;6&#34;/> <!--超时的一个百分比范围--> <param name=&#34;trajectory_execution/allowed_goal_duration_margin&#34; value=&#34;0.5&#34;/> |
- 方案2:关闭轨迹执行情况的一个monitoring,通过加入如下参数设置
1 | <param name=&#34;trajectory_execution/execution_duration_monitoring&#34; value=&#34;false&#34;/> |
- ③ 修改lwr_moveit_controller_manager.launch.xml
1234567891011 | <launch> <!-- 在参数服务器上加载moveit_controller_manager作为参数 如果没有传递任何参数,将设置moveit_simple_controller_manager --> <arg name=&#34;moveit_controller_manager&#34; default=&#34;moveit_simple_controller_manager/MoveItSimpleControllerManager&#34; /> <param name=&#34;moveit_controller_manager&#34; value=&#34;$(arg moveit_controller_manager)&#34;/> <!-- 将ros_controllers加载到参数服务器 --> <rosparam file=&#34;$(find lwr_moveit_config)/config/ros_controllers.yaml&#34;/></launch> |
最新版本中,助手会帮我们自动生成ros_controllers,已经不需要进行修改,或者也可以将默认的ros_controllers该为其他自定义的xxx_controllers
123456789101112 | controller_list: - name: &#34;lwr&#34; 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 |
参数介绍:
- name:写一个与自己机器人相关的名称,便于使用
- action_ns:服务器名称定义,follow_joint_trajectory即为后续action名字的一部分,整体名称为:name/action_ns
- type:定义action的类型,FollowJointTrajectory是ros自带action类型,是一种控制机械臂运动轨迹的数据结构,其他action类型请参考:传送门
- joints:来自urdf文件中描述的关节名称,直接复制fake_controllers.yaml中的即可!
测试
rviz中加载一个障碍物
- 新建障碍物文件test.scene
- Scene Objects→Import From Text
- Publish Scene


LWR的Moveit配置结果解析
文件级:
<hr/>├── 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
<hr/><hr/>
参考文献:
- https://blog.csdn.net/weixin_42018112/article/details/80231442
- https://blog.csdn.net/improve100/article/details/50619925
- https://blog.csdn.net/lingchen2348/article/details/80300069
- https://www.ncnynl.com/archives/201612/1138.html
- https://www.ncnynl.com/archives/201612/1137.html
|
|