Asked — Edited

Script Command Manual

Functions

Sleep (milliseconds) Pauses for specified milliseconds Example: Sleep(1000)

SleepRandom (lowMilliSec, highMilliSec) Pauses for a random millisecond delay between the 2 provided values Example: SleepRandom(1000, 5000)

Servo (servoPort, position) Move servo to the specified position Example: Servo(D14, 25)

ServoUp (servoPort, count) Increment the servo position value up by specified count Example: Servo(D14, 1)

ServoDown (servoPort, count) Decrement the servo position value by specified count Example: Servo(D14, 1)

ServoRandom (servoPort, lowPosition, highPosition) Move the servo to a random position between low and high Example: Servo(D14, 10, 20)

Release (servoPort) Release a servo from holding its position Example: Release(D14)

Move (servoPort, [forward/stop/reverse]) Set a modified servo to move Example: Move(D14, FORWARD)

Set (digitalPort, [on/off/true/false]) Set a digital port state to either on or off Example: Set(D2, OFF)

ToggleDigital (digitalPort ) Toggle the digital port

Digital_Wait (digitalPort, [on/off/true/false]) Wait until the digital port status has changed Example: Digital_Wait(D12, ON)

ADC_Wait (adcPort, [higher/lower/equals], value) Wait until ADC port is higher or lower than specified value Example: ADC_Wait(ADC0, HIGHER, 50)

Movement_Wait ([forward/reverse/stop/left/right]) Wait until a movement from the Movement Panel is specified. Even if another script executes a movement, this will execute Example: Movement_Wait(FORWARD)

Servo_Wait (digitalPort, [higher/lower/equals], value) Wait until the servo Port is higher or lower than specified value. Zero can be specified as a value for a stopped servo. Example: Servo_Wait(D5, HIGHER, 20)

WaitForServoMove (servoPort) Waits for the specified servo to move. Unlike Servo_Wait, this function does not wait for a specific value. It simply returns once the servo has moved to a new position. Example: WaitForServoMove(d0)

Ping_Wait (triggerPort, echoPort, [higher/lower/equals], inches) Wait until the Ping Sensor distance is higher or lower than specified value in inches. Trigger and Echo are Digital Ports Example: Ping_Wait(D3, D4, HIGHER, 50)

Forward( [fastest/fast/slow/slowest] ) Using the servo port settings from a Movement Panel Control, this will start your robot in the Forward direction. Optionally, you can provide the speed or leave the parameter empty. You will require at least one Movement Panel to be configured within the project. This function will control that movement panel.

Reverse( [fastest/fast/slow/slowest] ) Using the servo port settings from a Movement Panel Control, this will start your robot in the Reverse direction. Optionally, you can provide the speed or leave the parameter empty. You will require at least one Movement Panel to be configured within the project. This function will control that movement panel.

Stop() Using the servo port settings from a Movement Panel Control, this will stop your robot. You will require at least one Movement Panel to be configured within the project. This function will control that movement panel.

Left( [milliSeconds] ) Using the servo port settings from a Movement Panel Control, this will turn your robot left. You will require at least one Movement Panel to be configured within the project. This function will control that movement panel. Optionally, you can specify the number of milliseconds to turn. Example #1: Left() Example #2: Left(200)

Right( [milliSeconds] ) Using the servo port settings from a Movement Panel Control, this will turn your robot right. You will require at least one Movement Panel to be configured within the project. This function will control that movement panel. Optionally, you can specify the number of milliseconds to turn. Example #1: Right() Example #2: Right(200)

Sound_Random( digitalPort, noteLength, noteCount) Plays a little random melody out of the EZ-B speaker that is on the specified digitalPort. Note length is in MS, and noteCount is the number of notes to play.

Sound_Note( digitalPort, noteLength, note) Plays a note out of the speaker that is on the specified digitalPort. Note length is in MS, and note is the number of note to play.

Say( text to speech ) Speaks the text that is specified within the brackets out of the PC Sound Card.

SendI2C( hexAddress, data, .... ) Send a series of data to the specified hex address over the I2C interface Data can be Hex (0x09), character ('c'), string ("string"), or decimal (188) Example: SendI2C(0x09, 'n', 0x00, 0x50, 244, "This is text")

SendSerial( digitalPort, baudRate, data, ... ) Send a series of data over the specified port and baud rate Data can be Hex (0x09), character ('c'), string ("string"), or decimal (188) Example: SendI2C(0x09, 'n', 0x00, 244, "This is text")

