【Moveit】Moveit Core结构、C++源码解析与规划流程举例


moveit很多人都会用,但是对其中的框架和实现原理都不清楚,moveit作为一个优秀的框架是很值得学习的,其中主要关注的点:

  • 碰撞检测
  • 路径规划

故,此博简要的介绍一下moveit中的核心部分Moveit_core的代码框架。


moveit是一个大的元包,其中又包含其他的元包,其具体结构我们可以直接看他的->官方网站
可以看出其中的最关键节点就是moveit-core:
123
然后我们可以看到官方提供的API分为了四个:

在这里插入图片描述
其中Move Group Interface是我们常用的API接口,好用但是功能不全,因此有必要看一下Moveit Core的源码,它包括了MoveIt中用于运动学,计划场景,约束,运动计划,碰撞检查和插件界面的核心组件。
在上图中,也可以看到moveit_core的核心api。这些API实际上都是通过封装成动态库然后安装的形式来使用的。
move_core这个包里包含了很多SUBDIRECTORY,其中里面有很多使用gtest来实现的test脚本可以供学习使用,也是一个不错的资源,在这就不详细举例子了。
其实也就是说核心代码包就那么几个,其余的打多都是测试包。并且这些核心包里实质上都是接口。

框架

kinematics_base

主要是运动学,逆运动学,包括了碰撞检测。
->reference
可以看到
在这里插入图片描述

因此可以从派生类(PR2ArmKinematicsPlugin)出发,测试。
可以看出:
在这里插入图片描述
这个test主要就是对kinematics_base进行扩展和测试。

robot_model

命名空间:moveit::core ->参考

  • aabb 生成axis-aligned bounding box包围盒,这里不知道为什么不生成OBB包围盒?是为了减少计算量?但aabb包围盒相对来说碰撞计算误差更大。

  • robot_model 根据urdf和srdf构建运动学模型。

  • joint_model 来自机器人的关节。 为该关节在运动链中应用的变换建模。 关节由多个变量组成。 在最简单的情况下,如果关节是单个自由度,则只有一个变量,并且其名称与关节的名称相同。 对于多自由度关节,每个变量都有一个本地名称(例如,x,y),但是从此类外部看,完整的变量名称是“关节名称” /“本地名称”(例如, 具有局部变量“ x”和“ y”的名为“ base”的关节将其完整变量名称存储为“ base / x”和“ base / y”)。 本地名称永远不会直接用于引用变量。其中包含了,计算齐次变换矩阵等。
    在这里插入图片描述

    • 固定关节,即不会动的关节
    • floating joint,这个关节允许六个自由度的运动, 浮动关节.
    • planar: wiki上的原话是: This joint allows motion in a plane perpendicular to the axis. 我理解是, 这个关节允许再垂直于轴的一个平面内进行运动, 参考"ROS机器人开发实践"第115页上的内容. 这里的运动应该即包括平移, 也包括旋转.->reference
    • prismatic: 平移关节
    • revolute:转动关节
  • joint_model_group: 官网没有直接给出解释。主要是一些get函数来返回jointModel。

  • link_model:A link from the robot. Contains the constant transform applied to the link and its geometry.主要是杆及杆上的一些变换关系。

其test文件测试了模型的load及其他,并且使用了外部的utils,这些utils显示了如何加载并且建立模型。

robot_state

命名空间:moveit::core ->参考

  • robot_state: Representation of a robot’s state. This includes position, velocity, acceleration and effort.
    At the lowest level, a state is a collection of variables. Each variable has a name and can have position, velocity, acceleration and effort associated to it. Effort and acceleration share the memory area for efficiency reasons (one should not set both acceleration and effort in the same state and expect things to work). Often variables correspond to joint names as well (joints with one degree of freedom have one variable), but joints with multiple degrees of freedom have more variables. Operations are allowed at variable level, joint level (see JointModel) and joint group level (see JointModelGroup).
    For efficiency reasons a state computes forward kinematics in a lazy fashion. This can sometimes lead to problems if the update() function was not called on the state.
    机器人状态的表示。 这包括位置,速度,加速度和精力。
    在最低级别上,状态是变量的集合。 每个变量都有一个名称,并且可以具有与其相关的位置,速度,加速度和作用力。 出于效率方面的考虑,努力和加速共享内存区域(不应将加速和努力设置为同一状态,并且期望事情能够正常进行)。 变量通常也与关节名称相对应(具有一个自由度的关节具有一个变量),但是具有多个自由度的关节具有更多的变量。 允许在可变级别,联合级别(请参见JointModel)和联合组级别(请参见JointModelGroup)上进行操作。
    出于效率原因,状态以惰性方式计算正向运动学。 如果未在状态上调用update()函数,则有时可能会导致问题。
    //—
    生成包围盒,get**Model等作用。
  • AttachedBody: Object defining bodies that can be attached to robot links. This is useful when handling objects picked up by the robot.也就是说。

其中还有一个文件 coversion用于msg类型转换。

test有:
在这里插入图片描述

自己体会。

未完

从一个完整的运动规划例子,理解moveit core框架。(rviz+rosrun脚本)
以仿真程序举例,这里只列举核心节点。

rviz

  • ros 自带的节点:
    在这里插入图片描述
  • 这里只关注move_group.launch
    在这里插入图片描述
  • move_group-> 这里我们不考虑sensor。
    在这里插入图片描述
    • planning_context: 导入urdf srdf joint_limits.yaml kinematics.yaml到参数服务器
    • planning_pipeline.launch -> ompl_planning_pipeline.launch.xml->同样是写入参数服务器
      在这里插入图片描述
  • trajectory_execution.launch.xml 参数服务器配置 and -> panda_moveit_controller_manager.launch.xml
  • 最后一个是关键:其打开了moveit_ros下的一个节点move_group。
  <!-- Start the actual 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)">
    <!-- Set the display variable, in case OpenGL code is used internally -->
    <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)"/>


    <!-- Publish the planning scene of the physical robot so that rviz plugin can know 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>

猜你喜欢

转载自blog.csdn.net/weixin_44229927/article/details/115964656