public interface ScriptWriter
This API adds support for generating URScript code from URCaps.
Modifier and Type | Method and Description |
---|---|
void |
appendLine(String scriptLine) |
void |
appendRaw(String script) |
void |
assign(String variableName,
String expression)
Variable assignment.
|
void |
assign(Variable variable,
String expression)
Variable assignment.
|
void |
defineFunction(String name) |
void |
defineThread(String threadName)
Start a thread definition with a given thread name.
|
void |
elseCondition()
Adds an else branch.
|
void |
elseIfCondition(String expression)
Adds an else-if branch.
|
void |
end()
Insert an end.
|
String |
generateScript() |
String |
getResolvedVariableName(Variable variable)
Returns a registered variable name that can be used in a script.
|
void |
globalVariable(String variableName,
String expression)
Deprecated.
Use
assign(Variable variable, String expression) instead
Global variable assignment. |
void |
ifCondition(String expression)
Start an if-conditional.
|
void |
ifNotCondition(String expression)
Start a negated if-conditional
|
void |
incrementVariable(Variable variable)
Add 1 to the variable value.
|
void |
returnMethod()
Return from method.
|
void |
runThread(String threadHandle,
String threadName)
Start a previously defined thread.
|
void |
set_payload(double payloadMass)
Sets the payload mass.
|
void |
set_payload(double payloadMass,
double centerOfGravityX,
double centerOfGravityY,
double centerOfGravityZ)
Sets the mass and center of gravity of the payload.
|
void |
set_tcp(double x,
double y,
double z,
double rx,
double ry,
double rz)
Set the Tool Center Point.
|
void |
sleep(double seconds)
Sleep for a number of seconds
|
void |
sync()
Uses up the remaining ”physical” time a thread has in the current
frame.
|
void |
whileCondition(String expression)
Starts a while-loop with a loop invariant.
|
void |
whileNot(String expression)
Starts a while-loop with a negated loop invariant.
|
void |
whileTrue()
Starts a while true loop.
|
void |
writeChildren()
Use this method when generating code for a node that has children nodes.
|
void appendLine(String scriptLine)
scriptLine
- a single line script command and uses auto-indentation.void appendRaw(String script)
script
- append script as is, without auto-indentation.String generateScript()
void writeChildren()
Use this method when generating code for a node that has children nodes. A simple example:
writer.ifCondition(expression)
writer.writeChildren() // let children nodes generate code.
writer.end()
In most cases you probably only want to call writeChildren() once, but it is possible to call it multiple times and thus have children nodes generate their code multiple times.
@Deprecated void globalVariable(String variableName, String expression)
assign(Variable variable, String expression)
instead
Global variable assignment.
variableName
- name of global variableexpression
- expression that is assigned to the global variablevoid assign(String variableName, String expression)
Variable assignment. Assigns the variable without a local or global qualifier. See the Script Manual for the scoping rules.
variableName
- name of the variable, not null.expression
- expression that is assigned to the variable, not null.void assign(Variable variable, String expression)
Variable assignment.
variable
- the variable to assign an expression to, not null.expression
- expression that is assigned to the variable, not null.void incrementVariable(Variable variable)
Add 1 to the variable value.
variable
- the variable to increment, not null.void sleep(double seconds)
Sleep for a number of seconds
seconds
- amount of time to sleep in secondsvoid sync()
Uses up the remaining ”physical” time a thread has in the current frame.
void defineFunction(String name)
name
- Define a function of name namevoid returnMethod()
Return from method.
void end()
void set_payload(double payloadMass)
Sets the payload mass. This function must be called, when the payload weight or weight distribution changes significantly - I.e when the robot picks up or puts down a heavy workpiece.
payloadMass
- in kilogramsvoid set_payload(double payloadMass, double centerOfGravityX, double centerOfGravityY, double centerOfGravityZ)
Sets the mass and center of gravity of the payload. This function must be called, when the payload weight or weigh distribution changes significantly - I.e when the robot picks up or puts down a heavy workpiece.
payloadMass
- in kilogramscenterOfGravityX
- displacement from the tool-mount in meters.centerOfGravityY
- displacement from the tool-mount in meters.centerOfGravityZ
- displacement from the tool-mount in meters.void set_tcp(double x, double y, double z, double rx, double ry, double rz)
Set the Tool Center Point. Sets the transformation from the output flange coordinate system to the TCP as a pose.
x
- Position party
- Position partz
- Position partrx
- Rotation partry
- Rotation partrz
- Rotation partvoid ifCondition(String expression)
Start an if-conditional.
expression
- the expression of the if-sentence, not null.void ifNotCondition(String expression)
Start a negated if-conditional
expression
- the expression of the negated if-sentencevoid elseIfCondition(String expression)
Adds an else-if branch.
expression
- the expression to "else-if" on.void elseCondition()
Adds an else branch.
void whileTrue()
Starts a while true loop.
void whileCondition(String expression)
Starts a while-loop with a loop invariant.
expression
- the loop invariant.void whileNot(String expression)
Starts a while-loop with a negated loop invariant.
expression
- the loop invariant that will be negatedvoid defineThread(String threadName)
Start a thread definition with a given thread name.
threadName
- the name of the new threadvoid runThread(String threadHandle, String threadName)
Start a previously defined thread.
threadHandle
- A variable name which will contain a thread handle that can be
used to control the thread.threadName
- The name of the thread that will be started.String getResolvedVariableName(Variable variable)
DataModel
instance or used for the configuration
of a built-in PolyScope program node.
Please note: The name of a variable in the script can be different from the value of Variable.getDisplayName()
.
You should not use the value of Variable.getDisplayName()
in a script
variable
- a registered Variable, not null.IllegalArgumentException
- if the variable
was not registered in the data model or used for the configuration
of a built-in PolyScope program node.ClassCastException
- if the variable
was not created by VariableFactory
.Copyright © 2018. All rights reserved.