1.4 Vrep之逆运动学模块

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/lwz45698752/article/details/84478240


  • 本章将学习逆运动学模块的使用,当然,我们在学习过程中也会复习如何创建机械臂模型
  • 你可以先看下IK和FK相关文件夹scenes/ik_fk_simple_examples下的实例来学习逆运动学模块

导入模型

导入mesh

  • 我们目的是创建一个non-dynamic机械臂,只用到逆运动学功能而不需要物理引擎的帮助(设置为non-dynamic的原因)
  • CAD数据位于"cadFiles" 文件夹中,具体操作如下: [Menu bar --> File --> Import --> Mesh…] ,则导入了 A single simple shape ,其默认位于场景的中心。当然,取决于导入时的设置,CAD数据可能处于不同位置,有不同缩放系数(scale),甚至可能已经被划分为几个小形状。
    在这里插入图片描述

划分形状

  • 此时导入的是A single simple shape ,我们要划分其为几个小形状,选中机械臂,然后 [Menu bar --> Edit --> Grouping/Merging --> Divide selected shapes].
    在这里插入图片描述

  • 这种划分算法的原理是将具有相同边的三角形(mesh由三角形组成)组合在一起,有时这种自动划分不行,则进入三角形编辑模式,手动划分


统一视觉属性

  • 下面要统一视觉属性,选中一个形状,进入属性设置界面,点击Adjust outside color,来调整所选形状的外表面的各种颜色成分,这里我们只调整形状的外部颜色成分,搞掂一个后,通过选形状A,CTRL+选形状B(模板形状),然后Apply to selection,达到统一的目的。同理,统一其他视觉属性Shading angle, the Edges width or the Edges color。

效果图:

在这里插入图片描述


添加关节

基本思想:从形状中提取关节(三角形编辑模式)

  • 首先选中所有导入的形状,点击 [Menu bar --> Edit --> Bounding box alignment --> Align selected shapes’ coordinate frame with world],这一步保证包围盒与绝对坐标系对齐(our bounding boxes are aligned with the absolute reference frame),并且考虑到当前机械臂设置(given the current manipulator configuration),能代表最小包围盒。

  • 然后添加旋转关节Menu bar --> Add --> Joint --> Revolute,默认位置是0,0,0而默认姿态为垂直方向,所以添加的关节会被基座的圆柱体掩盖,然后选中关节,Ctrl+选中基座,分别对位置和姿态Apply to selection,使得关节和基座处于完全相同的坐标下,对其他6个关节重复这样的操作,则所有关节的位置是对的,但部分关节的姿态要调整。

  • 对那些应该与世界坐标系Y轴对齐的关节,在姿态框中输入(90,0,0) for the Alpha, Beta and Gamma,然后点击 Apply to selection,而对那些应该与世界坐标系X轴对齐的关节,在姿态框中输入(0,90,0)for the Alpha, Beta and Gamma,然后点击 Apply to selection,最终所有关节的位姿都搞掂!

在这里插入图片描述

扫描二维码关注公众号,回复: 4343081 查看本文章

组合形状

  • 下一步要组合(group)那些属于同一刚性实体(连杆)的形状。
  • 选中那些要组成连杆1(连杆0是基座)的形状,然后组合,即[Menu bar --> Edit --> Grouping/Merging --> Group selected shapes]。
  • 一旦形状组合成复合形状,你可以重新将包围盒与世界对齐,但这一步不是必需,只是为了视觉效果。(附英文)

Once the shapes are grouped in a compound shape, you could re-align its bounding box with the world, but this step is not required (and has only a visual effect).

  • 重复上述过程,合并其他逻辑上属于一起的形状,这里我们不会去驱动gripper的手指,所以简单地将它们与最后一个连杆刚性地组合在一起。
  • 当要组合的所有形状具有相同的视觉属性时,尝试将它们合并到一起,即Menu bar --> Edit --> Grouping/Merging --> Merge selected shapes。

When all shapes that are meant to be grouped share the same visual attributes, try merging them together instead ([Menu bar --> Edit --> Grouping/Merging --> Merge selected shapes]).

  • 关于merge与group的辨析(待补)

  • 接着重新命名各结构,如"redundantRobot" - “redundantRob_joint1” - “redundantRob_link1” - “redundantRob_joint2”

  • 接着通过拖拽建立运动学链,效果如图:

在这里插入图片描述


  • 接着选中所有关节,在关节模式的属性设置中,选择joint is in inverse kinematics mode,然后Apply to selection,接着设置关节所在的视觉层(比如关节默认处于第二层,则disable第二层显示)

定义逆运动学任务

  • VREP中逆运动任务至少需要如下的几种元素说明:
  1. 运动学链,包括一个末端dummy和基座(机械臂要求)
  2. 一个target dummy及与之相约束的tip dummy(任务要求tip-target对)

a kinematic chain described with a “tip” dummy and a “base” object.

A “target” dummy that the “tip” dummy will be constrained to follow.


  • 现在我们已经有了基座,下面添加末端dummy,命名为redundantRob_tip,并设置其位置为:(0.324,0,0.62),并将其拖拽到基座上(层次树中)

  • 下面设置target dummy,复制和粘贴redundantRob_tip,并重新命名为redundantRob_target

  • 接着为了说明"redundantRob_tip"和redundantRob_target"为逆运动学的tip/target对,打开redundantRob_tip的dummy属性设置框,指定redundantRob_target为Linked dummy,此外,属性框中的Link type默认为 IK, tip-target,不需更改。注意到层次树中tip/target对有红色虚线连接。(重要

