When the inverse motion solution module was used, the robot arm model was incorrectly displayed and IK model could not be used.
this is the photo and subscript codes.
Code: Select all
function sysCall_init()
local simBase=sim.getObject('.')
local simTip=sim.getObject('./tip')
local simTarget=sim.getObject('./testPose1')
-- create an IK environment:
ikEnv=simIK.createEnvironment()
-- create an IK group:
ikGroup_undamped=simIK.createGroup(ikEnv)
-- set its resolution method to undamped:
simIK.setGroupCalculation(ikEnv,ikGroup_undamped,simIK.method_pseudo_inverse,0,6)
-- create an IK element based on the scene content:
simIK.addElementFromScene(ikEnv,ikGroup_undamped,simBase,simTip,simTarget,simIK.constraint_pose)
-- create another IK group:
ikGroup_damped=simIK.createGroup(ikEnv)
-- set its resolution method to damped:
simIK.setGroupCalculation(ikEnv,ikGroup_damped,simIK.method_damped_least_squares,1,99)
-- create an IK element based on the scene content:
simIK.addElementFromScene(ikEnv,ikGroup_damped,simBase,simTip,simTarget,simIK.constraint_pose)
end
function sysCall_actuation()
if simIK.handleGroup(ikEnv,ikGroup_damped,{syncWorlds=true})~=simIK.result_success then
-- the position/orientation could not be reached.
-- try to solve with the damped method:
simIK.handleGroup(ikEnv,ikGroup_damped,{syncWorlds=true})
-- We display a IK failure report message:
sim.addLog(sim.verbosity_scriptwarnings,"IK solver failed.")
end
end
function sysCall_cleanup()
-- erase the IK environment:
simIK.eraseEnvironment(ikEnv)
end