Python Kinematics

How is the OnCalculateTarget method in the vcPythonKinematics object used?

When I include this method in a python kinematics script the onInverse method is no longer called.

 

Thanks

Not my best topic, but I have an example below, which I made some time back. I think you need to return the matrix that will be the input to the OnInverse.

 

Returns Kinematic chain joint values based on the target (matrix)

def OnInverse(kinobj):
t2 = kinobj.Target
t2.rotateRelY(180)
solutions = []
for i in range(CONFIG_COUNT):
y = t2.P.Y
x = t2.P.X
z = t2.P.Z
rz = t2.WPR.Z
solutions.append( ( VC_SOLUTION_REACHABLE, GetMappedJoints( [y, x, z, rz] )))
kinobj.Solutions = solutions
return True

z = vcVector.new(0,0,1,0)
EPSILON = 0.00001
def OnCalculateTarget(fullMtx, baseMtx, toolMtx, isExternal):
if JS[3]:
#With orientation around Z
toolMtx.invert()
t6 = baseMtxfullMtxtoolMtx
else:

fixed orientation

toolMtx_inv = vcMatrix.new( toolMtx )
toolMtx_inv.invert()
toolMtx.rotateAbsY(180)
root2target = baseMtxfullMtx
root2target.WPR = toolMtx.WPR
t6 = root2target
toolMtx_inv
return t6

Thanks! I got it working now.