MPU9150 Accelerometer, Gyro, Temperature, Compass icon MPU9150 Accelerometer, Gyro, Temperature, Compass MPU9150 ARC control reads compass, gyro, accelerometer and temperature via I2C, initializes and sets EZ-Script variables on demand. Try it →
Canada
YouTube
Asked — Edited
Resolved Resolved by DJ Sures!

How Can Two Commands Be Run At The Same Time?

I am trying to get two commands to run at the same time ( without success ). For example:


Left(1,2000)
ControlCommand("Auto Position", AutoPositionFrame, "Stretch Left", 10,1,1)

The program runs the first line, once that is completed then the next line runs. Is there a way to have them run simultaneously?


ARC Pro

Upgrade to ARC Pro

Subscribe to ARC Pro, and your robot will become a canvas for your imagination, limited only by your creativity.

Author Avatar
PRO
Synthiam
LinkedIn Thingiverse Twitter YouTube GitHub
#1  

First, we'll change your question to "how to run two commands consecutively without delay". This is because a computer runs instructions one at a time. A program is a list of instructions. Each instruction is read and then run. That's how computers work. What you don't see is the small lag between commands/instructions, which gives the appearance of "things happening at the same time".

So let's now look at your code...

The first command is specified Left to run for 2,000 ms (which is two seconds). You're asking the command to run for two seconds. This means you can't expect the next command to execute until the first command has completed, which will take 2 seconds.

Perhaps what you can do is this...


left(1)
ControlCommand("Auto Position", AutoPositionFrame, "Stretch Left", 10,1,1)
Sleep(2000)
Stop()

#2  

Thanks DJ. That added some clarity, it's the order of the commands as well. This is giving me what I am looking for;


ControlCommand("Auto Position", AutoPositionFrame, "Stretch Left",10,1,1)
left()
Sleep(3000)
Stop()