The establishment of inverse kinematics solution module of vrep4.4.0 version

Typically: "How do I... ", "How can I... " questions
Post Reply
qsz
Posts: 1
Joined: 24 Jan 2024, 15:45

The establishment of inverse kinematics solution module of vrep4.4.0 version

Post by qsz »

I would like to ask how to establish the inverse kinematics solving module in vrep4.4.0.Once it's done, call ikgroup for the sim.setExplicitHandling () operation.
Following the example:

Code: Select all

enableIk=function(enable)
    if enable then
        sim.setObjectMatrix(ikTarget,-1,sim.getObjectMatrix(ikTip,-1))
        for i=1,#jointHandles,1 do
            sim.setJointMode(jointHandles[i],sim.jointmode_ik,1)
        end
        sim.setExplicitHandling(ikGroup,0)
    else
        sim.setExplicitHandling(ikGroup,1)
        for i=1,#jointHandles,1 do
            sim.setJointMode(jointHandles[i],sim.jointmode_force,0)    
        end
    end
end

function sysCall_init()
    local simBase=sim.getObject('.')
    local simTip=sim.getObject('./tip')
    local simTarget=sim.getObject('./target')
    ikEnv=simIK.createEnvironment()
    ikGroup=simIK.createGroup(ikEnv) 
    simIK.setGroupCalculation(ikEnv,ikGroup,simIK.method_pseudo_inverse,0,6) 
    simIK.addElementFromScene(ikEnv,ikGroup,simBase,simTip,simTarget,simIK.constraint_pose) 
end
The error is Ik group does not exist!!!

coppelia
Site Admin
Posts: 10375
Joined: 14 Dec 2012, 00:25

Re: The establishment of inverse kinematics solution module of vrep4.4.0 version

Post by coppelia »

Hello,

I am not sure I completely understand what you want to do. My understanding is you want to move away from the old way of handling IK, and use the new way?

Your second code section looks right:

Code: Select all

function sysCall_init()
    local simBase=sim.getObject('.')
    local simTip=sim.getObject('./tip')
    local simTarget=sim.getObject('./target')
    ikEnv=simIK.createEnvironment()
    ikGroup=simIK.createGroup(ikEnv) 
    simIK.setGroupCalculation(ikEnv,ikGroup,simIK.method_pseudo_inverse,0,6) 
    simIK.addElementFromScene(ikEnv,ikGroup,simBase,simTip,simTarget,simIK.constraint_pose) 
end
The first part of your code is not compatible with the second part. If you want to enable/disable handling of IK, then you should add following (the actuation section was missing anyways):

Code: Select all

function sysCall_actuation()
    if ikEnabled then
        simIK.handleGroup(ikEnv, ikGroup, {syncWorlds = true, allowError = true})
    end
end


Cheers

Post Reply