I'm trying to write the well known IK resolution (simIK) in python.
I think everything in the code below is correct. I don't get any error messages and the Ik resolution flag is set to 1 (which means that the IK is succesfully being computed). However, the tip of my kinematic chain does not move at all. What am i doing wrong?
Code: Select all
#python
def setIK(simBase, simTip, simTarget):
ikEnv = simIK.createEnvironment()
ikGroup = simIK.createGroup(ikEnv)
simIK.setGroupCalculation(ikEnv, ikGroup, simIK.method_damped_least_squares, 0.1, 99)
ikElement = simIK.addElementFromScene(ikEnv, ikGroup, simBase, simTip, simTarget, simIK.constraint_pose)
simIK.setElementPrecision(ikEnv, ikGroup, ikElement[0], self.precision)
self.ikEnv = ikEnv
self.ikGroup = ikGroup
def solveIK():
result, flag, precision = simIK.handleGroup(self.ikEnv, self.ikGroup, {'options.syncWorlds': True, 'options.allowError': False})
if result != 1:
print("Warning! Inverse kinematics could not be solved. Error code: ", flag)
sim.stopSimulation()
def sysCall_init():
sim = require('sim')
simIK = require('simIK')
linear_tolerance = 1e-6
angular_tolerance = 1e-4
self.precision = [linear_tolerance, angular_tolerance]
simBase = sim.getObject('/base')
simTip = sim.getObject('./tip')
simTarget = sim.getObject('/target')
setIK(simBase, simTip, simTarget)
def sysCall_actuation():
solveIK()
def sysCall_sensing():
# put your sensing code here
pass
def sysCall_cleanup():
# do some clean-up here
pass
Thanks!