Page 1 of 1

How to disable/enable IK_group or IK_element during simulation ?

Posted: 05 Mar 2020, 12:01
by erenes
Hello ,

I am trying to control manipulator. So IK_group is used now.
But during simulation, sometime Joint mode control is needed.
Then I think, first disable IK_group, second change joint mode to torque/force.
After this, I can control each Joint. Am I right?

I checked these 3 methods. But doesn't seem to be used to enable/disable IK_group during simulation.
sim.setIkGroupProperties()
sim.setIkElementProperties()
sim.setExplicitHandling()

Can you explain a way to do it?
Thank you.

Re: How to disable/enable IK_group or IK_element during simulation ?

Posted: 05 Mar 2020, 16:05
by sampits
erenes wrote: 05 Mar 2020, 12:01 Hello ,

I am trying to control manipulator. So IK_group is used now.
But during simulation, sometime Joint mode control is needed.
Then I think, first disable IK_group, second change joint mode to torque/force.
After this, I can control each Joint. Am I right?

I checked these 3 methods. But doesn't seem to be used to enable/disable IK_group during simulation.
sim.setIkGroupProperties()
sim.setIkElementProperties()
sim.setExplicitHandling()

Can you explain a way to do it?
Thank you.
In my case i used a function to control the Ik

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(ikGroupHandle,0)
    else
        sim.setExplicitHandling(ikGroupHandle,1)
        for i=1,#jointHandles,1 do
            sim.setJointMode(jointHandles[i],sim.jointmode_force,0)    
        end
    end
end
then all i need is to call the function and select true or false and Ik actviates/deactivates.
Not sure if thats what you want.

Re: How to disable/enable IK_group or IK_element during simulation ?

Posted: 06 Mar 2020, 11:16
by erenes
Thank you sampits for your kind reply.
I referred your code snippet and similar topic in this forum. And I made like this and it works.

What I have done is ... (VREP version 3.6.2)

# Before start simulation
1. "Calculation Modules" -> "Kinematics" -> "IK Group" -> uncheck "Explicit Handling"
2. In the script,

Code: Select all

    hdl_ikGroup=sim.getIkGroupHandle("IK_Group")
    ik_full_constraint=sim.ik_x_constraint+
                       sim.ik_y_constraint+
                       sim.ik_z_constraint+
                       sim.ik_alpha_beta_constraint+
                       sim.ik_gamma_constraint+
                       sim.ik_avoidance_constraint
    joint_list={hdl_joint1, hdl_joint2, hdl_joint3, hdl_joint4, hdl_joint5, hdl_joint6, hdl_joint7}         
    
    function switch_ik_mode(mode)
        if mode then
            for i=1,#joint_list,1 do
                sim.setJointMode(joint_list[i],sim.jointmode_ik,1)
            end
            sim.setIkElementProperties(hdl_ikGroup,hdl_tip,ik_full_constraint)
        else
            sim.setIkElementProperties(hdl_ikGroup,hdl_tip,0)
            for i=1,#joint_list,1 do
                sim.setJointMode(joint_list[i],sim.jointmode_force,0)
            end
        end
    end
                       

And then during simulation, switch joint to IK mode or Torque/Force mode.
In joint mode, sim.setJointTargetPosition() can be used.