Hello Coppelia,
I'd like to achieve the effect that a command is executed after the previous one is fully finished.
For example, I have two Inverse Kinematics movements, but I want the second one to be executed after the first one is done (now what I do is to do sim.wait(some time) or use time.sleep in python remote API), is there some way that I can get a signal indicating that the previous command is done so I don't need to wait or sleep?
Thank you!
Start a motion after the previous motion is done (or command)
Re: Start a motion after the previous motion is done (or command)
Hello,
if you are using a threaded script, then you simply write the commands sequentially. You can also use sim.wait in there. From a non-threaded script things are a bit different and will depend on how you implemented things. But the recommended path is to use a threaded script for that. e.g.:
Cheers
if you are using a threaded script, then you simply write the commands sequentially. You can also use sim.wait in there. From a non-threaded script things are a bit different and will depend on how you implemented things. But the recommended path is to use a threaded script for that. e.g.:
Code: Select all
function sysCall_init()
corout=coroutine.create(coroutineMain)
end
function sysCall_actuation()
if coroutine.status(corout)~='dead' then
local ok,errorMsg=coroutine.resume(corout)
if errorMsg then
error(debug.traceback(corout,errorMsg),2)
end
end
end
function coroutineMain()
-- execute command 1
sim.setIntegerSignal("execDone",1)
-- execute command 2
sim.setIntegerSignal("execDone",2)
sim.wait(1)
-- execute command 3
sim.setIntegerSignal("execDone",3)
end