Asked — Edited
Resolved Resolved by Rich!

Is There A Global Command For Repeating A Script That Was Just Executed?

I am looking to see if ARC has a global command for repeating the last script executed.

Example:


#Nudge Right Script
# Turn turn the robot right just a little at a speed of 150, then return to max motor settings at 255
right(150, 200)
right(255, 1)
stop()


#Nudge left Script
# Turn turn the robot left just a little at a speed of 150, then return to max motor settings at 255
left(150, 200)
left(255, 1)
stop()

Then I would like to be able to repeat the last script executed, so I can make a Speech Recognition ControlCommand call to the "RepeatLastScript", that could repeat the last script played, so I can just use the phrase "Again", and possibly another one for "More", which would play the last executed Script twice.

Thanks,

ZionPhil


ARC Pro

Upgrade to ARC Pro

Elevate your robot's capabilities to the next level with Synthiam ARC Pro, unlocking a world of possibilities in robot programming.

United Kingdom
#1  

Not that I'm aware of however a solution would be to add a variable to the end of each script and use this variable to see what was last run.

I.E. at the end of each script have

$lastrun = "Script Name Here"

Obviously change the Script Name Here part in each case.

Then, have your "Again" command use IF to check i.e.

IF($lastrun = "nudge left")
  ControlCommand("nudge left", ScriptStartWait)
ElseIF($lastrun = "nudge right")
  ControlCommand("nudge right", ScriptStartWait)
ElseIf($lastrun = "turn left")
  ControlCommand("turn left", ScriptStartWait)
ElseIf...
  and so on
...EndIf
#2  

Wow @Rich . That worked perfect.

I put the following code in the Speech Recognition Window under the Phrase "Again".


IF($lastrun = "Nudge Left")
  ControlCommand("Script Manager", ScriptStartWait, "Nudge Left")
ElseIF($lastrun = "Nudge Right")
  ControlCommand("Script Manager", ScriptStartWait, "Nudge Right")
ElseIf($lastrun = "Nudge Forward")
  ControlCommand("Script Manager", ScriptStartWait, "Nudge Forward")
ElseIf($lastrun = "Nudge Reverse")
  ControlCommand("Script Manager", ScriptStartWait, "Nudge Reverse")
EndIf

Thanks again Rich!

ZIonPhil

United Kingdom
#3  

If you have other scripts running these movements it may cause a few small issues but if they are only voice controlled it should be fine.

I'm happy to help.

#4  

So the solution to that would be to duplicate the scripts, but under different names if other scripts needed to ControlCommand to the same action?

United Kingdom
#5  

The issue would be that the last speech triggered script and the last run script may not be the same. An alternative, have the speech commands run the variable then ControlCommand to fire the script, so basically a 2 line script in the speech recognition command, the first line sets the variable, the second is the controlcommand.

#6  

That's the way I am doing it. Thanks.