Australia
Asked — Edited

Scripting Multiple Robot Actions One After Another

I'm currently using Script Manager to run multiple scripts in sequence. I know that ControlCommand is non-blocking by default but is there a way to wait for a script to finish before executing the next? The idea is to basically wait for each robot to finish asking/answering/doing something before moving on. I've mostly been using WaitFor($AutoPositionStatus = 0) but it doesn't seem to wait consistently for the other robot to finish. In the code below "JD great" starts while "Six answer question" is still running.

Code:

ControlCommand("Script Manager", ScriptStartWait, "JD ask question")

WaitFor($AutoPositionStatus = 0)

ControlCommand("Script Manager", ScriptStartWait, "Six answer question")

WaitFor($AutoPositionStatus = 0)

ControlCommand("Script Manager", ScriptStartWait, "JD great")


Related Hardware EZ-B v4

ARC Pro

Upgrade to ARC Pro

Unlock the true power of automation and robotics by becoming a proud subscriber of Synthiam ARC Pro.

PRO
Synthiam
#1  

$autopositionStatus is only for the status of the auto position. That means it only changes when the status of the Auto Position changes.

Secondly, it appears there would be two Auto Position controls in your project since there’s two robots. That means the autoPositionStatus variable can’t be shared between the two. You have to change the variable of one of the Auto Position controls.

#2  

 I tend to make things more complex than they need to be, but I have done similar things by setting and clearing variables at the beginning and ending of scripts, then having "watcher" scripts looping on waitforchange() on the variable and launching other scripts when the variable changes to the desired value.   This can allow for a great deal of flexibility in where you start a routine, and what happens based on responses from other controls, but again, it is probably way more complex than it needs to be.  Almost every time I post a solution these days DJ points out some built in function I missed.....:)

Alan

Australia
#3  

That is a good point. It hadn't occurred to me that waiting for the $AutoPositionStatus isn't always the same as waiting for a script to finish.

Thanks! That seems to be what's happening. I changed the variable names and it helps but I've also noticed that the Status variable seems to clear itself a little bit before the motion is complete. I might give that setting and clearing method a try.

Thanks for the advice!

PRO
Synthiam
#4  

The status variable does set to 0 (false) when the last command is sent. The reason there’s still a movement is the servos catching up.

This is is a bit difficult with servos because you don’t actually know there position. You only know what position you told them to move to. They could still be moving on last motion instruction.

adding a short pause in the action may help at the end. Or use the sleep() to wait a bit after the status variable changes

Australia
#5  

That makes sense. I've tried using sleep() and that seems to work well enough. I'll try the pause as well and see how that goes. Thanks again.