I'm trying to run simIK.getConfigForTipPose to find the inverse kinematics solution for a redundant arm. I want to fix one of the arm's joint angles and have the solver work out the other angles where the tip is at the target under that constraint. I'm trying to use simIK.setJointMode to passive for the joint but when I use simIK.getConfigForTipPose, it ignores the angle I've set that joint to and solves it using a different angle.
Do you know how I should implement the constraint?
Best,
Kat
Code: Select all
function coroutineMain()
--joint handles
for i=1,7,1 do
jh[i]=sim.getObjectHandle('LBR_iiwa_14_R820_joint'..i)
end
-- joint limits
jointLimitsL={-170,-120,-170,-120,-170,-120,-175}
jointLimitsR={340,240,340,240,340,240,350}
J1_position=10*math.pi/180 -- I want Joint 1 to stay at 10 degrees
sim.setJointPosition(jh[1],J1_position) -- set Joint 1 to 10degrees
-- define IK parameters
simBase=sim.getObjectHandle(sim.handle_self)
simTarget=sim.getObjectHandle('LBR_iiwa_target')
simTip=sim.getObjectHandle('LBR_iiwa_tip')
ikEnv=simIK.createEnvironment()
ikGroup=simIK.createIkGroup(ikEnv)
ikElement,simToIkMap=simIK.addIkElementFromScene(ikEnv,ikGroup,simBase,simTip,simTarget,simIK.constraint_pose)
ikTip=simToIkMap[simTip]
ikJoints={}
for i=1,#jh,1 do
ikJoints[i]=simToIkMap[jh[i]]
end
simIK.setJointPosition(ikEnv,ikJoints[1],J1_position) -- set IKjoint position of Joint 1
simIK.setJointMode(ikEnv,ikJoints[1],simIK.jointmode_passive) -- set joint 1 to passive mode
-- this finds the solution but Joint 1 is not 10deg
c=simIK.getConfigForTipPose(ikEnv,ikGroup,ikJoints,1.4,0.04,{1,1,1,1},nil,nil,nil,jointLimitsL,jointLimitsR)