Python Kinematics

Forum Forums Visual Components 4.0 Component Modeling Python Kinematics

Be sure to read the Forum Rules and Guidelines before start using the Forum.

This topic contains 2 replies, has 2 voices, and was last updated by  Fredrik 1 year, 3 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #2618

    Fredrik
    Participant

    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

    #2620
    line_out
    line_out
    Participant

    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 = baseMtx*fullMtx*toolMtx
    else:
    # fixed orientation
    toolMtx_inv = vcMatrix.new( toolMtx )
    toolMtx_inv.invert()
    toolMtx.rotateAbsY(180)
    root2target = baseMtx*fullMtx
    root2target.WPR = toolMtx.WPR
    t6 = root2target*toolMtx_inv
    return t6

    Attachments:
    You must be logged in to view attached files.
    #2625

    Fredrik
    Participant

    Thanks! I got it working now.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.