WaitUntilTime( hour, minute ) Pauses until the specified time. To be cpu friendly, the accuracy is within the minute of the specified time. It will trigger within the minute, just not on the minute. Example: WaitUntilTime(17, 30)

MP3TriggerPlayTrack( digitalPort, baud, trackNumber ) Plays the specified MP3 track from the MP3 Trigger Sheild Example: MP3TriggerPlayTrack( d0, 38400, 1 )

MP3TriggerPlayRandomTrack( digitalPort, baud, lowestTrackNum, highestTrackNum ) Plays a random MP3 track from the MP3 Trigger Sheild between the supplied track numbers Example: MP3TriggerPlayTrack( d0, 38400, 1, 10 )

MP3TriggerNext( digitalPort, baud ) Plays the next MP3 track from the MP3 Trigger Sheild Example: MP3TriggerPlayNext( d0, 38400 )

MP3TriggerPrev( digitalPort, baud ) Plays the previous MP3 track from the MP3 Trigger Sheild Example: MP3TriggerPrevious( d0, 38400 )

MP3TriggerStop( digitalPort, baud ) Stops the current MP3 track from the MP3 Trigger Sheild Starts the mp3 file if not playing Example: MP3TriggerStop( d0, 38400 )

ControlCommand( windowName, windowControlCommand ) Sends a command to the window by its name Example: ControlCommand( "ADC Graph", pause )

Commented Text

Comment a line of code

:Label Defines a label for a GOTO() command Example: :My_Label

Goto( label ) Goto a specific :Label location Example: Goto(My_Label)

If ( servo [Port] [Condition] [Value] ) Queries a servo Port for its position against your condition. Port is a servo Port (between d0 and d20) Condition is either =, , =, Value is an user defined integer If true, the following command (next line) is executed If false, the following command (next line) is skipped Example: If (Servo D0 > 5)

If ( ADC [Port] [Condition] [Value] ) Queries an ADC Port for its value against your condition. Port is an ADC Port (between adc0 and adc7) Condition is either =, , =, Value is an user defined integer If true, the following command (next line) is executed If false, the following command (next line) is skipped Example: If (ADC ADC2 > 50)

If ( Digital [Port] [Condition] [Value] ) Queries a Digital Port for its state against your condition. Port is a Digital Port (between d0 and d20) Condition is either =, Value is either True or False If true, the following command (next line) is executed If false, the following command (next line) is skipped Example: If (Digital D0 false)

References

Multiple EZ-B Boards EZ-Builder supports multiple physical EZ-B Boards connected to your computer. You can specify the board by putting the board number in front of the command. For example: 2.Servo(d0, 8) will move the D0 servo on EZ-B board #2 to position 8. If no board is specified, the first board (zero) is assumed. If using more than one board, the first board is always responsible for movement panels.

ADC Ports ADC0 ADC1 ADC2 ADC3 ADC4 ADC5 ADC6 ADC7 ADC8

Servo/Digital/Uart Ports D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11 D12 D13 D14 D15 D16 D17 D18 D19

Baud Rates 300 1200 2400 4800 9600 19200 38400 57600

Window Control Commands All Controls PauseOn PauseOff PauseToggle

Camera Device
CameraServoTrackEnable
CameraServoTrackDisable
CameraServoTrackToggle
CameraMovementTrackEnable
CameraMovementTrackDisable
CameraMovementTrackToggle

Camera Device Tracking Modes
CameraColorTracking
CameraMotionTracking
CameraView
CameraFaceTracking
CameraAutoTracking

Camera Snapshot
CameraSnapshot

Scripting
ScriptStart
ScriptStop

Personality Generator
RunOnce

Sound Board
Track_0 ... Track_9

Music Notes C1 Db1 D1 Eb1 E1 F1 Gb1 G1 Ab1 A1 Bb1 B1 C2 Db2 D2 Eb2 E2 F2 Gb2 G2 Ab2 A2 Bb2


ARC Pro

Upgrade to ARC Pro

Your robot can be more than a simple automated machine with the power of ARC Pro!

Australia
#1  

Can I have an example for the Forward( [fastest/fast/slow/slowest] ) and Reverse ( [fastest/fast/slow/slowest] ).

Netherlands
#2  

Forward(fastest) or Forward(fast) or Forward(slow) or Forward(slowest)

:D

Australia
#5  

I was wondering what the command was to start a script with a joystick button.

PRO
Canada
#6  

Hi Creativita,

That command would be: ControlCommand( "Script Name", ScriptStart )

where Script Name is whatever you name your script, just don't forget the quotes.

Australia
#8  

