Hello,
I setup a robot and defined IK groups and set them to all explicit. In a lua script I call sim.handleIKGroup() each step in sysCall_actuation(). That works fine.
When the target is to far away the robot arm do wild gestures, which I want to avoid. The easiest is to calculate some distance and restore the simulation. In the CoppeliaUI ther is a "Edit conditional params" window with "Restore if". Is there some restore functionality accessible by lua? Alternatively I would save and restore all joint positions in code. Is there a better way instead "freezing" the robot arm?
Thanks,
Chris
Restore simulation
Re: Restore simulation
Hello Chris,
it seems you are still using the old IK functionality (i.e. the one you set up via the GUI). From CoppeliaSim V4.2, IK should be entirely set up and handled programmatically, which makes things much easier, also for debugging. All demo scenes starting with V4.2 use the new approach. In there, you'd use simIK.setIkGroupFlags(ikEnv,ikGroup,4+8)
To do something similar with the old IK functionality, you'd do something like:
With spherical joints, you'd have to adjust the code somewhat.
Cheers
it seems you are still using the old IK functionality (i.e. the one you set up via the GUI). From CoppeliaSim V4.2, IK should be entirely set up and handled programmatically, which makes things much easier, also for debugging. All demo scenes starting with V4.2 use the new approach. In there, you'd use simIK.setIkGroupFlags(ikEnv,ikGroup,4+8)
To do something similar with the old IK functionality, you'd do something like:
Code: Select all
sim.setThreadAutomaticSwitch(false) -- in case you are running threaded
local allJoints=sim.getObjectsInTree(robotBaseHandle,sim.object_joint_type,0)
local allPositions={}
for i=1,#allJoints,1 do
allPositions[allJoints[i]]=sim.getJointPosition(allJoints[i])
end
sim.handleIkGroup()
if (wantToRestore) then
for i=1,#allJoints,1 do
sim.setJointPosition(allJoints[i],allPositions[allJoints[i]])
end
end
sim.setThreadAutomaticSwitch(true)
Cheers