V-rep学习笔记:机器人模型创建4—定义模型

  完成之前的操作后终于来到最后一步——定义模型,即将之前创建的几何体、关节等元素按层级关系组织成为一个整体。

  将最后一个连杆robot_link_dyn6拖放到相应的关节(robot_joint6)下,成为其子节点。依次进行这样的操作,直到机器人的基座为止,最终UR机器人的层级结构看起来如下图所示:

[Robot model hierarchy]

   由于根节点代表了整个机器人,这里我们将根节点重命名:robot代表机器人的动力学模型,robot_visibleBase代表机器人的可视化模型。接着选中模型根节点(即robot),双击其图标打开Common属性页面,勾选"Object is model base"选项。

  Object is model base: indicates whether the object should act as the base of a model. An object flagged as base of model has special properties (e.g. saving or copying the object will also automatically save/copy all its children and children's children, etc.). Additionally, when such an object is selected, the selection bounding box is displayed as thick stippled lines, encompassing the whole model.

    同时也勾选"Object/model can transfer or accept DNA"选项。

  Object / model can transfer or accept DNA: when this feature is enabled for an object or a model, then it will share a same identifier with all of its copies. An Object or model can then transfer its DNA (i.e. copy an instance of itself) to all of its siblings (i.e. objects/models with the same identifier), via the transfer DNA toolbar button. Imagine having 100 same robots in your scene that you want to modify in a similar way: simply modify one of them, select it, then click the transfer DNA toolbar button. This item should almost always be checked for a model base to facilitate model re-instanciation. 即勾选这一选项后能让我们很方便的将某一个模型的更改应用到其它复制体上。

[DNA transfer toolbar button]

   举个例子:定义好模型并勾选"Object/model can transfer or accept DNA"后将下图左边的二连杆机构复制一份拖到右边。接着将左侧模型连杆L1的颜色改为黄色,然后选中左侧模型的根节点J1,这时工具栏上的Transfer DNA to siblings按钮变得可用。点击这一按钮后右边的模型连杆L1颜色也变为黄色。同样的可以将右边模型连杆L2的颜色改为绿色或其它颜色,再transfer DNA,左侧模型中连杆L2也会发生同样的变化。

   定义好模型后会出现一个包围体将模型整各围起来。不过由于关节、传感器等物体的存在,包围体比实际应有的体积要大。我们可以选择要移出的关节,通过勾选"Don't show as inside model selection"选项将其从包围体中除去。We could do the same procedure for all invisible items in our model. This is also a useful option in order to also exclude large sensors or other items from the model bounding box.

[Robot model bounding box]

  为了防止模型被偶然更改,我们选择模型中每个可见的几何体,然后在Common属性页勾选" Select base of model instead"选项,这样一来通过鼠标在场景中点中机器人的某一连杆时,整个机器人(根节点)就会被选中。This allows us to manipulate the model as if it was a single object. 如下图所示,红色的圆点为鼠标选择的连杆,而作为代替机器人的基座将被选中:

  之后我们将模型放置合适的位置和姿态上。It is considered good practice to position the model (i.e. its base object) at X=0 and Y=0.

  现在我们点击开始仿真按钮,机械臂在重力作用下会塌下来,因为此时6个旋转关节还没有受控制。进入Joint Dynamic Properties对话框,勾选Motor enabled和Control loop enabled并选择Position control(PID),对关节进行简单的PID控制。

  再次进行仿真,可以看到机器人将能保持在当前位置。此外,在仿真过程中我们可以点击工具栏上的动态内容显示按钮,通过不同颜色显示场景中物体所处的状态。

[Dynamic content visualization button]

  Only items that are taken into account by the physics engine will be display, and the display is color-coded. It is very important to always do this, and specially when your dynamic model doesn't behave as expected, in order to quickly debug the model. Similarly, always look at the scene hierarchy during simulation: dynamically enabled objects should display a ball-bounding icon on the right-hand side of their name.

  Dynamic objects will appear in various colors, depending on their function or settings. Refer to following figure:

  根据上面颜色对应的状态我们可以看出:机器人基座为白色表示它是一个静态的respondable物体;连杆为红色表示它们是动态的respondable物体。

  创建好机器人后我们可能要将其安装在移动底盘上或在机器人的末端装一个手爪。有下面两种方式将动态体刚性地连接在一起:

  1. by grouping them: select the shapes, then [Menu bar --> Edit --> Grouping/Merging --> Group selected shapes].
  2. by attaching them via a force/torque sensor: a force torque sensor can also act as a rigid link between two separate dynamically enabled shapes.

  第一种方式很简单,我们来看看第二种:先通过[Menu bar --> Add --> Force sensor]添加力传感器,在场景中将其移动到机器人末端,并在层次结构中将其拖放到最后一个连杆robot_link_dyn6下。更改其外观与尺寸,并且改名为robot_attachment.

[Attachment force/torque sensor]

  在模型浏览器中选择一个手爪并拖入场景中,保持手爪处于选中状态,然后按Control键同时选中robot_attachment力传感器,接着点击工具栏上面的"Assemble / Disassemble"按钮,手抓就会被装配到合适的位置。The gripper knew how to attach itself because it was appropriately configured during its model definition. 

[Assemble / Disassemble button]

 

[Attached gripper]

   手爪模型在定义时就确定了装配时如何确定位置姿态,因此在考虑将UR机器人安装到移动小车上时,我们同样应该定义其装配行为:先选中机器人模型,然后点击Common属性页下的Assembling按钮,弹出Assembling Behaviour对话框。消除"Object can have the 'parent' role"选项,然后点击"Set Matrix"按钮。This will memorize the current base object's local transformation matrix, and use it to position/orient itself relative to the mobile robot's attachment point. 

  • Object can have the 'child' role: if checked, then the object can be attached to another object (i.e. become another object's child)
  • Object can have the 'parent' role: if checked, then the object can have another obejct attached to itself (i.e. become another object's parent)
  • Set matrix: when the object is assembled, a specific transformation matrix will be used as its new local transformation matrix. By default that matrix is the identity matrix, but you can specify a specific matrix by clicking the button. This feature is useful in order to automatically position and orient an object correctly in relation to its new parent (e.g. in order to have a gripper automatically placed correctly at a robot's tooltip)

  为了验证上述功能,我们往场景中拖入一个KUKA Omnirob移动机器人。首先选中UR机器人,然后按Control键用鼠标选取移动平台上的attachment points,点击工具栏上"Assemble / Disassemble"按钮,此时我们的UR机器人应该正确的安装在移动平台上面。

[Attached robot]

  如果我们在装配前改变UR机器人的姿态朝向,然后点击"Set Matrix"按钮记住机器人在局部坐标系中的位置姿态信息,那么之后进行装配时UR机器人在移动平台上的朝向也会发生相应的变化(注意如果模型位置不在X=0,Y=0,Z=0处,那么安装到移动平台时将会有一个偏移),如下图所示:

  对于用户自己创建的模型如果以后想直接拖入场景中使用,可以选中模型根节点,然后在菜单栏中选择File --> Save model as... 将其保存。If we saved it in the model folder, then the model will be available in the model brower.

  保存时会出现一些提示,比如会提示选择模型的缩略图:

  将模型命名为user model保存在系统models文件夹下,当新建一个场景时就可以在模型浏览器中找到我们自己创建好的模型:

   至此,一个完整的机器人模型就已经创建好了。后续工作是为机器人添加各类传感器和控制脚本控制机器人的运动以及行为。

 

参考:

Building a clean model tutorial

posted @ 2017-04-18 22:45  XXX已失联  阅读(2750)  评论(0编辑  收藏  举报