Is it possible in ARC to make two servos turn at once by using one command.

#9  

write a script that has two servos moving at once. Then call on that script to start/end.

Australia
#10  

But I need a code to write that will operate two servos at the same time, not one after the other. Or perhaps I am just mis-understanding you. I am new to this so could you please explain it in a relatively simple way.

#11  

if you write a script like:

servo(d0, 28) servo(d1, 28) sleep(1000) servo(d0, 4) servo(d1, 4) sleep(1000)

This will move servos (d0 and d1) at the same time to the respective positions. Since there is no sleep command between the two servos they will move at the same time.

But remember, you need to have a sleep command between movements of the same servo. Or the servo can't resolve between the two commands. It'll just shake and not move fully.

Even though the servo's are commanded to move at the same time, the servos may not move identically because of electronic differences between the two.

Hope this helps.

EDIT: A word of caution, normal sized servo's require about an amp a piece so you need an appropriate power supply that can supply enough current to move multiple servos at the same time without browning out.

Australia
#12  

Thanks for that, I get you now.

Australia
#13  

Hello Again I need a line of code for ARC which will start a script or something similar when the camera detects movement. Is this possible? It would be a great help to me.

PRO
Synthiam
#14  

You sure can...

  1. Create a script control with all your stuff
  2. Name the script control "Test Script"
  3. Then in the "camera found" of Config in the Camera Control, enter this

ControlCommand("Test Script", ScriptStart)

Australia
#15  

Thanks. That will be really helpful for my project.

Australia
#16  

I can't seem to find the "Camera Found" in the Camera window. There is "Colour Found Script" and "Colour Lost". Is the "Colour Found Script" the same as "Motion Found?"

Also I have been having trouble installing the latest ARC. At the top of the ARC window it reads Version 2011.08.10.00. When I click on the "Check for Latest Version" in the Utilities drop box it says that the newer version is available. But when it comes round to installing it a message pops up saying that a newer version is already installed.

PRO
Synthiam
#17  

You may have to uninstall your older version first. Windows Installer is very strange. Sometimes it does silly things.

I misread what you asked. There is no script on motion, but I can make one for you.

Australia
#18  

I will try that. It would be great if you can make a Motion Found and Lost. Perhaps you could do so for all of them (Auto, Motion, Colour and Facial Recognition.)

Canada
#19  

That would be good

Australia
#20  

I have been making a major mistake when writing my scripts. I didn't understand that the Sleep function was neccessary between different lines to prevent them from occuring at the same time. Hopefully I haven't damaged my servos.

#21  

DJ Do you think I should start a "free sample scripts" forum category? I don't want to make the forum cluttered, but it would be nice to just copy paste samples, and choose from a list, like :

Servo scripts:

  1. Left arm wave (with 1 dof slow)
  2. Left arm wave (with 2 dof slow)
  3. Left arm wave (with 3 dof slow)
  4. Left arm wave (with 1 dof fast)
  5. Left arm wave (with 2 dof fast)
  6. Left arm wave (with 3 dof fast)
  7. Head spin (1 time, clockwise)*
  8. Head spin (2 times, clockwise)*
  9. head movement ("no" answer, back and forth 3 times)***
  10. Head movement ("yes" answer, up and down 3 times)***

*warning, must use 360 degree servo for this script or risk damage to Servos, parts, ez-b, etc

** servo needs to be mounted appropriately to go up/down or left/right. (horizontal/vertical selection)

*** you may edit numbers in the script so servo moves arm/head/etc a certain number of times, such as you may want the "yes" answer to go up,down,up,down and that would need a "2" in that script.

I also want to make some for led flashing. TJ Http://www.TheGoodRobot.com

Australia
#22  

I am not sure about the extent of the Goto command. See script below:

: Start WaitForServoMove(D4) Say(Movement Detected) Goto(Start)

This is part of the script I have been working on for camera motion tracking. D4 is my head servo and is being used for servo tracking. With the label and Goto would this script just continue to loop until I stopped it? This would be incredible useful. The idea is that I will start the script with a voice command ("Detect Movement") and will stop it with another command ("Stop Detecting Movement.") It would be more life-like and would save me having to keep repeating the command. If Goto does not loop is there an alternative which will allow me to do the same.

PRO
Synthiam
#23  

You can do that, or the checkbox that says "Repeat"

Australia
#28  

Could you give us a table containing different speeds matched to the values for the ServoSpeed command. I am not sure what is slow and what is fast. Also, what is the standard speed for servos?

PRO
Synthiam
#29  

