sim.wait execution

Typically: "How do I... ", "How can I... " questions
Post Reply
veneneux2804
Posts: 8
Joined: 09 Apr 2024, 09:06

sim.wait execution

Post by veneneux2804 »

Im trying to make my conveyor move after 2s its sensor trigger and I got executed during simulation all the time, how can I fix that?

Code: Select all


sim=require'sim'

function sysCall_init()
    self=sim.getObject('.')
    sensor=sim.getObject('./_sensor')
end
function sysCall_actuation()
    beltVelocity=0
    if sim.readProximitySensor(sensor) > 0 then
        sim.wait(2)
        belVelocity=0.7
    end
    sim.writeCustomTableData(self,'__ctrl__',{vel=beltVelocity})
end
fferri
Posts: 1334
Joined: 09 Sep 2013, 19:28

Re: sim.wait execution

Post by fferri »

You can't use sim.wait in a non-threaded script.

Either check the value returned by sim.getSimulationTime (e.g.: set belVelocity only if t>2), or use a threaded script instead where you can use sim.wait.
Post Reply