Asked — Edited

Script Priority

I am a novice code writer but am learning. I have two questions I need help with.

  1. I am writing script for my DIY robot Max. I have script that includes an AutoPosition event. The question is how to I keep from all the script running at the same time. In my script I want a line of code to finish before the next line of code starts. I have looked and failed to find the answer on my own.

  2. My second question is opposite the first. Since AutoPosition doesn't allow for control of modified servos I am writing script that I want to run at the same time the AutoPosition script is running.

It seems that my problem really comes down to controlling the order script runs.

I will say that EZ-Robot has the most quality information I have ever seen in helping people to solve their own problems. It is just that I have trouble finding where that information is.

Any help would be greatly appreciated.

confused


ARC Pro

Upgrade to ARC Pro

Experience the transformation – subscribe to Synthiam ARC Pro and watch your robot evolve into a marvel of innovation and intelligence.

PRO
Synthiam
#1  
  1. Scripts execute one line at a time. Each line is a command. When a command is executing, the script engine will not continue until it has completed. Computers and cpus work this way. They each process one command at a time. This is inherit to all programming languages and the way computers work.

post your script.

  1. the Auto Position does indeed support continuous rotation servos, because they are still servos. If calibrated correctly, 90 degrees on a continuous rotation servo is STOP, and further away from 90 in either direction will change the speed of that direction. More information here: https://synthiam.com/Tutorials/Lesson/48?courseId=6#part5

Also calibration of continuous rotation is here: https://synthiam.com/Tutorials/UserTutorials/190/1

PRO
Synthiam
#2  

It occurred to me that both RoboScratch and Blockly in ARC were designed for beginners. Perhaps it will be beneficial to start with one of those interfaces?

You don't see those interfaces because your ARC is Version: 2017.01.10.01. Please consider upgrading ARC, it's free.

#3  

Thanks DJ. Great thanks for helping.

Here is my code. When I run it the voice starts and the Auto Position starts and runs at the same time. I want the voice to start and end and then want the Auto Position script to run. I have been using RoboScratch then copying and pasting the code into a script box. Then I modify it to do what I want. It is faster.

Also I have at the end of the code I had to write Both Arms Park code twice to get max to complete the park function.


Say("Hi caleb and joel.  I want to show you my dance moves.  You can join in if you want.")


ControlCommand("Auto Position", AutoPositionAction, "Dance 1")
Sleep(6000)
ControlCommand("Auto Position", AutoPositionStop)
Stop()



ControlCommand("Auto Position", AutoPositionAction, "Both Arms Park")
Sleep(6000)
ControlCommand("Auto Position", AutoPositionStop)
Stop()


ControlCommand("Auto Position", AutoPositionAction, "Both Arms Park")
sleep(100)
waitfor($AutoPositionStatus = 0)

PRO
Synthiam
#4  

Blockly or RoboScratch may be useful. I recommend upgrading to the latest ARC to ensure you have both.

Here is the activity guide, which will help you with information on using RoboScratch or Blockly: https://synthiam.com/Tutorials/Course/6

This example would be extremely easy and best to use RoboScratch or Blockly - both generate code for you.

*Note: assuming "Both Arms Park" is not set to repeat, here's your code re-written:


# Speak out of the ezb speaker and wait for it to finish
SayEZBWait("Hi caleb and joel.  I want to show you my dance moves.  You can join in if you want.")

# Run the dance for 6 seconds
ControlCommand("Auto Position", AutoPositionAction, "Dance 1")
Sleep(6000)

# run Both Arms Park and wait until it's finished (assumin Both Arms Park is not marked as Repeat)
ControlCommand("Auto Position", AutoPositionAction, "Both Arms Park")
sleep(100)
waitfor($AutoPositionStatus = 0)

*Note: assuming "Both Arms Park" is set for repeat, here's your code re-written:


# Speak out of the ezb speaker and wait for it to finish
SayEZBWait("Hi caleb and joel.  I want to show you my dance moves.  You can join in if you want.")

# Run the dance for 6 seconds
ControlCommand("Auto Position", AutoPositionAction, "Dance 1")
Sleep(6000)

# run Both Arms Park for 6 seconds
ControlCommand("Auto Position", AutoPositionAction, "Both Arms Park")
Sleep(6000)

#5  

This is very clear now. I understand all the code and am going to change it. Thank you for helping me. I really love the help I get from EZ-Robot. Thanks DJ