Oh man i forgot! The servo speed command is accepted but it doesn't do anything right now. I was having huge timing issues with the 20 servo PID's. I'm working on a new servo speed that won't affect timing for other devices. It's on the list too.

And your motion thing is up next btw

Australia
#30  

Thanks. I can't wait. The servo speed has become useful for me now because of the scan scripts I have added. There are three: Scan Left, Scan Right and Scan. The Scan Right rotates the servo slowly to the right on a horizontal axis, the Scan Left rotates the servo slowly to the left on a horizontal axis and the Scan continues to scan back and forth. All of the three scripts stop and the servos return to their original speed when I release the corresponding joystick button. I plan to add a fourth Continuous Scan script which continues to scan even when I release the button. Is there any command which acts as a toggle for starting and stopping scripts? I thought the scripts would be a cool addition and would give the horizontal servo a smooth slow rotation speed, one that I am be unable to achieve with the joystick. I think I am past the major programming stage for my camera. I am simply adding some new features and fixing any mistakes. The building of the security camera is incredibly simple, allowing me to focus on the programming. Sadly I lack the most important part of the whole project, the camera. But don't worry, I am definitely going to buy it from you

PRO
Synthiam
#31  

If a script is set to repeat, then you can scriptStart and scriptStop

Do you want a "toggle/on/off for the repeat" option?

Australia
#33  

Could you also make a start/stop script toggle or something similar, if that is possible

Australia
#34  

I have decided to merge the Continuous Scan Script and Scan Script. The Scan Script will repeat instead of stopping when I release the button. I have replaced the Continuous Scan Script button with a Scan Stop Script. This will allow me to stop and start the scan at will But please still include a toggle on/off for the repeat function. I think that will be very useful in future projects, for all of us

Australia
#35  

I can't seem to get the Move(servo port, [forward, stop, reverse]) to work. I type in Move(D3, Forward), attempt to save and the syntax error message appears. The command I gave is nearly identical to the example

#36  

Do i need a script, or movement script at the same time i use a modified servo Movement Panel to send a command to a motor controller? the motor controller is sabertooth 2x25 and it only has 2 inputs (for controlling 2 motors), it has Signal 1 and Signal 2. i can not get my ez-b to communicate with the motor controller.

PRO
Synthiam
#37  
  1. Setup your controller as RC mode.

  2. Connect the 2 RC pins from the controller to 2 I/O pins of the EZ-B. The I/O pins are not labeled GND or +5. It is the furthest pin out. Make sure it's Digital, not ADC. Check the manual. Digital pins start with a D

  3. Add a Modified servo panel.

  4. Press CONFIG

  5. Select the two ports you connected the SAbertooth controller to

  6. Use the directional arrows to drive your robot

If that doesn't work, your sabertooth isn't configured correctly. Contact their support for assistance on their product and why RC mode doesn't work.

#38  

Hi guys,

I was wondering if there is any way to get the script editor to accept math functions? I'm trying to set up a proper analogue system with potentiometers in place of the Joystick option, but it seems the only way to get it to work is to hard set the values on the ADC, so if the ADC = 10 the servo = 1, if the ADC = 20 the servo = 2, and so on.

Naturally, to get a full servo sweep, this creates a huge amount of code to run every frame and takes about 0.2 seconds to complete the evaluations for a full servo sweep. And this latency leads to the evaluation missing the mark, so the servo position fails to update, unless the the evaluation frame just happens to fall on the exact analogue value of 10 or 20, etc...

What I was hoping for was a way to write an equation that automatically reads the position of the ADC and calculates the servo position accordingly, without having to hard code it. This way, if I'm creating an analogue control system (like a glove or armateur) I'm not forced to destroy a perfectly good USB controller, and I can make my ranges a lot more dynamic.

Any thoughts?

PRO
Synthiam
#39  

Currently the scripting engine does not support variables or math functions. I expected the EZ-SDK for people who wanted that kind of control. It seems the ARC is growing into a development environment. And since then, there are math and variables on the TO-DO list for the future.

#40  

it would a super good add-ons to have variables an math funtions that is about what i am looking for the sonar sensor,plus be really good for analog too,there so many needs for it hope very soon DJ:D

PRO
Synthiam
#41  

Add Control -> Script -> VB

or

Add Control -> Script -> C#

The VB is very easy to use:)

#42  

@DJ Sures Regarding your Post on 5/7/2012:

Is there supposed to be specific controls for VB and C#, With in ARC? Does the Add control -> Scripting -> EZ-Script accept VB/C#?

Not sure what you mean by the post...