Creates a new ScriptBuilder
Optionalscript: stringIf a script is specified, the new ScriptBuilder will be preloaded with that script
OptionalinitialIndent: numberIf an indent is specified, the ScriptBuilder will be initialized with that indent
ReadonlytypeStatic ReadonlySINGLE_Static ReadonlySINGLE_Add a frame with the name 'name' initialized at the specified pose expressed in the refFrame coordinate frame. This command only adds a frame to the world, it does not attach it to the ref_frame coordinate frame. Use attach_frame() to attach the newly added frame to ref_frame if desired.
name of the frame to be added. The name must not be the same as any existing world model object (frame, axis, or axis group), otherwise an exception is thrown
initial pose of the new object or string expression
Add a frame with the name 'name' initialized at the specified pose expressed in the refFrame coordinate frame.
OptionalrefFrame: stringAdd raw script code. As this method takes raw script code that may not be indented and appends it without indenting it, it may violate the overall indentation.
The script to be appended
this object.
Add a block of statements to the builder.
A block of statements as a String.
this object.
Append the content of another script builder to this script builder
Add a statement that assigns an expression to a variable.
The name of the variable.
The expression to be assigned to the variable.
this object.
Attaches the child frame to the parent world model object. The relative transform between the parent and child will be set such that the child does not move in the world when the attachment occurs. The child cannot be "world", "tcp", or the same as parent. This will fail if child or parent is not an existing frame, or this makes the attachments form a closed chain.
name of the frame to be attached. The name must not be "world" or "tcp".
name of the object that the child frame will be attached to.
Add a while statement with a given expression. This is unbalanced, it has to be balanced by a call to #end() at the appropriate time.
The string representation of an expression.
this object.
Add a while not statement with a given expression. This is unbalanced, it has to be balanced by a call to #end() at the appropriate time.
The string representation of an expression.
this object.
Add a while statement that loops forever. This is unbalanced, it has to be balanced by a call to #end() at the appropriate time.
this object.
Add a comment in the script.
The comment text.
this object.
ProtecteddecreaseDecrease the indent.
Optionallevel: numberAdd a function definition with the given name and parameters. This is unbalanced, it has to be balanced by a call to #end() at the appropriate time.
The name of the function.
The parameters of the function.
this object.
Add a thread definition with given the threadName. This is unbalanced, it has to be balanced by a call to #end() at the appropriate time.
The threadName of the thread.
this object.
Delete the frame named frame from the world model. The "world", "base", and "tcp" frames cannot be deleted. Any frames that are attached to the deleted frame will be attached to the "world" frame with new frame offsets set such that the detached frame does not move in the world. This command will fail if the frame does not exist.
name of the frame to be deleted
Add an else statement. This is unbalanced, it has to be balanced by a call to #end() at the appropriate time.
this object.
Add an else if statement with a given expression. This is unbalanced, it has to be balanced by a call to #elseIfCondition(String) or #elseIfCondition(Script) or #else() or #end() at the appropriate time.
The expression that the else if statement branches on.
this object.
Add the end keyword that balances/terminates the declaration of functions, branch and loop statements.
this object.
Get the current indention level of this ScriptBuilder.
the indention level as a number.
The terminal operation that generates the as string containing the UR Script.
the string that contains the UR Script.
Add a statement that declares a global variable and assigns it an initial value.
The name of the global variable.
An expression which is the initial value of the global variable.
this object.
Add an if statement with a given expression. This is unbalanced, it has to be balanced by a call to #elseIfCondition(String) or #else() or #end() at the appropriate time.
The expression that the if statement branches on.
this object.
ProtectedincreaseIncrease the indent.
Optionallevel: numberAdd a statement that increments a variable with the given name.
The name of the variable.
this object.
Add a statement to kill a thread.
The thread threadHandle.
this object.
Add a statement that declares a local variable and assigns it an initial value.
The name of the local variable.
An expression which is the initial value of the local variable.
this object.
TCP moves on the circular arc segment from current pose, through pose_via to pose_to. Accelerates to and moves with constant tool speed v. Use the mode parameter to define the orientation interpolation.
path point (note: only position is used). Pose_via can also be specified as joint positions, then forward kinematics is used to calculate the corresponding pose as a string or number array.
target pose (note: only position is used in Fixed orientation mode). Pose_to can also be specified as joint positions, then forward kinematics is used to calculate the corresponding pose as a string or number array.
Optionalacc: string | numbertool acceleration rad/s2 as a string or number (optional).
Optionalspeed: string | numbertool speed in m/s as a string or number (optional).
OptionalblendRadius: string | numberblend radius (of target pose) in m as a string or number (optional).
Optionalmode: string | numbermode of circular arc move as a string or number (optional). 0: Unconstrained mode. Interpolate orientation from current pose to target pose (pose_to) 1: Fixed mode. Keep orientation constant relative to the tangent of the circular arc (starting from current pose)
this object.
Changes the placement of the coordinate frame named name to the new placement given by pose that is defined in the refFrame coordinate frame. This will fail if name is “world”, "tcp", or if the frame does not exist. Note: to move the "tcp" frame, use the set_tcp() command instead. If being used with the part positioner product, the ref_name argument can be the name of an external axis or axis group.
the name of the frame to move
the new placement
Changes the placement of the coordinate frame named name to the new placement given by pose that is defined in the refFrame coordinate frame.
OptionalrefFrame: stringAdd a call to the function that will Move to position (linear in joint-space).
joint positions (q can also be specified as a pose, then inverse kinematics is used to calculate the corresponding joint positions) as a string or number array.
Optionalacc: string | numberjoint acceleration of leading axis in rad/s2 as a string or number.
Optionalspeed: string | numberjoint speed of leading axis in rad/s as a string or number (optional).
Optionaltime: string | numbertime in seconds as a string or number (optional).
OptionalblendRadius: string | numberblend radius in m as a string or number (optional).
this object.
Add a call to the function that will Move to position (linear in tool-space).
target pose (pose can also be specified as joint positions, then forward kinematics is used to calculate the corresponding pose) as a string.
Optionalacc: string | numbertool acceleration m/s2 as a string or number.
Optionalspeed: string | numbertool speed in m/s as a string or number (optional).
Optionaltime: string | numbertime in seconds as a string or number (optional).
OptionalblendRadius: string | numberblend radius in m as a string or number (optional).
this object.
Blend circular (in tool-space) and move linear (in tool-space) to position. Accelerates to and moves with constant tool speed v.
joint positions (q can also be specified as a pose, then inverse kinematics is used to calculate the corresponding joint positions) as a string or number array.
Optionalacc: string | numberjoint acceleration of leading axis in rad/s2 as a string or number.
Optionalspeed: string | numberjoint speed of leading axis in rad/s as a string or number (optional).
OptionalblendRadius: string | numberblend radius in m as a string or number (optional).
this object.
Add a call to the function that will Move to position (linear in joint-space), using OptiMove
joint positions (q can also be specified as a pose, then inverse kinematics is used to calculate the corresponding joint positions) as a string or number array.
Optionalacc: string | numberJoint acceleration as a fraction of what the joints are able to perform - a (0.0, 1.0] (optional).
Optionalspeed: string | numberJoint speed as a fraction of how fast the joints can move during the motion - v (0.0, 1.0] (optional).
OptionalblendRadius: string | numberblend radius in m as a string or number (optional).
this object.
Add a call to the function that will Move to position (linear in tool-space), using OptiMove
target pose (pose can also be specified as joint positions, then forward kinematics is used to calculate the corresponding pose) as a string.
tool acceleration m/s2 as a string or number.
Optionalspeed: string | numbertool speed in m/s as a string or number (optional).
OptionalblendRadius: string | numberblend radius in m as a string or number (optional).
this object.
Add a popup with the given parameters.
The popup message.
The popup title.
The popup level.
true if its a blocking popup and false otherwise.
this object.
Request a value with the given parameters.
The variable name to assign the value to
The request message.
The type: integer, float, boolean, or string
this object.
Add a statement to run a thread with the given name and assign the thread handle to a variable.
The variable that gets assigned the thread handle .
The name of the thread to be started.
this object.
Changes the orientation of the frame
Set the direction of the acceleration experienced by the robot.
x m/s^2
y m/s^2
z m/s^2
mass in kilograms as a Script.
this object.
use setTargetPayload
mass in kilograms as a Script.
CoG x offset in meters
CoG y offset in meters
CoG z offset in meters
Optionalinertia: [number, number, number, number, number, number]The payload inertia matrix in kg*m^2, elements lxx,lyy lzz, lxy, lxz, lyz
this object.
use setTargetPayload
Declares or updates a persistent (shared) variable in URScript with the given name and value. Shared variables retain their values between program runs and are accessible globally.
The name of the persistent variable.
The initial value or expression to assign to the persistent variable.
This ScriptBuilder instance for chaining.
mass in kilograms as a Script.
CoG x offset in meters
CoG y offset in meters
CoG z offset in meters
Optionalinertia: [number, number, number, number, number, number]The payload inertia matrix in kg*m^2, elements lxx,lyy lzz, lxy, lxz, lyz
this object.
x length
y length
z length
rx angle
ry angle
rz angle
Optionalname: stringName of the TCP
Add a sleep command.
The amount of time in seconds.
this object.
Add a call to the function that will accelerate linearly in joint space and continue with constant joint speed.
array of joint speeds in rad/s.
joint acceleration in rad/s2 (of leading axis)
time in seconds before the function returns.
this object.
Add a call to the function that will accelerate linearly in Cartesian space and continue with constant tool speed.
array of tool speeds in m/s (spatial vector).
tool position acceleration m/s2.
time in seconds before the function returns.
OptionalrefFrameName: stringname of reference frame
this object.
Add a stopj command. It decelerates joint speeds to zero.
The joint acceleration in rad/s2.
this object.
Add a stopl command. It decelerates tool speed to zero.
The tool acceleration in m/s2.
this object.
Add a sync command that uses up the remaining "physical" time a thread has in the current frame.
this object.
StaticCreateCreate a ScriptBuilder preloaded with the incognito program definition. This is unbalanced, it has to be balanced by a call to #end() before calling #getScript().
new ScriptBuilder.
StaticCreateCreate a ScriptBuilder preloaded with a secondary program definition. This is unbalanced, it has to be balanced by a call to #end() before calling #getScript().
The name of the secondary program.
new ScriptBuilder.
StaticformatReturn a String representation of the input array.
the input array.
String representation of the input array.
StaticformatConverts a variable's value to a URScript-compatible literal string based on its declared type.
Handles proper formatting for POSE, BOOLEAN, ARRAY, and STRING types to ensure valid URScript syntax.
p[...] wrapper, assuming correct formatting.'' for invalid or mixed-type array inputs, or if the variable type is missing.The URVariable object containing the variable's metadata.
The value to be converted. Typically a string, but may also be a boolean, number, or array.
The value formatted as a URScript-compatible literal string.
StaticgetGenerate the String representation of a boolean.
The input boolean
The String representation of the input
StaticnegateThe expression to be negated
ScriptBuilder provides methods to easily generate well indented UR script programmatically. This class manages indentation automatically as the script is built step by step. But,it does not guarantee perfect formatting as there is a possibility to pass badly formatted expressions, statements or scripts.