在这里插入图片描述


  • 下面要注册逆运动学为IK group(register the task as an IK group),打开逆运动学属性框,点击Add new IK group,则IK group列表中出现新的一项:“IK_Group”,选中它,点击 Edit IK elements来打开 IK element dialog,选中redundantRob_tip,然后点击 Add new IK element with tip按钮。

  • 这一步只是添加了一个出现在列表中的IK模块,此外,还表明了redundantRobot作为基座(如图),最后,确保所有的items在Constraints上为checked状态(如图)。我们确实希望tip dummy在位置和姿态上能跟随target dummy。

This just added an IK element that appears in the list. Further down, indicate “redundantRobot” as the Base. Finally, make sure that all items are checked in the Constraints section (check als Alpha-Beta and Gamma). Indeed, we want our “tip” dummy to follow our “target” dummy in position and orientation
在这里插入图片描述


在逆运动学设置框中,你能enable Mechanism is redundant,但眼下在我们这里没差别,因为我们没定义关节限制和避障参数
在这里插入图片描述


  • 运行仿真,此时若移动redundantRob_target的位置和姿态,则机械臂应该跟随着运动,注意到若移动得太远,则逆运动学模块会崩溃,这种情况通常由于两种原因,一种是奇异点,另一种是达不到这一位置。
  • 针对这种行为,我们有变通的方法:选中逆运动框列表中的"IK_Group",然后为Calc. method项设定为DLS,这次若将target移动到很远的地方,则逆运动运算更加稳定( the inverse kinematics resolution became more stable),上下调整Damping项,基本上,若该项值大时,逆运动更稳定但变慢。
  • 实际上,你可以获得两种解决方案的好处(get the advantages of both resolution methods),你只需要创建两个相同的 “IK groups”,第一个是not damped,第二个是damped,那么,对于第二个IK group,你可以指定带条件的解决方案,有关更多信息,请参阅“Edit conditional parameters项(specify a conditional resolution (refer to the Edit conditional parameters item for more information))。
  • 关于为什么能兼有二者好处,是由于Edit conditional parameters中说明若not damped失败,则采用damped方案
  • 现在将Calc. method项设定回 Pseudo inverse。
  • 运行仿真,在IK element框中,选中"redundantRob_tip,然后disable一些约束项,观察此时若拖动target,机械臂会如何运动,实验够了,就将所有约束项重设为checked。

定义模型

  • 为了不用担心误操作从而破坏模型,我们要定义模型
  • 首先将"redundantRob_tip" and “redundantRob_target"移动到视图层11使之不可见,然后shift+选中场景中所有可见物体,然后Ctrl+选中"redundantRobot"来将其移出选择项中,打开common properties dialog,然后enable Select base of model instead项,然后点击Apply to selection。然后通过ESC按键来清除选择项,然后选中"redundantRobot”,enable Object is model base item(在common properties中)
  • 大功告成,成功添加包围盒。

在这里插入图片描述

  • 接着添加一个控制球,从而来控制机械臂抓手的位姿,[Menu bar --> Add --> Primitive shape --> Sphere],为 X-Size, Y-Size and Z-Size指定为0.05, 然后 uncheck the Create dynamic and respondable shape项,接着使得球体位置和redundantRob_target的位置一致,此时球体出现在机械臂的末端(tip)上,重命名其为redundantRob_manipSphere,接着通过拖拽将其作为"redundantRob_target"的父节点,此时运行仿真,你能通过移动小球来改变机械臂的configuration

  • 接着改变下球体外观,在shape properties中,点击Adjust outside color, 然后 check the Opacity item以及 check the Backface culling item

  • 在球体的object common properties中,uncheck all items in the Object special properties section(因为球体并不属于机械臂,更像是人机交互接口),接着将"redundantRobot" 作为 "redundantRob_manipSphere"的父节点。

在这里插入图片描述

register a collision object

  • 最后,我们要register a collision object来检测机械臂与环境的碰撞,即机械臂中的每个形状能检测碰撞(当然不包括那个球体),所以要设置collection
  • 打开collection对话框,选择"redundantRobot",然后点击Add new collection,则添加了个新的,空的collection,接着定义这个collection的内容:点击Add(确保"redundantRobot" 仍然被选中)。接着选中新增加的collection项,点击Visualize selected collection,则所有组成机械臂的物体在场景中呈现pink的颜色,将collection命名为 “redundantRob”。

在这里插入图片描述


  • 接着注册(register)一个碰撞物体(a collision object),具体操作:
  • 打开collision dialog,然后添加新的collision object并指定如下的item pair:"[Collection] redundantRob" - “all other collidable objects in the scene”,然后将此collision object重命名为 “redundantRob”
  • 此时运行仿真,复制粘贴机械臂几次,注意到那些模块也对应地被复制了,然后放在各自周围,然后拖动球体,改变机械臂结构(位姿),可看到若发生碰撞时,场景中机械臂颜色的改变,且每个机械臂都在充分运行(发挥各自功能)。
  • 注册最小距离计算object的步骤类似于注册碰撞object的步骤,所有注册的object(包括collision detection, collections, IK groups)和场景中的物体可通过API调用来获取,除此之外,还可以被图标记录并可视化。

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/lwz45698752/article/details/84478240
1.4