V-rep学习笔记:机器人逆运动学解算

  •  IK groups and IK elements

   VREP中使用IK groups和IK elements来进行正/逆运动学计算,一个IK group可以包含一个或者多个IK elements:

  • IK groups: IK groups group one or more IK elements. To solve the kinematics of a simple kinematic chain, one IK group containing one IK element is needed. The IK group defines the overall solving properties (like what solving algorithm to use, etc.) for one or more IK elements
  • IK elements: IK elements specify simple kinematic chains. One IK element represents one kinematic chain. A kinematic chain is a linkage containing at least one joint object. In short, an IK element is made up by:
    • a base (any type of object, even a joint. In that case however the joint is considered as rigid). It represents the start of the kinematic chain.
    • several links (any type of object except joints). Joints which are not in IK mode are however also considered as links(in that case they behave as rigid joints (fixed value)). 
    • several joints. A joint which is not in IK mode is however not considered as a joint, but as a link (see above). 
    • a tip. The tip is always a dummy and is the last object in the considered kinematic chain (when going from the base to the tip). The tip dummy should be linked to a target dummy (see hereafter) and the link should be an IK, tip-target link type. 
    • a target. The target is always a dummy and represents the position and/or orientation the tip should adopt (or follow) during simulation. 

   一个IK element代表一条运动链,最简单的就是下面这种情况,即场景中只有一个串联机械臂(一条运动链),那么进行逆运动学求解只需要一个IK group:

  如果同一场景中有2个互不干扰的串联机械臂,那么就需要2个IK group。下面这种情况IK group的求解顺序对结果没有影响:

 

  然而当两个运动链相互之间产生影响时,比如上图中Target2固定到运动链1上时,求解顺序就很重要了。必须先求解IK group1,求解的结果会直接影响Target2的位置,从而影响IK group2的求解:

  下面是一种更复杂的情况:两个运动链共享某一关节,先解算运动链1会带着关节朝左移动从而影响运动链2的求解;而先解算运动链2会带着关节朝右移动从而影响运动链1的求解。这种矛盾的情况下按顺序解算就失去作用,需要同时求解两个运动链。将两个IK element放在同一IK group中就可以同时进行逆解计算

  • 交互式验证求解结果

  简单的串联机械臂按照教程很容易搭建好逆运动学模型,模型和求解参数设定好以后可以通过拖拽/旋转Target Dummy(或者操控球)来观察机械臂的行为。下面以帮助文档中的7自由度冗余机械臂为例进行操作,模型位于C:Program FilesV-REP3V-REP_PRO_EDU utorialsInverseKinematics中。 Try holding down the Ctrl or Shift-keys during manipulation:打开Object Position/Orientation操纵面板,选中操控球(manipSphere),在默认视图下按住鼠标只能在X-Y平面内进行位置的拖拽,如果同时按住Ctrl键则可切换到Z方向拖拽,这是一个很实用的功能。另外值得一提的是下面的Gif图片使用ScreenToGif开源软件制作,相当良心!

  打开Tools→User settings对话框,在Object manipulation中也可以自定义拖拽或旋转物体时的步距/步距角:

 

  • 求解方法

  The pseudoinverse tends to have stability problems in the neighborhoods of singularities. At a singularity, the Jacobian matrix no longer has full row rank, corresponding to the fact that there is a direction of movement of the end effectors which is not achievable. If the configuration is exactly at a singularity, then the pseudoinverse method will not attempt to move in an impossible direction, and the pseudoinverse will be well-behaved. However, if the configuration is close to a singularity, then the pseudoinverse method will lead to very large changes in joint angles, even for small movements in the target position. 

  Try to drag the object as far as possible, and notice how the inverse kinematics task breaks. Indeed, this happens when a configuration is singular or not reachable, however there are workarounds to this behavior: while the simulation is still running, select "IK_Group" in the inverse kinematics dialog list, then specify DLS for the Calc. method item. Drag the object out of reach and notice how the inverse kinematics resolution became more stable. Try adjusting the Damping item up and down. Basically, when damping is large, resolution becomes more stable but slowerThe damped least squares method(DLS) avoids many of the pseudo inverse method’s problems with singularities and can give a numerically stable method.

  即使用伪逆矩阵法(Pseudo Inverse)进求解,在奇异位置处可能会出现问题,而DLS法在奇异位置处则更稳定。

  Practically, you can get the advantages of both resolution methods, all you need to do is define two identical "IK groups", where the first is not damped and the second is damped. Then, for the second "IK group", you can specify a conditional resolution (refer to the Edit conditional parameters item for more information).  伪逆矩阵法收敛快,但是在奇异位置处存在问题;DLS法在奇异位置处计算结果更稳定,但是运算较慢。因此可以将两者结合起来使用,在IK Group中添加undamped的伪逆矩阵法和damped的DLS法。选中damped IK group,点开Edit conditional parameters对话框,在Perform if...条件栏中进行配置:如果undamped方法失败,则执行damped方法。

  • 约束

  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. Sometimes it is however not possible to correctly specify the constraints for a tip, and in that case the IK group's calculation method should be a damped method (e.g. DLS method) with an appropriately selected damping factor. A damped resolution method should also be selected when a target can't possibly be reached (out of reach, or close to a singular configuration). Damping can result in more stable calculations, but keep in mind that damping will always slow down the IK calculations (more iterations will be needed to put the tip into place).  正确理解和施加约束对于运动学逆解的求解相当重要,如果约束的数目比机构自由度要多则会造成过约束,这时有些求解方法就会失败。

  在IK element的Constraints选项栏中勾选X、Y、Z可以分别对笛卡尔坐标系下的三个位置分量进行约束,但是姿态的三个分量只有两个选项框可以勾选:Turning Alpha-Beta constraint on, will match the tip's z-axis orientation with the target's z-axis orientation, while keeping a free rotation around the z-axis if Gamma constraint is off. When Alpha-Beta constraint AND Gamma constraint are turned on, then the tip will try to adopt exactly the same orientation as its associated target. (V-rep中物体姿态以X-Y-Z欧拉角的方式确定。即以指定的参考系为初始姿态,然后按X-Y-Z的顺序依次绕自身的坐标轴旋转Alpha,Beta,Gamma角度后得到)

  • Alpha-beta on and Gamma off

  很多工业机械臂只有4个自由度(包括沿X,Y,Z方向的平移和绕Z轴的旋转自由度),如SCARA机器人,其末端的Z轴指向是固定不变的(因此要约束Alpha-beta,即绕X-Y轴的旋转)。

  • Alpha-beta and Gamma on

   对于自由度等于或大于6的机械臂,在其灵活工作空间内的点可以任意姿态到达,因此可以约束所有的自由度。

  • collections

  A collection is a user-defined collection of scene objects. A collection has to contain at least one object and is considered to be an entity (objects are also entities). Collections are useful when referring to several objects like a robot for instance. V-REP supports calculations based not only on objects, but also on collections. For instance the collision detection module allows registering following collision pair: (collection A; object B). The collision checking algorithm will then check whether the collection A (any object composing it) collides with object B.

  VREP中可以将场景里的物体组成一个集合(collection),后续的一些操作,比如碰撞检测时就可以选取定义好的集合。将物体添加进集合有多种方式,以这个冗余机器人为例,在工具栏中打开Collections对话框,点击Add new collection按钮,添加一个新的集合并将其命名为redundantRob。然后选中机器人的根节点redundantRobot,同时勾选Tree of selected object和Base included,点击Add把机器人整个加入进collection中。为了验证可以点Visualize selected collection按钮,用颜色来显示加入集合中的物体:

  VREP提供多种灵活的选取方法(参考帮助文档的Collections页面),上面这种操作只需要选取根节点即可将整个运动链上的物体加入集合,比一个个物体单独添加要方便很多:

  In above example, if object 1 is removed from the scene, the element is not valid anymore and will also be removed. Object 1 is the element's defining object.

参考:

Inverse kinematics tutorial

Solving IK and FK for any type of mechanism

External kinematics (auxiliary API)

原文地址:https://www.cnblogs.com/21207-iHome/p/7420733.html