Solving the FK problem of simple kinematic chains is trivial (just apply the desired joint values to all joints in the chain to obtain the position and orientation of the tip or end effector). However it is less trivial to solve the IK and FK problem for closed mechanisms. 計算串聯機構(或開鏈機構)的運動學正解很簡單,但是對於並聯機構或者閉鏈機構(若運動鏈的各構件構成了首末封閉的系統,則稱其為閉式運動鏈)來說運動學正解的計算就比較復雜。

Solving IK and FK for closed mechanisms
In the case of an FK problem, identify the joints that you want to control (i.e. the joints that are driving the mechanism, the active joints—select the joint mode different from inverse kinematics mode). Then, identify which kinematic chain needs to be closed. Closing will be handled by loop closure constraints in the form of tip-target pairs as shown in following figure:

[Forward Kinematics solving method for closed mechanisms]
Then, set the desired joint values for the active joints and call the inverse kinematics functionality to handle loop closure constraints. (the default main script handles all IK groups that are not marked as explicit handling). Following example shows some additional functionality that can be used to solve complicated kinematic problems:

[Inverse kinematics task]
Most of the time there are several different ways of solving the IK or FK of a mechanism, and it is always worth considering various alternatives before implementing the most complicated one!
參考V-REP_PRO_EDU\scenes\ik_fk_simple_examples\7-fkAndIkResolutionForParallelMechanisms.ttt中的例子,實現了閉鏈機構的運動學正解與逆解:

根據這個例子我們來搭建一個平行四邊形機構。構建樹形層級結構:以frame作為機座,然后將運動鏈上的節點依次串聯起來,最后將target和tip連接起來構成閉環(loop closure)。target和tip的類型設置為IK,tip-target,然后在Calculation Modules的IK選項卡中添加IK group,並將其設為顯式處理(Explicit handling):
[模型結構]

[IK設置]
給第一個關節(主動控制關節。其它關節從動但要設為IK模式,而不是passive模式)施加一個正弦規律的往復擺動,可以看出機構能跟着一起運動而不散開。添加Graph記錄末端關節轉角和運動鏈上倒數第二個關節的轉角,可以看出末端關節轉角為0且始終保持不變(其實這里末端的Joint並沒有什么作用,因為在IK的計算下tip和target已經能重合。比如上面官方的那個例子中最后一根桿L5就沒有接Joint而是直接連着tip)。

代碼如下,在設置主動關節角度后可以調用simHandleIkGroup函數來計算IK,使機構保持閉環:
if (sim_call_type==sim_childscriptcall_initialization) then ikGroup=simGetIkGroupHandle('ik') tipDummy=simGetObjectHandle('tip') motor=simGetObjectHandle('Revolute_joint0') -- set the motor joint into ik mode simSetJointMode(motor,sim_jointmode_ik,0) -- close the mechanism (if it was open) simHandleIkGroup(ikGroup) end if (sim_call_type==sim_childscriptcall_actuation) then -- First set the motor joint into passive mode simSetJointMode(motor,sim_jointmode_passive,0) -- Set the desired joint angle local angle=20*math.pi/180*math.sin(math.pi*simGetSimulationTime()) simSetJointPosition(motor, angle) -- Compute simHandleIkGroup(ikGroup) end
注意使用幾何約束求解器GCS也能實現類似的功能,只是相比IK存在着一些差異:The geometric constraint solver is slower and less precise at solving kinematic problems, but might be easier and more intuitive to use. Moreover, it allows interacting with a mechanism in a more flexible way than the inverse kinematics calculation module.
下面場景中可以拖拽機構上的任意桿件來直觀地控制其運動。這里使用的是Geometric Constraint Solver(注意要設置好General damping參數,否則可能出現拖拽時機構不動、動的很遲緩或者約束broken的現象)

參考:
