Wait in script code error

Hello,
i have a problem with this code:

def end_mission(cons, end):
end = True

wait cons == False

end = False
end

the error is wait is not define…

how is possible??
sorry for my english.

thank all

“Wait” is not a command in UR Script. The command for that is sleep. However, sleep looks for a number as an input, not a logical statement like true or false.

For you, you’d want something like:

while(cons != False): <— This could also be written simply as “while(cons):”
sync()
end

1 Like

thank you so much
but
what is sync()?

sync() uses up the available time slice that the code has been given. When doing something like a while loop that does nothing, or a thread that doesn’t do much, you can run into faults that say “thread blah blah blah used too much time” or something similar. Generally, instead of actually doing nothing in your loop, you want to call the sync() command so keep the scheduling in order

So i can use sync() also in thread instead of wait some time?

And if i can use sync() in thead that read data from plc what is the refresh time.
Is sense use sync in this case or not?

Don’t get too hung up on sync(). It really has to do with how operating systems schedule tasks and allocate processor time to achieve them. I just put it in the example because I know from experience that without it, the robot will fault with a “used too much time” error, and throwing that sync() command in there fixes it. In general, if you have a looping thread, put a sync() at the end of it.

As for the thread and PLC, I’m not exactly sure what you’re asking. The robot controller runs at 500Hz. You’ll have to read your PLC documentation to find its scan rate. The sync() command is not doing the actual waiting. The “while(cons != false)” loop is what is doing the waiting. It’s doing nothing (ie waiting) until cons becomes true