Welcome to Synthiam!

Program robots using technologies created from industry experts. ARC is our free-to-use robot programming software that makes features like vision recognition, navigation and artificial intelligence easy.

Get Started
Asked — Edited

Script Done Command

Hey again everyone. Happy New Year!

New question... without using sleep commands is there a way to start another script when another finishes? Reasoning for this is.. I'd like to showcase all functions of my machine. So basically when I say" robot what can you do" it would start with " I can move my head" followed with head movement, when this script is done it is followed by " I can move my arms" and the arms move etc etc. All of my movements have been made in the script manager being easily linked via control command. Just thought it would be a neat idea. Script done go to next script. Thanks guys!

Chris

In the Allen Bradley plc programming world we'd call it "step programming "

#1  
There may be a better way to do this, but I would do it like this. I assume you don't always want the scripts to each run in sequence, so I would use a variable to turn on "demo mode". At the end of each script, I would check if that variable is on or off, and if it is on, I could execute the next script.

So for example, in the init script, you set the variable to off so that other scripts that look at it don't error.

Code:


$demomode="OFF"


Then, at the end of each script:

Code:


if $demomode="ON"
ControlCommand( "Script Manager", ScriptStart, "NextScript" )
endif


Were "NextScript" is actually the name of the script that should execute after this one.

Finally, you need one more script that turns on demo mode, and starts the first script:

Code:


$demomode="ON"
ControlCommand( "Script Manager", ScriptStart, "FirstScript" )



Alan
PRO
Synthiam
#2  
The easiest and more effecient way is to use the built-in ScriptStartWait command..

1) Load ARC

2) Press EXAMPLE PROJECTS from the Bookmarks window

3) Enter the EZ-Scripts Examples folder

4) Either locate "Procedural 3" project or search for "ScriptStart"

Code:


# Run script and wait for it to finish
ControlCommand("One Script", ScriptStartWait)

# Now run the next script and wait for it to finish
ControlCommand("Another Script", ScriptStartWait)

Print("There are no more scripts")


For more information about example EZ-Script projects, visit this activity: http://www.ez-robot.com/Tutorials/Lesson/22?courseId=6
#3  
Well... That is certainly better, and I looked for something like that in the script manual in ARC before answering because I was sure I had seen it, but the command is not documented......

Alan
#5  
But how would I know what "ScriptStartWait does if it is not documented without looking at every tutorial and sample? Like I said, I knew I had seen something like this. I probably looked at that sample a couple of years ago, but without a document to reference, it is very difficult to remember every thing that ARC can do.

I'll drop it since we have answered the original question, and the solution is elegant, but this is a recurring theme...

Alan
PRO
Synthiam
#6  
The command is assembled using 3 words, Script Start and Wait. The purpose of using descriptive commands is to identify what they do with words, much like a short sentence.

ControlCommand() is how controls speak to other controls. Each control has it's own ControlCommand, this includes 3rd party plugins as well. ControlCommands() are Control specific and not part of the EZ-Script language. ControlCommands() are documented by their respective control using the Cheat Sheet or Right-Click in the editor to display.

The recurring theme only applies to those who forget to use the CheatSheet tab or Right-Click in the editor - neither of which you had done when answering the question.

The recommended first point of action to identify the capabilities of a Control is to look in the CheatSheet tab or Right-Click in the editor, each of which will return the same results.
#7  

Quote:


The recurring theme only applies to those who forget to use the CheatSheet tab or Right-Click in the editor - neither of which you had done when answering the question.


That is insulting, and innacurate.

We clearly are never going to agree on how software should be documented, so subject dropped.

Alan
PRO
Synthiam
#8  
I would never want to insult you or come off that way. My response may sound mechanical because i'm juggling a few other tasks while responding to this.

The ControlCommand() uses self documenting descriptions for commands. If your suggestion is to add another layer of documentation to the ControlCommand() Cheat Sheet display, then that's duly noted. However, keep in mind that the CheatSheet and all uses of it would increase in length/size exponentially with paragraph of description per self-documented command... and be even more difficult to read, considering the CheatSheet is already being skipped as a source for available commands.
PRO
Synthiam
#9  
Oh - Adding to @kamaroman68's question... because the question asks about movement, i suspect this is using the Auto Position Control? Or at least the secondary scripts are. So the answer of ScriptStartWait won't actually work because the question may actually be regarding how to wait for an Auto Position to finish.

In which case, remember that the documentation of ControlCommand() states that that is "sends a command to another control". So, if you tell the Auto Position Control to execute an action, it will do so and continue to the next command. This means it does not wait for the Auto Position Action to finish. The ControlCommand() to start an action simply tells the Auto Position to begin executing that action, and does not wait for it to complete.

There is a variable in Auto Position called $AutoPositionStatus, that can be viewed in the Auto Position Config screen -or- in the Variable List Tab when editing scripts.

User-inserted image


User-inserted image


That variable, as the blue question mark next to it describes, will change from 0 to 1 based on the status of the Auto Position control (is it running or not). So, you can launch an Auto Position and wait for it to finish like such...

Code:


ControlCommand("Auto Position", AutoPositionAction, "Forward")

# Wait a moment to ensure the Auto Position has started running
Sleep(100)

# Wait for the Auto Position action to end
WaitFor($AutoPositionStatus = 0)


This can be taught using either RoboScratch or Blockly, both of which present this as a lesson by using the Auto Position (Wait) functions.

For example in RoboScratch...
User-inserted image


Creates the following code....
User-inserted image


And in Blockly...
User-inserted image


Which generates...

User-inserted image
#10  
The issue is not that the Cheat Sheet doesn't work, but there is nowhere to find documentation for some of the functions this just being one example.

I did in fact attempt to use cheatsheet and didn't see anything that looked useful, so wrote up the way I knew would work.

Scriptstartwait doesn't sound like it does what it does. If it was scriptstopwait, I might have tried it even without documentation since the name looked like what I was looking for. Now that you have defined it, imakes perfect sense, just not intuitively clear without that definition.

I also looked at getControlValue to see if there was anything useful, but it is also poorly documented (the document says to see below for all values, then the only documented value is "pause").

Alan
#11  
Auto position is Not being used. I script all positions manually. Thanks again guys!
#12  
Not siding with anyone here but to me ControlCommand("Script", ScriptStartWait) worked exactly how I assumed it would when I first starting using the command... I admit I am guilty of not reading manuals or "how to" documentation as much as I should.... I usually start messing with stuff first then if I get stuck I look for a video and if I have to, read documentation... I have a hard time keeping focus while reading...

I prefer videos over documentation.... I learn much faster and better visually... For instance I learned how to change my own motorcycle tires with simple tools (tire irons) by watching an youtube video.... I would have never been able to do that by reading an "how to" manual on changing your own tires... Unless it had a lot of pictures that is :)