gScript is an interpreted language similar to assembly. A gScript source code file is a plain text file with one statement per line. Statements are executed in sequence from top to bottom. A statement has the form
COMMAND ARG0 ARG1 ... ARGN
COMMAND
must be one of the build in commands as specified below. Arguments can be of various forms, including numeric and string literals, variables, or references to memory. The syntax for these forms will be described below.
The gScript interpreter has memory that is split into two parts. The first is a variable table. When you reference a variable with the $VAR
syntax, gScript looks into the variable table to either read or write to that variable. Whether a read or write occurs depends on the command. Trying to read from a variable that has not been initialized will result in an error. The second part of memory is called Main Memory. It consists of an array of memory cells that can be accessed with bracket syntax, e.g. [10]
to access the cell at address 10. The bracket syntax can also be used in conjuntion with variables. This is accomplished via the syntax [$var]
.
Comments are indicated with a #
, with all characters after it being ignored.
# This whole line is a comment
ADD $res 12 -6 # This a comment sharing a line with a statement.
To reference specific lines of code, for example when using a GOTOIF
, Labels can be used. The syntax for labels is the following:
@LABEL COMMAND args
The presence of a label does not effect the execution of the statement on its line.
gScript has a simple type system, supporting four types in memory (both for variables and in main memory) and five types for literals. In memory, the four supported types are integers, floats, 3d vectors, and 3d rotations. Internally, these are all stored as a four-tuple of 64-bit floats with a tag designating the type of the stored value. You can see this in the "Memory View" tab of the main UI. To access specific fields in vectors (and in fact any value), a dot syntax is supported. For example. If there is a variable called $var
, one can access the y
element with $var.y
. It's also important to keep in mind that "integers" are stored as 64-bit floats. This could result in rounding errors for large numbers, so avoid relying on large integers being exact. For literals, in addition to the four memory types, string literals are supported for certain commands. Examples of literals are:
- float:
10.0
,3.14E-2
- integer:
0
,12
,-568
- 3D Vector:
{12,13.7,-2}
, Don't put spaces between the values! - 3D Rotation:
{0.1,0.9,.16,0}
, Again, no spaces - string:
a_string
,"a string with spaces"
, Quote escaping is not currently supported
But what about booleans? Boolean types are not supported in memory, but in commands that expect a boolean (e.g. GOTOIF
) an argument is interpreted as false if the number in the first (the X
) slot rounds to zero. Otherwise, it is interpreted as true.
Does nothing. Used internally.
Format: PASS
Copies the contents of src
to dest
.
Format: COPY dest src
dest
: Writable location to copy tosrc
: Readable location to copy from
Used to print to the console on the bottom of the UI. The arguments are any readable value while format
specifies how the arguments are to be printed. Supported format codes are listed in the table below
gScript Format | Description |
---|---|
%f | Equivalent to the printf format string %0.3f |
%d | Equivalent to the printf format string %d |
%v | Formats the value as a vector. {x,y,z} |
%r | Formats the value as a rotation. {x,y,z,w} |
%b | Evaluates argument as a boolean. Becomes either True or False |
Format: PRINT format arg1 arg2 argn
format
: The format stringarg1
,arg2
,argn
: Readable values to insert into format string
Used for flow control. Goes to the command at the line specified by dest
. Recommend using in conjunction with labels to be robust against changing line numbers.
Format: GOTO dest
dest
: The address of the statement to execute next. Can be a Label.
Used for flow control. Goes to the command at the line specified by dest
if the cond
evaluates to True
, otherwise proceed to the next statement. Recommend using in conjunction with labels to be robust against changing line numbers.
Format: GOTOIF dest cond
dest
: The address of the statement to execute next. Can be a Label.cond
: If interpreted asTrue
thenGOTO
dest
, otherwise proceed to next statement.
Same as GOTOIF
, except it goes to the command at dest
if cond
is evaluated to False
.
Format: GOTOIFN dest cond
dest
: The address of the statement to execute next. Can be a Label.cond
: If interpreted asFalse
thenGOTO
dest
, otherwise proceed to next statement.
Adds the two arguments piecewise and stores the result in dest
. The type of dest
is copied from arg1
.
Format: ADD dest arg1 arg2
dest
: Writable location for the result of the additionarg1
: Readable location for the first input to the addition.arg2
: Readable location for the second input to the addition.
Subtracts the two arguments piecewise and stores the result in dest
. The type of dest
is copied from arg1
. The operation is equivalent to dest = arg1 - arg2
.
Format: SUB dest arg1 arg2
dest
: Writable location for the result of the subtractionarg1
: Readable location for the first input to the subtractionarg2
: Readable location for the second input to the subtraction
Increments the first, the x
, field in arg1
by 1 and stores the result in dest
.
Format: INC dest arg1
dest
: Writable location for the result of the incrementarg
: Readable location for the value to be incremented
Decrements the first, the x
, field in arg1
by 1 and stores the result in dest
.
Format: DEC dest arg1
dest
: Writable location for the result of the decrementarg
: Readable location for the value to be incremented
Pauses execution for the specified number of milliseconds.
Format: WAIT time
time
: Readable specifying the number of milliseconds to wait
Computes a position/orientation of a part in the gantry's coordinate system by comparing measured reference points with reference points defined by mechanical drawings of that part.
Format: FIT pos rot type fid_tr fid_br fid_bl fid_tl
pos
: Writable location to store the position resulting from the fitrot
: Writable location to store the orientation resulting from the fittype
: The type of part that is being fit. Currently eitherBBM
orHDI
.fid_tr
: Top-right fiducial positionfid_br
: Bottom-right fiducial positionfid_bl
: Bottom-left fiducial positionfid_tl
: Top-left fiducial position
Moves the X,Y,and Z axes to their home positions.
Format: HOME
Moves the gantry to the absolute position of the vector specified by pos
.
Format: MOVETO pos speed
pos
: 3D Vector specifying an absolute position to move tospeed
: Optional number to specify the speed of the motion in mm/s. If omitted, use the (rather slow) default speed.
Moves the gantry through the displacement specified by the vector dis
Format: MOVEREL dis speed
dis
: 3D Vector specifying a relative motionspeed
: Optional number to specify the speed of the motion in mm/s. If omitted, use the (rather slow) default speed.
Moves the gantry to the named position pos_name
. It must be one of the named positions found in safe_move_pos_data.dat
.
Format: MOVESAFE pos_name
pos_name
: A string literal for the name
Reads the current position of the gantry and saves it into pos
.
Format: GETPOS pos
pos
: A writable location to save the current x/y/z position
Rotates the gantry head by rot
degrees.
Format: ROTATE rot
rot
: The amount to rotate in degrees
Reads the current rotation of the gantry head in degrees and saves it into rot
.
Format: GETROT arg1
rot
: A writeable location to save the current rotation in degrees
Format: JOYSTICK cam_name
Enables the Joystick. If cam_name
is supplied and matches one of the cameras as specified in camera_configuration.ini
, a video stream from that camera is shown in the popup window. Execution of the script will halt until the 'C' button is pressed on the joystick.
cam_name
: The camera identification for the popup feed. If blank, no image is shown.
Fetches an image from the specified camera. If filename is specified, the image is saved to that location. Otherwise, a pop-up window will display the image until dismissed.
Format: SNAPSHOT cam_name filename
Sets the specified vacuum channel to either on or off depending on the boolean evaluation of state
.
Format: SETVAC chan state
chan
: The channel name of Vacuum to set. Must be one of the channels listed inmanifold_parameters.ini
.state
: A readable value interpreted as a boolean.
Format: GETVAC chan dest
chan
: The channel name of Vacuum to getdest
: writable location to store that channel's state
Tooled Routines call functions that are defined by the "Tool" subclasses of the LabVIEW Gantry Class. To call these, the script must first execute the LOADTOOL
command for the specific tool. Afterwards, the UNLOADTOOL
command must be called.
"Loads" the specified tool. This means different things for different tools. For example, PICKER
and GRABBER
loading means moving the gantry to the tool rack and picking up that tool, while for CAMERA
and SYRINGE
it currently just does internal bookkeeping.
Format: LOADTOOL toolname
toolname
: One ofCAMERA
,SYRINGE
,PICKER
, orGRABBER
.
Format: UNLOADTOOL
Format: AUTOFOCUS res range steps
res
: Writable location to save the position of max focus in the specified range.range
: Size of window to search for maximum focus centered around the current position.steps
: The number of samples to take withinrange
.
Format: FINDFID loc fidtype
loc
: Location of the fiducial in gantry coordinates. If no fiducial was found, the result will be {-1,0,0,0}.fidtype
: Specify the type of fiducial you want to find. Needs to correspond to a section infiducial_parameters.ini
Invokes the Syringe Tool potting routine. Must supply the start and end positions as well as the offset between the gantry camera and the needle tip. Currently, potting parameters (speed, tip-height, etc.) are read from the POTTING
section of general_configuration.ini
.
Format: POTLINE start end offset
start
: 3D position of the start of the desired line of encapsulantend
: 3D position of the end of the desired line of encapsulantoffset
: Calibrated 3d offset of the needle tip.
Format: POTLINE pos offset
start
: 3D position of the desired dot of encapsulantoffset
: Calibrated 3d offset of the needle tip.
NOT IMPLEMENTED
NOT IMPLEMENTED