public interface ScriptWriter
Modifier and Type | Method and Description |
---|---|
void |
appendLine(String scriptLine)
Adds a single line of script code using auto-indentation.
|
void |
appendRaw(String script)
Adds script code appending the script code as is without using auto-indentation.
|
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()
Generate a string with the full script code.
|
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. |
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)
Deprecated.
In the script code generated by this method, the 'set_payload(m, cog)' script function will be called
without specifying the optional 'cog' parameter. This means that the currently active TCP will be used as Center
of Gravity (CoG) with the side effect that later calls to the 'set_tcp()' script function will also change the
CoG to the new TCP.
Use set_payload(double payloadMass, double centerOfGravityX, double centerOfGravityY, double centerOfGravityZ)
instead. |
void |
set_payload(double payloadMass,
double centerOfGravityX,
double centerOfGravityY,
double centerOfGravityZ)
Sets the total mass and center of gravity (CoG) of the attached payload.
|
void |
set_tcp(double x,
double y,
double z,
double rx,
double ry,
double rz)
Set the Tool Center Point (TCP).
|
void |
set_tcp(TCP tcp)
Set the Tool Center Point (TCP).
|
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 script code for a node that has children nodes.
|
void appendLine(String scriptLine)
scriptLine
- single line of script code to append.void appendRaw(String script)
script
- script code to append.String generateScript()
void writeChildren()
Use this method when generating script 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.variableName
- name of global variable.expression
- expression that is assigned to the global variable.void 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
- the variable to assign an expression to. Not null
.expression
- expression that is assigned to the variable. Not null
.void incrementVariable(Variable variable)
variable
- the variable to increment. Not null
.void sleep(double seconds)
seconds
- amount of time to sleep in seconds.void sync()
void defineFunction(String name)
name
- Define a function of name name.void returnMethod()
void end()
@Deprecated void set_payload(double payloadMass)
set_payload(double payloadMass, double centerOfGravityX, double centerOfGravityY, double centerOfGravityZ)
instead.Sets the total payload mass.
This function must be called, when the payload weight or weight distribution changes significantly, i.e when the robot arm picks up or puts down a heavy workpiece.payloadMass
- The total payload mass in kilograms.void set_payload(double payloadMass, double centerOfGravityX, double centerOfGravityY, double centerOfGravityZ)
Sets the total mass and center of gravity (CoG) of the attached payload.
The center of gravity, also referred to as center of mass, is defined as the offset between the center of the tool output flange and the center of gravity of the attached payload.
This function must be called, when the payload weight or weigh distribution changes significantly, i.e when the robot arm picks up or puts down a heavy workpiece.
NOTE: The usage of this script function is deprecated on e-Series robots. Please consider using the
Set Payload program node (see the SetPayloadNode
interface) instead, or use the script function
'set_target_payload(m, cog, inertia)' (see the Script Manual for more details).
payloadMass
- The total payload mass in kilogramscenterOfGravityX
- The X coordinate of the center of gravity (x displacement from the tool-mount) in meters.centerOfGravityY
- The Y coordinate of the center of gravity (y displacement from the tool-mount) in meters.centerOfGravityZ
- The Z coordinate of the center of gravity (z 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 (TCP).
Sets the transformation from the tool output flange coordinate system to the TCP as a pose.x
- Position part.y
- Position part.z
- Position part.rx
- Rotation part.ry
- Rotation part.rz
- Rotation part.void set_tcp(TCP tcp)
Set the Tool Center Point (TCP).
Sets the transformation from the tool output flange coordinate system to the TCP as a pose.tcp
- Tool Center Point.void ifCondition(String expression)
expression
- the expression of the if-sentence. Not null
.void ifNotCondition(String expression)
expression
- the expression of the negated if-sentence.void elseIfCondition(String expression)
expression
- the expression of the "else-if"-sentence.void elseCondition()
void whileTrue()
void whileCondition(String expression)
expression
- the loop invariant.void whileNot(String expression)
expression
- the loop invariant that will be negated.void defineThread(String threadName)
threadName
- the name of the new thread.void runThread(String threadHandle, String threadName)
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)
Returns a registered variable name that can be used in a script.
A variable is registered if it has been stored in a DataModel
instance or used for the configuration
of a built-in PolyScope program node.
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 © 2023. All rights reserved.