Universal Robots ScriptManual - E-Series - 5.9.4 - EN
Universal Robots ScriptManual - E-Series - 5.9.4 - EN
Version 5.9
CONTENTS CONTENTS
The information contained herein is the property of Universal Robots A/S and shall
not be reproduced in whole or in part without prior written approval of Universal
Robots A/S. The information herein is subject to change without notice and should
not be construed as a commitment by Universal Robots A/S. This manual is period-
ically reviewed and revised.
Universal Robots A/S assumes no responsibility for any errors or omissions in this doc-
ument.
Copyright c 2009–2020 by Universal Robots A/S
The Universal Robots logo is a registered trademark of Universal Robots A/S.
Contents
Contents 2
2 Module motion 14
2.1 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.2 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
3 Module internals 44
3.1 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
3.2 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
4 Module urmath 65
4.1 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
4.2 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
5 Module interfaces 83
5.1 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
2 URScript
CONTENTS CONTENTS
3 URScript
The URScript Programming Language
1.1 Introduction
• Script Level
At the Script Level, the URScript is the programming language that controls the robot.
The URScript includes variables, types, and the flow control statements. There are also
built-in variables and functions that monitor and control I/O and robot movements.
URControl is the low-level robot controller running on the PC in the Control Box. When
the PC boots up, the URControl starts up as a daemon (i.e., a service) and the PolyScope
or Graphical User Interface connects as a client using a local TCP/IP connection.
Programming a robot at the Script Level is done by writing a client application (running
at another PC) and connecting to URControl using a TCP/IP socket.
• hostname: ur-xx (or the IP address found in the About Dialog-Box in PolyScope if
the robot is not in DNS).
• port: 30002
When a connection has been established URScript programs or commands are sent in
clear text on the socket. Each line is terminated by “\n”. Note that the text can only
consist of extended ASCII characters.
The following conditions must be met to ensure that the URControl correctly recognizes
the script:
• The script must start from a function definition or a secondary function definition
(either "def" or "sec" keywords) in the first column
• All other script lines must be indented by at least one white space
• The last line of script must be an "end" keyword starting in the first column
4 URScript
Numbers, Variables, and Types The URScript Programming Language
1+2-3
4*5/6
(1+2)*3/(4-5)
101%100
"Hello" + ", " + "World!"
foo = 42
bar = False or True and not False
baz = 87-13/3.1415
hello = "Hello, World!"
l = [1,2,4]
m = [[1,2,3],[4,5,6],[6,7,8]]
target = p[0.4,0.4,0.0,0.0,3.14159,0.0]
The fundamental type of a variable is deduced from the first assignment of the vari-
able. In the example above foo is an int, bar is a bool, baz is a double, l is an array,
m is a matrix and target is a pose: a combination of a position and orientation.
• none
• bool
• array
• matrix
• pose
• string
A pose is given as p[x,y,z,ax,ay,az], where x,y,z is the position of the TCP, and
ax,ay,az is the orientation of the TCP, given in axis-angle notation.
Note that strings are fundamentally byte arrays without knowledge of the encoding
used for the characters it contains. Therefore some string functions appear to oper-
ate on characters (e.g. str_len), but they operate on bytes. The result may differ
from what is expected when the string containing sequences of multi-byte or variable-
5 URScript
Matrix and Array expressions The URScript Programming Language
length characters. Refer to the description of the single function for more details.
Matrix and array operations can be assigned to a variable to store and manipulate
multiple numbers at the same time. It is also possible to get access and write to a
single entry of the matrix. The matrix and array are 0-indexed.
array = [1,2,3,4,5]
a = array[0]
array[2] = 10
matrix = [[1,2],[3,4],[5,6]]
b = matrix[0,0]
matrix[2,1] = 20
C = [[1,2],[3,4],[5,6]] * [[10,20,30],[40,50,60]]
Matrix-array multiplication operations are supported if the matrix is the first operand
and array is second. If the matrix’s number of columns matches the arrays length, the
resulting array will have the length as the matrix number of rows.
C = [[1,2],[3,4],[5,6]] * [10,20]
Array-array operations are possible if both arrays are of the same length and supports:
addition, subtraction, multiplication, division and modulo operations. The operation is
executed index by index on both arrays and thus results in an array of the same length.
E.g. a[i] − b[i] = c[i].
Scalar operations on a matrix or an array are possible. They support addition, subtrac-
tion, multiplication, division and modulo operations. The scalar operations are done
on all the entries of the matrix or the array. E.g. a[i] + b = c[i]
mul1 = [1,2,3] * 5
mul2 = 5 * [[1,2],[3,4],[5,6]]
div1 = [10,20,30] / 10
div2 = 10 / [10,20,30]
6 URScript
Flow of Control The URScript Programming Language
add1 = [1,2,3] + 10
add2 = 10 + [1,2,3]
sub1 = [10,20,30] - 5
sub2 = 5 - [[10,20],[30,40]]
mod1 = [11,22,33] % 5
mod2 = 121 % [[10,20],[30,40]]
if a > 3:
a = a + 1
elif b < 7:
b = b * a
else:
a = a + b
end
and while-loops:
l = [1,2,3,4,5]
i = 0
while i < 5:
l[i] = l[i]*2
i = i + 1
end
You can use break to stop a loop prematurely and continue to pass control to the
next iteration of the nearest enclosing loop.
• return returns from a function. When no value is returned, the keyword None
must follow the keyword return.
1.6 Function
7 URScript
Remote Procedure Call (RPC) The URScript Programming Language
result = add(1, 4)
def add(a=0,b=0):
return a+b
end
If default values are given in the declaration, arguments can be either input or skipped
as below:
result = add(0,0)
result = add()
When calling a function, it is important to comply with the declared order of the ar-
guments. If the order is different from its definition, the function does not work as ex-
pected.
Arguments can only be passed by value (including arrays). This means that any modi-
fication done to the content of the argument within the scope of the function will not
be reflected outside that scope.
def myProg()
a = [50,100]
fun(a)
def fun(p1):
p1[0] = 25
assert(p1[0] == 25)
...
end
assert(a[0] == 50)
...
end
Remote Procedure Calls (RPC) are similar to normal function calls, except that the
function is defined and executed remotely. On the remote site, the RPC function be-
ing called must exist with the same number of parameters and corresponding types
(together the function’s signature). If the function is not defined remotely, it stops pro-
gram execution. The controller uses the XMLRPC standard to send the parameters to
the remote site and retrieve the result(s). During an RPC call, the controller waits for
the remote function to complete. The XMLRPC standard is among others supported
by C++ (xmlrpc-c library), Python and Java.
8 URScript
Scoping rules The URScript Programming Language
def myProg():
end
Every variable declared inside a program has a scope. The scope is the textual region
where the variable is directly accessible. Two qualifiers are available to modify this
visibility:
• local qualifier tells the controller to treat a variable inside a function, as being
truly local, even if a global variable with the same name exists.
For each variable the controller determines the scope binding, i.e. whether the vari-
able is global or local. In case no local or global qualifier is specified (also called a
free variable), the controller will first try to find the variable in the globals and otherwise
the variable will be treated as local.
In the following example, the first a is a global variable and the second a is a local
variable. Both variables are independent, even though they have the same name:
def myProg():
9 URScript
Scoping rules The URScript Programming Language
global a = 0
def myFun():
local a = 1
...
end
...
end
Beware that the global variable is no longer accessible from within the function, as the
local variable masks the global variable of the same name.
In the following example, the first a is a global variable, so the variable inside the func-
tion is the same variable declared in the program:
def myProg():
global a = 0
def myFun():
a = 1
...
end
...
end
For each nested function the same scope binding rules hold. In the following example,
the first a is global defined, the second local and the third implicitly global again:
def myProg():
global a = 0
def myFun():
local a = 1
def myFun2():
a = 2
...
end
...
end
...
end
The first and third a are one and the same, the second a is independent.
Variables on the first scope level (first indentation) are treated as global, even if the
global qualifier is missing or the local qualifier is used:
def myProg():
10 URScript
Threads The URScript Programming Language
a = 0
def myFun():
a = 1
...
end
...
end
1.9 Threads
To declare a new thread a syntax similar to the declaration of functions are used:
thread myThread():
# Do some stuff
return False
end
A couple of things should be noted. First of all, a thread cannot take any parameters,
and so the parentheses in the declaration must be empty. Second, although a return
statement is allowed in the thread, the value returned is discarded, and cannot be
accessed from outside the thread. A thread can contain other threads, the same
way a function can contain other functions. Threads can in other words be nested,
allowing for a thread hierarchy to be formed.
thread myThread():
# Do some stuff
return False
end
The value returned by the run command is a handle to the running thread. This handle
can be used to interact with a running thread. The run command spawns from the new
thread, and then executes the instruction following the run instruction.
A thread can only wait for a running thread spawned by itself. To wait for a running
thread to finish, use the join command:
11 URScript
Threads The URScript Programming Language
thread myThread():
# Do some stuff
return False
end
join thrd
This halts the calling threads execution, until the specified thread finishes its execution.
If the thread is already finished, the statement has no effect.
thread myThread():
# Do some stuff
return False
end
kill thrd
After the call to kill, the thread is stopped, and the thread handle is no longer valid. If
the thread has children, these are killed as well.
To protect against race conditions and other thread-related issues, support for critical
sections is provided. A critical section ensures the enclosed code can finish running
before another thread can start running. The previous statement is always true, unless
a time-demanding command is present within the scope of the critical section. In such
a case, another thread will be allowed to run. Time-demanding commands include
sleep, sync, move-commands, and socketRead. Therefore, it is important to keep the
critical section as short as possible. The syntax is as follows:
thread myThread():
enter_critical
# Do some stuff
exit_critical
return False
end
12 URScript
Program Label The URScript Programming Language
The scoping rules for threads are exactly the same, as those used for functions. See 1.8
for a discussion of these rules.
Because the primary purpose of the URScript scripting language is to control the robot,
the scheduling policy is largely based upon the realtime demands of this task.
The robot must be controlled a frequency of 500 Hz, or in other words, it must be told
what to do every 0.002 second (each 0.002 second period is called a frame). To
achieve this, each thread is given a “physical” (or robot) time slice of 0.002 seconds to
use, and all threads in a runnable state is then scheduled in a round robin1 fashion.
Each time a thread is scheduled, it can use a piece of its time slice (by executing
instructions that control the robot), or it can execute instructions that do not control
the robot, and therefore do not use any “physical” time. If a thread uses up its entire
time slice, either by use of “physical” time or by computational heavy instructions (such
as an infinite loop that do not control the robot) it is placed in a non-runnable state,
and is not allowed to run until the next frame starts. If a thread does not use its time
slice within a frame, it is expected to switch to a non-runnable state before the end
of the frame2 . The reason for this state switching can be a join instruction or simply
because the thread terminates.
It should be noted that even though the sleep instruction does not control the robot,
it still uses “physical” time. The same is true for the sync instruction. Inserting sync or
sleep will allow time for other threads to be executed and is therefore recommended
to use next to computational heavy instructions or inside infinite loops that do not con-
trol the robot, otherwise an exception like "Runtime is too much behind" can be raised
with a consequent protective stop.
Program label code lines, with an “$” as first symbol, are special lines in programs
generated by PolyScope that make it possible to track the execution of a program.
13 URScript
Secondary Programs The URScript Programming Language
Notable exception is that secondary program should not use any “physical” time. In
particular, it cannot contain sleep, or move statements. Secondary program must be
simple enough to be executed in a single controller step, without blocking the realtime
thread.
Exceptions on secondary program do not stop execution of the primary program. Ex-
ceptions are reported in robot controller log files.
The secondary function must be defined using the keyword "sec" as follows:
sec secondaryProgram():
set_digital_out(1,True)
end
14 URScript
Module motion
2 Module motion
This module contains functions and variables built into the URScript programming lan-
guage.
Robot trajectories are generated online by calling the move functions movej, movel
and the speed functions speedj, speedl.
Joint positions (q) and joint speeds (qd) are represented directly as lists of 6 Floats,
one for each robot joint. Tool poses (x) are represented as poses also consisting of 6
Floats. In a pose, the first 3 coordinates is a position vector and the last 3 an axis-angle
(http://en.wikipedia.org/wiki/Axis_angle).
15 URScript
Functions Module motion
2.1 Functions
conveyor_pulse_decode(type, A, B)
Deprecated:Tells the robot controller to treat digital inputs number A
and B as pulses for a conveyor encoder. Only digital input 0, 1, 2 or 3
can be used.
Parameters
type: An integer determining how to treat the inputs on A
and B
0 is no encoder, pulse decoding is disabled.
1 is quadrature encoder, input A and B must be
square waves with 90 degree offset. Direction of the
conveyor can be determined.
2 is rising and falling edge on single input (A).
3 is rising edge on single input (A).
4 is falling edge on single input (A).
The controller can decode inputs at up to 40kHz
A: Encoder input A, values of 0-3 are the digital inputs
0-3.
B: Encoder input B, values of 0-3 are the digital inputs
0-3.
Deprecated: This function is replaced by
encoder_enable_pulse_decode and it should therefore not be used
moving forward.
>>> conveyor_pulse_decode(1,0,1)
This example shows how to set up quadrature pulse decoding with
input A = digital_in[0] and input B = digital_in[1]
>>> conveyor_pulse_decode(2,3)
This example shows how to set up rising and falling edge pulse
decoding with input A = digital_in[3]. Note that you do not have to set
parameter B (as it is not used anyway).
Example command: conveyor_pulse_decode(1, 2, 3)
• Example Parameters:
– type = 1 → is quadrature encoder, input A and B must be
square waves with 90 degree offset. Direction of the
conveyor can be determined.
– A = 2 → Encoder output A is connected to digital input 2
– B = 3 → Encoder output B is connected to digital input 3
16 URScript
Functions Module motion
encoder_enable_pulse_decode(encoder_index, decoder_type, A, B)
Sets up an encoder hooked up to a pulse decoder of the controller.
>>> encoder_enable_pulse_decode(0,0,1,8,9)
17 URScript
Functions Module motion
encoder_enable_set_tick_count(encoder_index, range_id)
Sets up an encoder expecting to be updated with tick counts via the
function encoder_set_tick_count.
>>> encoder_enable_set_tick_count(0,0)
encoder_get_tick_count(encoder_index)
Returns the tick count of the designated encoder.
>>> encoder_get_tick_count(0)
This example returns the current tick count of encoder 0. Use caution
when subtracting encoder tick counts. Please see the function
encoder_unwind_delta_tick_count.
Parameters
encoder_index: Index of the encoder to query. Must be
either 0 or 1.
Return Value
The conveyor encoder tick count (float)
18 URScript
Functions Module motion
encoder_set_tick_count(encoder_index, count)
Tells the robot controller the tick count of the encoder. This function is
useful for absolute encoders (e.g. MODBUS).
This example sets the tick count of encoder 0 to 1234. Assumes that the
encoder is enabled using encoder_enable_set_tick_count first.
Parameters
encoder_index: Index of the encoder to define. Must be
either 0 or 1.
count: The tick count to set. Must be within the
range of the encoder.
19 URScript
Functions Module motion
encoder_unwind_delta_tick_count(encoder_index, delta_tick_count)
Returns the delta_tick_count. Unwinds in case encoder wraps around
the range. If no wrapping has happened the given delta_tick_count is
returned without any modification.
For example, the first sample point is near the end of the range (e.g.,
start:=65530). When the conveyor arrives at the second point, the
encoder may have crossed the end of its range, wrapped around, and
reached a value near the beginning of the range (e.g., current:=864).
Subtracting the two samples to calculate the motion of the conveyor is
not robust, and may result in an incorrect result
(delta=current-start=-64666).
20 URScript
Functions Module motion
end_force_mode()
Resets the robot mode from force mode to normal operation.
end_freedrive_mode()
Set robot back in normal position control mode after freedrive mode.
end_screw_driving()
Exit screw driving mode and return to normal operation.
end_teach_mode()
Set robot back in normal position control mode after freedrive mode.
21 URScript
Functions Module motion
22 URScript
Functions Module motion
force_mode_example()
This is an example of the above force_mode() function
Example command: force_mode(p[0.1,0,0,0,0.785],
[1,0,0,0,0,0], [20,0,40,0,0,0], 2,
[.2,.1,.1,.785,.785,1.57])
• Example Parameters:
– Task frame = p[0.1,0,0,0,0.785] → This frame is offset from the
base frame 100 mm in the x direction and rotated 45 degrees
in the rz direction
– Selection Vector = [1,0,0,0,0,0] → The robot is compliant in the
x direction of the Task frame above.
– Wrench = [20,0,40,0,0,0] → The robot apples 20N in the x
direction. It also accounts for a 40N external force in the z
direction.
– Type = 2 → The force frame is not transformed.
– Limits = [.1,.1,.1,.785,.785,1.57] → max x velocity is 100 mm/s,
max y deviation is 100 mm, max z deviation is 100 mm, max rx
deviation is 45 deg, max ry deviation is 45 deg, max rz
deviation is 90 deg.
force_mode_set_damping(damping)
Sets the damping parameter in force mode.
Parameters
damping: Between 0 and 1, default value is 0.005.
A value of 1 is full damping, so the robot will
decellerate quickly if no force is present. A value
of 0 is no damping, here the robot will maintain
the speed.
The value is stored until this function is called
again. Add this to the beginning of your program
to ensure it is called before force mode is entered
(otherwise default value will be used).
23 URScript
Functions Module motion
force_mode_set_gain_scaling(scaling)
Scales the gain in force mode.
Parameters
scaling: scaling parameter between 0 and 2, default is 1.
A value larger than 1 can make force mode
unstable, e.g. in case of collisions or pushing
against hard surfaces.
The value is stored until this function is called
again. Add this to the beginning of your program
to ensure it is called before force mode is entered
(otherwise default value will be used).
freedrive_mode()
Set robot in freedrive mode. In this mode the robot can be moved
around by hand in the same way as by pressing the "freedrive" button.
The robot will not be able to follow a trajectory (eg. a movej) in this
mode.
get_conveyor_tick_count()
Deprecated: Tells the tick count of the encoder, note that the
controller interpolates tick counts to get more accurate movements
with low resolution encoders
Return Value
The conveyor encoder tick count
Deprecated: This function is replaced by encoder_get_tick_count
and it should therefore not be used moving forward.
get_target_tcp_pose_along_path()
Query the target TCP pose as given by the trajectory being followed.
24 URScript
Functions Module motion
get_target_tcp_speed_along_path()
Query the target TCP speed as given by the trajectory being followed.
25 URScript
Functions Module motion
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.
Parameters
pose_via: 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.
pose_to: 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.
a: tool acceleration [m/s^2]
v: tool speed [m/s]
r: blend radius (of target pose) [m]
mode: 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)
Example command: movec(p[x,y,z,0,0,0], pose_to, a=1.2,
v=0.25, r=0.05, mode=1)
• Example Parameters:
– Note: first position on circle is previous waypoint.
– pose_via = p[x,y,z,0,0,0] → second position on circle.
∗ Note rotations are not used so they can be left as zeros.
∗ Note: This position can also be represented as joint
angles [j0,j1,j2,j3,j4,j5] then forward kinematics is used to
calculate the corresponding pose
– pose_to → third (and final) position on circle
– a = 1.2 → acceleration is 1.2 m/s/s
– v = 0.25 → velocity is 250 mm/s
– r = 0 → blend radius (at pose_to) is 50 mm.
– mode = 1 → use fixed orientation relative to tangent of
circular arc
26 URScript
Functions Module motion
27 URScript
Functions Module motion
See movej.
Parameters
pose: target pose (pose can also be specified as joint
positions, then forward kinematics is used to
calculate the corresponding pose)
a: tool acceleration [m/s^2]
v: tool speed [m/s]
t: time [S]
r: blend radius [m]
Example command: movel(pose, a=1.2, v=0.25, t=0, r=0)
• Example Parameters:
– pose = p[0.2,0.3,0.5,0,0,3.14] → position in base frame of x =
200 mm, y = 300 mm, z = 500 mm, rx = 0, ry = 0, rz = 180 deg
– a = 1.2 → acceleration of 1.2 m/s^2
– v = 0.25 → velocity of 250 mm/s
– t = 0 → the time (seconds) to make the move is not specified.
If it were specified the command would ignore the a and v
values.
– r = 0 → the blend radius is zero meters.
28 URScript
Functions Module motion
path_offset_disable(a=20)
Disable the path offsetting and decelerate all joints to zero speed.
Uses the stopj functionality to bring all joints to a rest. Therefore, all
joints will decelerate at different rates but reach stand-still at the same
time.
29 URScript
Functions Module motion
path_offset_enable()
Enable path offsetting.
path_offset_get(type)
Query the offset currently applied.
Parameters
type: Specifies the frame of reference of the returned
offset. Please refer to the path_offset_set script
function for a definition of the possible values and
their meaning.
Return Value
Pose specifying the translational and rotational offset. Units
are meters and radians.
30 URScript
Functions Module motion
path_offset_set(offset, type)
Specify the Cartesian path offset to be applied.
31 URScript
Functions Module motion
path_offset_set_alpha_filter(alpha)
Engage offset filtering using a simple alpha filter (EWMA) and set the
filter coefficient.
An alpha filter is a very simple 1st order IIR filter using a weighted sum of
the target and current offset: current = alpha*target +
(1-alpha)*current
Parameters
alpha: The filter coefficient to be used. Must be between 0
and 1. A value of 1 is equivalent to no filtering. For
welding, experiments have shown that a value
around 0.1 is a good compromise between
robustness and offsetting accuracy.
path_offset_set_max_offset(transLimit, rotLimit)
Set limits for the maximum allowed offset.
Due to safety and due to the finite reach of the robot, path offsetting
limits the magnitude of the offset to be applied. Use this function to
adjust these limits. Per default limits of 0.1 meters and 30 degrees (0.52
radians) are used.
Parameters
transLimit: The maximum allowed translational offset
distance along any axis in meters.
rotLimit: The maximum allowed rotational offset
around any axis in radians.
32 URScript
Functions Module motion
pause_on_error_code(code, argument)
Makes the robot pause if the specified error code occurs. The robot will
only pause during program execution. This setting is reset when the
program is stopped - call the command again before/during program
execution to re-enable it.
>>> pause_on_error_code(173, 7)
In the above example, the robot will pause on errors with code 173 if its
argument equals 7 (corresponding to ’C173A7’ in the log).
>>> pause_on_error_code(173)
In the above example, the robot will pause on error code 173 for any
argument value.
Parameters
code: The code of the error for which the robot should
pause (int)
argument: The argument of the error. If this parameter is
omitted the robot will pause on any argument
for the specified error code (int)
Notes:
• Error codes appear in the log as CxAy where ’x’ is the
code and ’y’ is the argument.
• There is a short delay from when the pause is triggered
until the robot is fully paused. In some special cases the
program might reach the subsequent program line
before it is paused.
33 URScript
Functions Module motion
position_deviation_warning(enabled, threshold=0.8)
When enabled, this function generates warning messages to the log
when the robot deviates from the target position. This function can be
called at any point in the execution of a program. It has no return
value.
>>> position_deviation_warning(True)
In the above example, the function has been enabled. This means that
log messages will be generated whenever a position deviation occurs.
The optional "threshold" parameter can be used to specify the level of
position deviation that triggers a log message.
Parameters
enabled: (Boolean) Enable or disable position deviation
log messages.
threshold: (Float) Optional value in the range [0;1], where
0 is no position deviation and 1 is the maximum
position deviation (equivalent to the amount of
position deviation that causes a protective
stop of the robot). If no threshold is specified by
the user, a default value of 0.8 is used.
Example command: position_deviation_warning(True, 0.8)
• Example Parameters:
– Enabled = True → Logging of warning is turned on
– Threshold = 0.8 → 80% of deviation that causes a protective
stop causes a warning to be logged in the log history file.
34 URScript
Functions Module motion
>>> reset_revolution_counter()
Parameters
qNear: Optional parameter, reset the revolution counter to
one close to the given qNear joint vector. If not
defined, the joint’s actual number of revolutions are
used.
Example command: reset_revolution_counter(qNear=[0.0,
0.0, 0.0, 0.0, 0.0, 0.0])
• Example Parameters:
– qNear = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] → Optional parameter,
resets the revolution counter of wrist 3 to zero on UR3 robots
to the nearest zero location to joint rotations represented by
qNear.
35 URScript
Functions Module motion
screw_driving(f, v_limit)
Enter screw driving mode. The robot will exert a force in the TCP Z-axis
direction at limited speed. This allows the robot to follow the screw
during tightening/loosening operations.
Parameters
f: The amount of force the robot will exert along the
TCP Z-axis (Newtons).
v_limit: Maximum TCP velocity along the Z axis (m/s).
Notes:
• Zero the F/T sensor without the screw driver pushing
against the screw.
• Call end_screw_driving when the screw driving
operation has completed.
>>> def testScrewDriver():
>>> # Zero F/T sensor
>>> zero_ftsensor()
>>> sleep(0.02)
>>>
>>> # Move the robot to the tightening position
>>> # (i.e. just before contact with the screw)
>>> ...
>>>
>>> # Start following the screw while tightening
>>> screw_driving(5.0, 0.1)
>>>
>>> # Wait until screw driver reports OK or NOK
>>> ...
>>>
>>> # Exit screw driving mode
>>> end_screw_driving()
>>> end
36 URScript
Functions Module motion
37 URScript
Functions Module motion
The gain parameter works the same way as the P-term of a PID
controller, where it adjusts the current position towards the desired (q).
The higher the gain, the faster reaction the robot will have.
Note: A high gain or a short lookahead time may cause instability and
vibrations. Especially if the target positions are noisy or updated at a
low frequency
It is preferred to call this function with a new setpoint (q) in each time
step (thus the default t=0.002)
>>> q = get_inverse_kin(x)
>>> servoj(q, lookahead_time=0.05, gain=500)
38 URScript
Functions Module motion
set_conveyor_tick_count(tick_count, absolute_encoder_resolution=0)
Deprecated: Tells the robot controller the tick count of the encoder.
This function is useful for absolute encoders, use
conveyor_pulse_decode() for setting up an incremental encoder. For
circular conveyors, the value must be between 0 and the number of
ticks per revolution.
Parameters
tick_count: Tick count of the
conveyor (Integer)
absolute_encoder_resolution: Resolution of the
encoder, needed to
handle wrapping nicely.
(Integer)
0 is a 32 bit signed
encoder, range
[-2147483648 ;
2147483647] (default)
1 is a 8 bit unsigned
encoder, range [0 ; 255]
2 is a 16 bit unsigned
encoder, range [0 ;
65535]
3 is a 24 bit unsigned
encoder, range [0 ;
16777215]
4 is a 32 bit unsigned
encoder, range [0 ;
4294967295]
Deprecated: This function is replaced by encoder_set_tick_count
and it should therefore not be used moving forward.
Example command: set_conveyor_tick_count(24543, 0)
• Example Parameters:
– Tick_count = 24543 → a value read from e.g. a MODBUS
register being updated by the absolute encoder
– Absolute_encoder_resolution = 0 → 0 is a 32 bit signed
encoder, range [-2147483648 ;2147483647] (default)
39 URScript
Functions Module motion
set_pos(q)
Set joint positions of simulated robot
Parameters
q: joint positions
Example command: set_pos([0.0,1.57,-1.57,0,0,3.14])
• Example Parameters:
– q = [0.0,1.57,-1.57,0,0,3.14] → the position of the simulated
robot with joint angles in radians representing rotations of
base, shoulder, elbow, wrist1, wrist2 and wrist3
set_safety_mode_transition_hardness(type)
Sets the transition hardness between normal mode, reduced mode
and safeguard stop.
Parameters
type: An integer specifying transition hardness.
0 is hard transition between modes using maximum
torque, similar to emergency stop.
1 is soft transition between modes.
speedj(qd, a, t)
Joint speed
40 URScript
Functions Module motion
speedl(xd, a, t, aRot=’a’)
Tool speed
stop_conveyor_tracking(a=20)
Stop tracking the conveyor, started by track_conveyor_linear() or
track_conveyor_circular(), and decelerate all joint speeds to zero.
Parameters
a: joint acceleration [rad/s^2] (optional)
Example command: stop_conveyor_tracking(a=15)
• Example Parameters:
– a = 15 rad/s^2 → acceleration of the joints
41 URScript
Functions Module motion
stopj(a)
Stop (linear in joint space)
stopl(a, aRot=’a’)
Stop (linear in tool space)
teach_mode()
Set robot in freedrive mode. In this mode the robot can be moved
around by hand in the same way as by pressing the "freedrive" button.
The robot will not be able to follow a trajectory (eg. a movej) in this
mode.
42 URScript
Functions Module motion
track_conveyor_circular(center, ticks_per_revolution,
rotate_tool=’False’, encoder_index=0)
Makes robot movement (movej() etc.) track a circular conveyor.
The example code makes the robot track a circular conveyor with
center in p[0.5,0.5,0,0,0,0] of the robot base coordinate system, where
500 ticks on the encoder corresponds to one revolution of the circular
conveyor around the center.
Parameters
center: Pose vector that determines
center of the conveyor in the
base coordinate system of the
robot.
ticks_per_revolution: How many ticks the encoder sees
when the conveyor moves one
revolution.
rotate_tool: Should the tool rotate with the
coneyor or stay in the orientation
specified by the trajectory
(movel() etc.).
encoder_index: The index of the encoder to
associate with the conveyor
tracking. Must be either 0 or 1.
This is an optional argument, and
please note the default of 0. The
ability to omit this argument will
allow existing programs to keep
working. Also, in use cases where
there is just one conveyor to track
consider leaving this argument
out.
Example command:
track_conveyor_circular(p[0.5,0.5,0,0,0,0], 500.0, false)
• Example Parameters:
– center = p[0.5,0.5,0,0,0,0] → location of the center of the
conveyor
– ticks_per_revolution = 500 → the number of ticks the encoder
sees when the conveyor moves one revolution
– rotate_tool = false → the tool should not rotate with the
conveyor, but stay in the orientation specified by the
trajectory (movel() etc.).
43 URScript
Variables Module motion
>>> track_conveyor_linear(p[1,0,0,0,0,0],1000.0)
The example code makes the robot track a conveyor in the x-axis of
the robot base coordinate system, where 1000 ticks on the encoder
corresponds to 1m along the x-axis.
Parameters
direction: Pose vector that determines the
direction of the conveyor in the base
coordinate system of the robot
ticks_per_meter: How many ticks the encoder sees when
the conveyor moves one meter
encoder_index: The index of the encoder to associate
with the conveyor tracking. Must be
either 0 or 1. This is an optional
argument, and please note the default
of 0. The ability to omit this argument
will allow existing programs to keep
working. Also, in use cases where there
is just one conveyor to track consider
leaving this argument out.
Example command: track_conveyor_linear(p[1,0,0,0,0,0],
1000.0)
• Example Parameters:
– direction = p[1,0,0,0,0,0] → Pose vector that determines the
direction of the conveyor in the base coordinate system of
the robot
– ticks_per_meter = 1000. → How many ticks the encoder sees
when the conveyor moves one meter.
2.2 Variables
Name Description
__package__ Value: ’Motion’
a_joint_default Value: 1.4
a_tool_default Value: 1.2
v_joint_default Value: 1.05
v_tool_default Value: 0.25
44 URScript
Module internals
3 Module internals
3.1 Functions
force()
Returns the force exerted at the TCP
Return the current externally exerted force at the TCP. The force is the
norm of Fx, Fy, and Fz calculated using get_tcp_force().
Return Value
The force in Newtons (float)
Note: Refer to force_mode() for taring the sensor.
get_actual_joint_positions()
Returns the actual angular positions of all joints
get_actual_joint_positions_history(steps=0)
Returns the actual past angular positions of all joints
45 URScript
Functions Module internals
get_actual_joint_speeds()
Returns the actual angular velocities of all joints
The angular actual velocities are expressed in radians pr. second and
returned as a vector of length 6. Note that the output might differ from
the output of get_target_joint_speeds(), especially during acceleration
and heavy loads.
Return Value
The current actual joint angular velocity vector in rad/s:
[Base, Shoulder, Elbow, Wrist1, Wrist2, Wrist3]
get_actual_tcp_pose()
Returns the current measured tool pose
get_actual_tcp_speed()
Returns the current measured TCP speed
The speed of the TCP retuned in a pose structure. The first three values
are the cartesian speeds along x,y,z, and the last three define the
current rotation axis, rx,ry,rz, and the length |rz,ry,rz| defines the
angular velocity in radians/s.
Return Value
The current actual TCP velocity vector [X, Y, Z, Rx, Ry, Rz]
get_actual_tool_flange_pose()
Returns the current measured tool flange pose
46 URScript
Functions Module internals
get_controller_temp()
Returns the temperature of the control box
get_forward_kin(q=’current_joint_positions’,
tcp=’active_tcp’)
Calculate the forward kinematic transformation (joint space -> tool
space) using the calibrated robot kinematics. If no joint position vector
is provided the current joint angles of the robot arm will be used. If no
tcp is provided the currently active tcp of the controller will be used.
Parameters
q: joint position vector (Optional)
tcp: tcp offset pose (Optional)
Return Value
tool pose
Example command: get_forward_kin([0.,3.14,1.57,.785,0,0],
p[0,0,0.01,0,0,0])
• Example Parameters:
– q = [0.,3.14,1.57,.785,0,0] → joint angles of j0=0 deg, j1=180
deg, j2=90 deg, j3=45 deg, j4=0 deg, j5=0 deg.
– tcp = p[0,0,0.01,0,0,0] → tcp offset of x=0mm, y=0mm,
z=10mm and rotation vector of rx=0 deg., ry=0 deg, rz=0 deg.
47 URScript
Functions Module internals
48 URScript
Functions Module internals
get_joint_temp(j)
Returns the temperature of joint j
The temperature of the joint house of joint j, counting from zero. j=0 is
the base joint, and j=5 is the last joint before the tool flange.
Parameters
j: The joint number (int)
Return Value
A temperature in degrees Celcius (float)
get_joint_torques()
Returns the torques of all joints
The torque on the joints, corrected by the torque needed to move the
robot itself (gravity, friction, etc.), returned as a vector of length 6.
Return Value
The joint torque vector in Nm: [Base, Shoulder, Elbow, Wrist1,
Wrist2, Wrist3]
49 URScript
Functions Module internals
get_steptime()
Returns the duration of the robot time step in seconds.
In every time step, the robot controller will receive measured joint
positions and velocities from the robot, and send desired joint positions
and velocities back to the robot. This happens with a predetermined
frequency, in regular intervals. This interval length is the robot time step.
Return Value
duration of the robot step in seconds
get_target_joint_positions()
Returns the desired angular position of all joints
get_target_joint_speeds()
Returns the desired angular velocities of all joints
The angular target velocities are expressed in radians pr. second and
returned as a vector of length 6. Note that the output might differ from
the output of get_actual_joint_speeds(), especially during acceleration
and heavy loads.
Return Value
The current target joint angular velocity vector in rad/s:
[Base, Shoulder, Elbow, Wrist1, Wrist2, Wrist3]
get_target_payload()
Returns the weight of the active payload
Return Value
The weight of the current payload in kilograms
50 URScript
Functions Module internals
get_target_payload_cog()
Retrieve the Center Of Gravity (COG) coordinates of the active
payload.
This scripts returns the COG coordinates of the active payload, with
respect to the tool flange
Return Value
The 3d coordinates of the COG [CoGx, CoGy, CoGz] in
meters
get_target_tcp_pose()
Returns the current target tool pose
get_target_tcp_speed()
Returns the current target TCP speed
The desired speed of the TCP returned in a pose structure. The first
three values are the cartesian speeds along x,y,z, and the last three
define the current rotation axis, rx,ry,rz, and the length |rz,ry,rz| defines
the angular velocity in radians/s.
Return Value
The TCP speed (pose)
get_target_waypoint()
Returns the target waypoint of the active move
51 URScript
Functions Module internals
get_tcp_force()
Returns the wrench (Force/Torque vector) at the TCP
get_tcp_offset()
Gets the active tcp offset, i.e. the transformation from the output
flange coordinate system to the TCP as a pose.
Return Value
tcp offset pose
get_tool_accelerometer_reading()
Returns the current reading of the tool accelerometer as a
three-dimensional vector.
The accelerometer axes are aligned with the tool coordinates, and
pointing an axis upwards results in a positive reading.
Return Value
X, Y, and Z composant of the measured acceleration in
SI-units (m/s^2).
get_tool_current()
Returns the tool current
52 URScript
Functions Module internals
is_steady()
Checks if robot is fully at rest.
True when the robot is fully at rest, and ready to accept higher external
forces and torques, such as from industrial screwdrivers. It is useful in
combination with the GUI’s wait node, before starting the screwdriver
or other actuators influencing the position of the robot.
Note: This function will always return false in modes other than the
standard position mode, e.g. false in force and teach mode.
Return Value
True when the robot is fully at rest. Returns False otherwise
(bool)
is_within_safety_limits(pose, qnear)
Checks if the given pose or q is reachable and within the current safety
limits of the robot.
This check considers joint limits (if the target pose is specified as joint
positions), TCP orientation limit and range of the robot. If a solution is
found when applying the inverse kinematics to the given target TCP
pose, this pose is considered reachable.
Parameters
pose: Target pose or joint position
qnear: list of joint positions (Optional) Only used when
target is a pose
Return Value
True if within limits, false otherwise (bool)
Deprecated: This function is deprecated, since it does not apply the
same algorithm as get_inverse_kin. It is recommended to use
get_inverse_kin_has_solution instead.
53 URScript
Functions Module internals
powerdown()
Shutdown the robot, and power off the robot and controller.
set_gravity(d)
Set the direction of the acceleration experienced by the robot. When
the robot mounting is fixed, this corresponds to an accleration of g
away from the earth’s centre.
will set the acceleration for a robot that is rotated "theta" radians
around the x-axis of the robot base coordinate system
Parameters
d: 3D vector, describing the direction of the gravity, relative
to the base of the robot.
Example command: set_gravity(0,9.82,0)
• Example Parameters:
– d is vector with a direction of y (direction of the robot cable)
and a magnitude of 9.82 m/s^2 (1g).
54 URScript
Functions Module internals
set_payload(m, cog)
Set payload mass and center of gravity
Sets the mass and center of gravity (abbr. CoG) of the payload.
set_payload_cog(CoG)
Set the Center of Gravity (CoG)
Deprecated: This function is deprecated. It is recommended to set
always the CoG with the mass (see set_payload).
55 URScript
Functions Module internals
set_payload_mass(m)
Set payload mass
Sets the mass of the payload and leaves the center of gravity (CoG)
unchanged.
Parameters
m: mass in kilograms
Example command: set_payload_mass(3.)
• Example Parameters:
– m = 3 → mass is set to 3 kg payload
set_tcp(pose)
Sets the active tcp offset, i.e. the transformation from the output flange
coordinate system to the TCP as a pose.
Parameters
pose: A pose describing the transformation.
Example command: set_tcp(p[0.,.2,.3,0.,3.14,0.])
• Example Parameters:
– pose = p[0.,.2,.3,0.,3.14,0.] → tool center point is set to
x=0mm, y=200mm, z=300mm, rotation vector is rx=0 deg,
ry=180 deg, rz=0 deg. In tool coordinates
sleep(t)
Sleep for an amount of time
Parameters
t: time [s]
Example command: sleep(3.)
• Example Parameters:
– t = 3. → time to sleep
56 URScript
Functions Module internals
str_at(src, index)
Provides direct access to the bytes of a string.
This script returns a string containing the byte in the source string at the
position corresponding to the specified index. It may not correspond
to an actual character in case of strings with special encoded
character (i.e. multi-byte or variable-length encoding)
57 URScript
Functions Module internals
str_cat(op1, op2)
String concatenation
This script returns a string that is the concatenation of the two operands
given as input. Both operands can be one of the following types:
String, Boolean, Integer, Float, Pose, List of Boolean / Integer / Float /
Pose. Any other type will raise an exception.
Float numbers will be formatted with 6 decimals, and trailing zeros will
be removed.
58 URScript
Functions Module internals
str_empty(str)
Returns true when str is empty, false otherwise.
Parameters
str: source string.
Return Value
True if the string is empty, false otherwise
Example command:
• str_empty("")
– returns True
• str_empty("Hello")
– returns False
This script returns the index (i.e. byte) of the the first occurrence of
substring target in str, starting from the given (optional) position.
The result may not correspond to the actual position of the first
character of target in case src contains multi-byte or variable-length
encoded characters.
59 URScript
Functions Module internals
str_len(str)
Returns the number of bytes in a string.
Please not that the value returned may not correspond to the actual
number of characters in sequences of multi-byte or variable-length
encoded characters.
60 URScript
Functions Module internals
The result is the substring of src that starts at the byte specified by
index with length of at most len bytes. If the requested substring
extends past the end of the original string (i.e. index + len > src
length), the length of the resulting substring is limited to the size of src.
sync()
Uses up the remaining "physical" time a thread has in the current frame.
61 URScript
Functions Module internals
textmsg(s1, s2=’’)
Send text message to log
62 URScript
Functions Module internals
to_num(str)
Converts a string to a number.
63 URScript
Functions Module internals
to_str(val)
Gets string representation of a value.
This script converts a value of type Boolean, Integer, Float, Pose (or a list
of those types) to a string.
Float numbers will be formatted with 6 decimals, and trailing zeros will
be removed.
Parameters
val: value to convert
Return Value
The string representation of the given value.
Example command:
• to_str(10)
– returns "10"
• to_str(2.123456123456)
– returns "2.123456"
• to_str(p[1.0, 2.0, 3.0, 4.0, 5.0, 6.0])
– returns "p[1, 2, 3, 4, 5, 6]"
• to_str([True, False, True])
– returns "[True, False, True]"
tool_contact(direction)
Detects when a contact between the tool and an object happens.
Parameters
direction: List of six floats. The first three elements are
interpreted as a 3D vector (in the robot base
coordinate system) giving the direction in
which contacts should be detected. If all
elements of the list are zero, contacts from all
directions are considered.
Return Value
Integer. The returned value is the number of time steps back
to just before the contact have started. A value larger than
0 means that a contact is detected. A value of 0 means no
contact.
64 URScript
Variables Module internals
tool_contact_examples()
Example of usage in conjunction with the
"get_actual_joint_positions_history()" function to allow the robot to
retract to the initial point of contact:
3.2 Variables
Name Description
__package__ Value: None
65 URScript
Module urmath
4 Module urmath
4.1 Functions
acos(f )
Returns the arc cosine of f
asin(f )
Returns the arc sine of f
66 URScript
Functions Module urmath
atan(f )
Returns the arc tangent of f
atan2(x, y)
Returns the arc tangent of x/y
67 URScript
Functions Module urmath
binary_list_to_integer(l)
Returns the value represented by the content of list l
Returns the integer value represented by the bools contained in the list
l when evaluated as a signed binary number.
Parameters
l: The list of bools to be converted to an integer. The bool
at index 0 is evaluated as the least significant bit. False
represents a zero and True represents a one. If the list is
empty this function returns 0. If the list contains more than
32 bools, the function returns the signed integer value of
the first 32 bools in the list.
Return Value
The integer value of the binary list content.
Example command:
binary_list_to_integer([True,False,False,True])
• Example Parameters:
– l represents the binary values 1001
∗ Returns 9
ceil(f )
Returns the smallest integer value that is not less than f
68 URScript
Functions Module urmath
cos(f )
Returns the cosine of f
d2r(d)
Returns degrees-to-radians of d
floor(f )
Returns largest integer not greater than f
69 URScript
Functions Module urmath
get_list_length(v)
Returns the length of a list variable
The length of a list is the number of entries the list is composed of.
Parameters
v: A list variable
Return Value
An integer specifying the length of the given list
Example command: get_list_length([1,3,3,6,2])
• Example Parameters:
– v is the list 1,3,3,6,2
∗ Returns 5
integer_to_binary_list(x)
Returns the binary representation of x
70 URScript
Functions Module urmath
inv(m)
Get the inverse of a matrix or pose
71 URScript
Functions Module urmath
length(v)
Returns the length of a list or string variable
log(b, f )
Returns the logarithm of f to the base b
72 URScript
Functions Module urmath
norm(a)
Returns the norm of the argument
List: In this case the euclidian norm of the list is returned, the list
elements must be numbers.
Parameters
a: Pose, float, int or List
Return Value
norm of a
Example command:
• norm(-5.3) → Returns 5.3
• norm(-8) → Returns 8
• norm(p[-.2,.2,-.2,-1.57,0,3.14]) → Returns 3.52768
normalize(v)
Returns the normalized form of a list of floats
Except for the case of all zeroes, the normalized form corresponds to
the unit vector in the direction of v.
73 URScript
Functions Module urmath
point_dist(p_from, p_to)
Point distance
Parameters
p_from: tool pose (pose)
p_to: tool pose (pose)
Return Value
Distance between the two tool positions (without
considering rotations)
Example command: point_dist(p[.2,.5,.1,1.57,0,3.14],
p[.2,.5,.6,0,1.57,3.14])
• Example Parameters:
– p_from = p[.2,.5,.1,1.57,0,3.14] → The first point
– p_to = p[.2,.5,.6,0,1.57,3.14] → The second point
∗ Returns distance between the points regardless of
rotation
pose_add(p_1, p_2)
Pose addition
74 URScript
Functions Module urmath
pose_dist(p_from, p_to)
Pose distance
Parameters
p_from: tool pose (pose)
p_to: tool pose (pose)
Return Value
distance
Example command: pose_dist(p[.2,.5,.1,1.57,0,3.14],
p[.2,.5,.6,0,1.57,3.14])
• Example Parameters:
– p_from = p[.2,.5,.1,1.57,0,3.14] → The first point
– p_to = p[.2,.5,.6,0,1.57,3.14] → The second point
∗ Returns distance between two poses including rotation
pose_inv(p_from)
Get the inverse of a pose
Parameters
p_from: tool pose (spatial vector)
Return Value
inverse tool pose transformation (spatial vector)
Example command: pose_inv(p[.2,.5,.1,1.57,0,3.14])
• Example Parameters:
– p_from = p[.2,.5,.1,1.57,0,3.14] → The point
∗ Returns p[0.19324,0.41794,-0.29662,1.23993,0.0,2.47985]
75 URScript
Functions Module urmath
pose_sub(p_to, p_from)
Pose subtraction
Parameters
p_to: tool pose (spatial vector)
p_from: tool pose (spatial vector)
Return Value
tool pose transformation (spatial vector)
Example command: pose_sub(p[.2,.5,.1,1.57,0,0],
p[.2,.5,.6,1.57,0,0])
• Example Parameters:
– p_1 = p[.2,.5,.1,1.57,0,0] → The first point
– p_2 = p[.2,.5,.6,1.57,0,0] → The second point
∗ Returns p[0.0,0.0,-0.5,0.0,.0.,0.0]
76 URScript
Functions Module urmath
pose_trans(p_from, p_from_to)
Pose transformation
This function can be seen in two different views. Either the function
transforms, that is translates and rotates, p_from_to by the parameters
of p_from. Or the function is used to get the resulting pose, when first
making a move of p_from and then from there, a move of p_from_to.
77 URScript
Functions Module urmath
pow(base, exponent)
Returns base raised to the power of exponent
r2d(r)
Returns radians-to-degrees of r
random()
Random Number
Return Value
pseudo-random number between 0 and 1 (float)
78 URScript
Functions Module urmath
rotvec2rpy(rotation_vector)
Returns RPY vector corresponding to rotation_vector
79 URScript
Functions Module urmath
rpy2rotvec(rpy_vector)
Returns rotation vector corresponding to rpy_vector
sin(f )
Returns the sine of f
80 URScript
Functions Module urmath
size(v)
Returns the size of a matrix variable, the length of a list or string variable
Parameters
v: A matrix, list or string variable
Return Value
Given a list or a string the length is returned as an integer.
Given a matrix the size is returned as a list of two numbers
representing the number of rows and columns, respectively.
Example command:
• size("here I am") → Returns 9
• size([1,2,3,4,5]) → Returns 5
• size([[1,2],[3,4],[5,6]]) → Returns [3,2]
sqrt(f )
Returns the square root of f
tan(f )
Returns the tangent of f
81 URScript
Variables Module urmath
transpose(m)
Get the transpose of a matrix
Parameters
m: matrix or an array
Return Value
transposed matrix or array
Example command:
• transpose([[1,2],[3,4],[5,6]]) → Returns [[1,3,5],[2,4,6]]
• transpose([1,2,3]) → Returns [[1],[2],[3]]
• transpose([[1],[2],[3]]) → Returns [1,2,3]
wrench_trans(T_from_to, w_from)
Wrench transformation
4.2 Variables
Name Description
__package__ Value: None
82 URScript
Variables Module urmath
83 URScript
Module interfaces
5 Module interfaces
5.1 Functions
enable_external_ft_sensor(enable, sensor_mass=0.0,
sensor_measuring_offset=[0.0, 0.0, 0.0], sensor_cog=[0.0, 0.0,
0.0])
Deprecated: This function is used for enabling and disabling the use of
external F/T measurements in the controller. Be aware that the
following functions are impacted: force_mode, screw_driving, and
teach_mode.
The RTDE interface shall be used for feeding F/T measurements into the
real-time control loop of the robot using input variable
external_force_torque of type VECTOR6D. If no other RTDE
watchdog has been configured (using script function
rtde_set_watchdog), a default watchdog will be set to a 10Hz
minimum update frequency when the external F/T sensor functionality
is enabled. If the update frequency is not met the robot program will
pause.
Parameters
enable: enable or disable feature
(bool)
sensor_mass: mass of the sensor in
kilograms (float)
sensor_measuring_offset: [x, y, z] measuring offset of the
sensor in meters relative to
the tool flange frame
sensor_cog: [x, y, z] center of gravity of the
sensor in meters relative to
the tool flange frame
Deprecated: When using this function, the sensor position is applied
such that the resulting torques are computed with opposite sign. Also,
this function does not compensate for payload in the calculation of
the wrench. New programs should use ft_rtde_input_enable in
place of this.
Notes:
• The TCP Configuration in the installation must also
include the weight and offset contribution of the sensor.
• Only the enable parameter is required; sensor mass,
offset and center of gravity are optional (zero if
not provided).
Example command: Please refer to ft_rtde_input_enable for some
examples of usage
84 URScript
Functions Module interfaces
ft_rtde_input_enable(enable, sensor_mass=0.0,
sensor_measuring_offset=[0.0, 0.0, 0.0], sensor_cog=[0.0, 0.0,
0.0])
This function is used for enabling and disabling the use of external F/T
measurements in the controller. Be aware that the following functions
are be impacted: force_mode, screw_driving, and teach_mode.
The RTDE interface shall be used for feeding F/T measurements into the
real-time control loop of the robot using input variable
external_force_torque of type VECTOR6D. If no other RTDE
watchdog has been configured (using script function
rtde_set_watchdog), a default watchdog will be set to a 10Hz
minimum update frequency when the external F/T sensor functionality
is enabled. If the update frequency is not met the robot program will
pause.
Parameters
enable: enable or disable feature
(bool)
sensor_mass: mass of the sensor in
kilograms (float)
sensor_measuring_offset: [x, y, z] measuring offset of the
sensor in meters relative to
the tool flange frame
sensor_cog: [x, y, z] center of gravity of the
sensor in meters relative to
the tool flange frame
Notes:
• This function replaces the deprecated
enable_external_ft_sensor.
• The TCP Configuration in the installation must also
include the weight and offset contribution of the sensor.
• Only the enable parameter is required; sensor mass,
offset and center of gravity are optional (zero if
not provided).
Example command:
• ft_rtde_input_enable(True, 1.0, [0.1, 0.0,
0.0], [0.2, 0.1, 0.5])
– Example Parameters:
∗ enable → Enabling the feed of an external F/T
measurements in the controller.
∗ sensor_mass → mass of F/T sensor is set to 1.0 Kg.
∗ sensor_measuring_offset → sensor measuring
offset is set to [0.1, 0.0, 0.0] m from the tool flange
in tool flange frame coordinates.
∗ sensor_cog → Center of Gravity of the sensor is
85 URScript
set to x=200 mm, y=100 mm, z=500 mm from the
center of the tool flange in tool flange frame
coordinates.
• ft_rtde_input_enable(True, 0.5)
Functions Module interfaces
get_analog_in(n)
Deprecated: Get analog input signal level
Parameters
n: The number (id) of the input, integer: [0:3]
Return Value
float, The signal level in Amperes, or Volts
Deprecated: The get_standard_analog_in and
get_tool_analog_in replace this function. Ports 2-3 should be
changed to 0-1 for the latter function. This function might be removed
in the next major release.
Note: For backwards compatibility n:2-3 go to the tool analog inputs.
Example command: get_analog_in(1)
• Example Parameters:
– n is analog input 1
∗ Returns value of analog output #1
get_analog_out(n)
Deprecated: Get analog output signal level
Parameters
n: The number (id) of the output, integer: [0:1]
Return Value
float, The signal level in Amperes, or Volts
Deprecated: The get_standard_analog_out replaces this function.
This function might be removed in the next major release.
Example command: get_analog_out(1)
• Example Parameters:
– n is analog output 1
∗ Returns value of analog output #1
86 URScript
Functions Module interfaces
get_configurable_digital_in(n)
Get configurable digital input signal level
get_configurable_digital_out(n)
Get configurable digital output signal level
87 URScript
Functions Module interfaces
get_digital_in(n)
Deprecated: Get digital input signal level
Parameters
n: The number (id) of the input, integer: [0:9]
Return Value
boolean, The signal level.
Deprecated: The get_standard_digital_in and
get_tool_digital_in replace this function. Ports 8-9 should be
changed to 0-1 for the latter function. This function might be removed
in the next major release.
Note: For backwards compatibility n:8-9 go to the tool digital inputs.
Example command: get_digital_in(1)
• Example Parameters:
– n is digital input 1
∗ Returns True or False
get_digital_out(n)
Deprecated: Get digital output signal level
Parameters
n: The number (id) of the output, integer: [0:9]
Return Value
boolean, The signal level.
Deprecated: The get_standard_digital_out and
get_tool_digital_out replace this function. Ports 8-9 should be
changed to 0-1 for the latter function. This function might be removed
in the next major release.
Note: For backwards compatibility n:8-9 go to the tool digital outputs.
Example command: get_digital_out(1)
• Example Parameters:
– n is digital output 1
∗ Returns True or False
88 URScript
Functions Module interfaces
get_flag(n)
Flags behave like internal digital outputs. They keep information
between program runs.
Parameters
n: The number (id) of the flag, integer: [0:31]
Return Value
Boolean, The stored bit.
Example command: get_flag(1)
• Example Parameters:
– n is flag number 1
∗ Returns True or False
get_standard_analog_in(n)
Get standard analog input signal level
get_standard_analog_out(n)
Get standard analog output signal level
Parameters
n: The number (id) of the output, integer: [0:1]
Return Value
float, The signal level in Amperes, or Volts
Example command: get_standard_analog_out(1)
• Example Parameters:
– n is standard analog output 1
∗ Returns value of standard analog output #1
89 URScript
Functions Module interfaces
get_standard_digital_in(n)
Get standard digital input signal level
get_standard_digital_out(n)
Get standard digital output signal level
90 URScript
Functions Module interfaces
get_tool_analog_in(n)
Get tool analog input signal level
get_tool_digital_in(n)
Get tool digital input signal level
91 URScript
Functions Module interfaces
get_tool_digital_out(n)
Get tool digital output signal level
get_tool_digital_output_mode(n)
Get the output mode of tool output pin.
Parameters
n: The number (id) of the output, Integer: [0:1]
Return Value
Integer [1:3], pin output mode. 1 = Sinking/NPN, 2 =
Sourcing/PNP, 3 = Push-Pull
Example command: get_tool_digital_output_mode(1)
• n is tool digital output 1.
– Returns Integer [1:3]
get_tool_output_mode()
Get tool Digital Outputs mode.
Return Value
Integer [0:1]: 0 = Digital Output Mode, 1 = Power(dual pin)
Mode
92 URScript
Functions Module interfaces
93 URScript
Functions Module interfaces
modbus_delete_signal(signal_name)
Deletes the signal identified by the supplied signal name.
>>> modbus_delete_signal("output1")
Parameters
signal_name: A string equal to the name of the signal that
should be deleted.
Example command: modbus_delete_signal("output1")
• Example Parameters:
– Signal name = output1
modbus_get_signal_status(signal_name, is_secondary_program)
Reads the current value of a specific signal.
>>> modbus_get_signal_status("output1",False)
Parameters
signal_name: A string equal to the name of the
signal for which the value should
be gotten.
is_secondary_program: A boolean for internal use only.
Must be set to False.
Return Value
An integer or a boolean. For digital signals: True or False. For
register signals: The register value expressed as an unsigned
integer.
Example command:
modbus_get_signal_status("output1",False)
• Example Parameters:
– Signal name = output 1
– Is_secondary_program = False (Note: must be set to False)
94 URScript
Functions Module interfaces
>>> modbus_send_custom_command("172.140.17.11",103,6,
>>> [17,32,2,88])
95 URScript
Functions Module interfaces
modbus_set_digital_input_action(signal_name, action)
Sets the selected digital input signal to either a "default" or "freedrive"
action.
modbus_set_output_register(signal_name, register_value,
is_secondary_program)
Sets the output register signal identified by the given name to the given
value.
>>> modbus_set_output_register("output1",300,False)
Parameters
signal_name: A string identifying an output
register signal that in advance
has been added.
register_value: An integer which must be a valid
word (0-65535) value.
is_secondary_program: A boolean for interal use only.
Must be set to False.
Example command: modbus_set_output_register("output1",
300, False)
• Example Parameters:
– Signal name = output1
– Register value = 300
– Is_secondary_program = False (Note: must be set to False)
96 URScript
Functions Module interfaces
modbus_set_output_signal(signal_name, digital_value,
is_secondary_program)
Sets the output digital signal identified by the given name to the given
value.
>>> modbus_set_output_signal("output2",True,False)
Parameters
signal_name: A string identifying an output
digital signal that in advance has
been added.
digital_value: A boolean to which value the
signal will be set.
is_secondary_program: A boolean for interal use only.
Must be set to False.
Example command: modbus_set_output_signal("output1",
True, False)
• Example Parameters:
– Signal name = output1
– Digital value = True
– Is_secondary_program = False (Note: must be set to False)
modbus_set_signal_update_frequency(signal_name,
update_frequency)
Sets the frequency with which the robot will send requests to the
Modbus controller to either read or write the signal value.
>>> modbus_set_signal_update_frequency("output2",20)
Parameters
signal_name: A string identifying an output digital
signal that in advance has been
added.
update_frequency: An integer in the range 0-500
specifying the update frequency in Hz.
Example command:
modbus_set_signal_update_frequency("output2", 20)
• Example Parameters:
– Signal name = output2
– Signal update frequency = 20 Hz
97 URScript
Functions Module interfaces
read_input_boolean_register(address)
Reads the boolean from one of the input registers, which can also be
accessed by a Field bus. Note, uses it’s own memory space.
Parameters
address: Address of the register (0:127)
Return Value
The boolean value held by the register (True, False)
Note: The lower range of the boolean input registers [0:63] is reserved
for FieldBus/PLC interface usage. The upper range [64:127] cannot be
accessed by FieldBus/PLC interfaces, since it is reserved for external
RTDE clients.
>>> bool_val = read_input_boolean_register(3)
Example command: read_input_boolean_register(3)
• Example Parameters:
– Address = input boolean register 3
read_input_float_register(address)
Reads the float from one of the input registers, which can also be
accessed by a Field bus. Note, uses it’s own memory space.
Parameters
address: Address of the register (0:47)
Return Value
The value held by the register (float)
Note: The lower range of the float input registers [0:23] is reserved for
FieldBus/PLC interface usage. The upper range [24:47] cannot be
accessed by FieldBus/PLC interfaces, since it is reserved for external
RTDE clients.
>>> float_val = read_input_float_register(3)
Example command: read_input_float_register(3)
• Example Parameters:
– Address = input float register 3
98 URScript
Functions Module interfaces
read_input_integer_register(address)
Reads the integer from one of the input registers, which can also be
accessed by a Field bus. Note, uses it’s own memory space.
Parameters
address: Address of the register (0:47)
Return Value
The value held by the register [-2,147,483,648 : 2,147,483,647]
Note: The lower range of the integer input registers [0:23] is reserved for
FieldBus/PLC interface usage. The upper range [24:47] cannot be
accessed by FieldBus/PLC interfaces, since it is reserved for external
RTDE clients.
>>> int_val = read_input_integer_register(3)
Example command: read_input_integer_register(3)
• Example Parameters:
– Address = input integer register 3
read_output_boolean_register(address)
Reads the boolean from one of the output registers, which can also be
accessed by a Field bus. Note, uses it’s own memory space.
Parameters
address: Address of the register (0:127)
Return Value
The boolean value held by the register (True, False)
Note: The lower range of the boolean output registers [0:63] is reserved
for FieldBus/PLC interface usage. The upper range [64:127] cannot be
accessed by FieldBus/PLC interfaces, since it is reserved for external
RTDE clients.
>>> bool_val = read_output_boolean_register(3)
Example command: read_output_boolean_register(3)
• Example Parameters:
– Address = output boolean register 3
99 URScript
Functions Module interfaces
read_output_float_register(address)
Reads the float from one of the output registers, which can also be
accessed by a Field bus. Note, uses it’s own memory space.
Parameters
address: Address of the register (0:47)
Return Value
The value held by the register (float)
Note: The lower range of the float output registers [0:23] is reserved for
FieldBus/PLC interface usage. The upper range [24:47] cannot be
accessed by FieldBus/PLC interfaces, since it is reserved for external
RTDE clients.
>>> float_val = read_output_float_register(3)
Example command: read_output_float_register(3)
• Example Parameters:
– Address = output float register 3
read_output_integer_register(address)
Reads the integer from one of the output registers, which can also be
accessed by a Field bus. Note, uses it’s own memory space.
Parameters
address: Address of the register (0:47)
Return Value
The int value held by the register [-2,147,483,648 :
2,147,483,647]
Note: The lower range of the integer output registers [0:23] is reserved
for FieldBus/PLC interface usage. The upper range [24:47] cannot be
accessed by FieldBus/PLC interfaces, since it is reserved for external
RTDE clients.
>>> int_val = read_output_integer_register(3)
Example command: read_output_integer_register(3)
• Example Parameters:
– Address = output integer register 3
100 URScript
Functions Module interfaces
read_port_bit(address)
Reads one of the ports, which can also be accessed by Modbus clients
read_port_register(address)
Reads one of the ports, which can also be accessed by Modbus clients
101 URScript
Functions Module interfaces
rpc_factory(type, url)
Creates a new Remote Procedure Call (RPC) handle. Please read the
subsection ef{Remote Procedure Call (RPC)} for a more detailed
description of RPCs.
102 URScript
Functions Module interfaces
103 URScript
Functions Module interfaces
set_analog_inputrange(port, range)
Deprecated: Set range of analog inputs
set_analog_out(n, f )
Deprecated: Set analog output signal level
Parameters
n: The number (id) of the output, integer: [0:1]
f: The relative signal level [0;1] (float)
Deprecated: The set_standard_analog_out replaces this function.
This function might be removed in the next major release.
Example command: set_analog_out(1,0.5)
• Example Parameters:
– n is analog output port 1 (on controller)
– f = 0.5, that corresponds to 5V (or 12mA depending on
domain setting) on the output port
104 URScript
Functions Module interfaces
set_configurable_digital_out(n, b)
Set configurable digital output signal level
set_digital_out(n, b)
Deprecated: Set digital output signal level
Parameters
n: The number (id) of the output, integer: [0:9]
b: The signal level. (boolean)
Deprecated: The set_standard_digital_out and
set_tool_digital_out replace this function. Ports 8-9 should be
changed to 0-1 for the latter function. This function might be removed
in the next major release.
Example command: set_digital_out(1,True)
• Example Parameters:
– n is digital output 1
– b = True
set_flag(n, b)
Flags behave like internal digital outputs. They keep information
between program runs.
Parameters
n: The number (id) of the flag, integer: [0:31]
b: The stored bit. (boolean)
Example command: set_flag(1,True)
• Example Parameters:
– n is flag number 1
– b = True will set the bit to True
105 URScript
Functions Module interfaces
set_standard_analog_out(n, f )
Set standard analog output signal level
Parameters
n: The number (id) of the output, integer: [0:1]
f: The relative signal level [0;1] (float)
Example command: set_standard_analog_out(1,1.0)
• Example Parameters:
– n is standard analog output port 1
– f = 1.0, that corresponds to 10V (or 20mA depending on
domain setting) on the output port
set_standard_digital_out(n, b)
Set standard digital output signal level
106 URScript
Functions Module interfaces
107 URScript
Functions Module interfaces
set_tool_digital_out(n, b)
Set tool digital output signal level
set_tool_digital_output_mode(n, mode)
Set output mode of tool output pin
Parameters
n: The number (id) of the output, integer: [0:1]
mode: The pin mode. Integer: [1:3]. 1 = Sinking/NPN, 2 =
Sourcing / PNP, 3 = Push-Pull.
Example command: set_tool_digital_output_mode(0, 2)
• Example Parameters:
– 0 is digital output pin 0.
– 2 is pin mode sourcing/PNP. The pin will source current when
set to 1 and be high impedance when set to 0.
set_tool_output_mode(mode)
Set tool Digital Outputs mode
Parameters
mode: The output mode to set, integer: [0:1]. 0 = Digital
Output mode, 1 = Power(dual pin) mode
Example command: set_tool_output_mode(1)
• Example Parameters:
– 1 is power(dual pin) mode. The digital outputs will be used as
extra supply.
108 URScript
Functions Module interfaces
set_tool_voltage(voltage)
Sets the voltage level for the power supply that delivers power to the
connector plug in the tool flange of the robot. The votage can be 0, 12
or 24 volts.
Parameters
voltage: The voltage (as an integer) at the tool connector,
integer: 0, 12 or 24.
Example command: set_tool_voltage(24)
• Example Parameters:
– voltage = 24 volts
socket_close(socket_name=’socket_0’)
Closes TCP/IP socket communication
>>> socket_comm_close()
Parameters
socket_name: Name of socket (string)
Example command: socket_close(socket_name="socket_0")
• Example Parameters:
– socket_name = socket_0
socket_get_var(name, socket_name=’socket_0’)
Reads an integer from the server
Sends the message "GET <name>\n" through the socket, expects the
response "<name> <int>\n" within 2 seconds. Returns 0 after timeout
Parameters
name: Variable name (string)
socket_name: Name of socket (string)
Return Value
an integer from the server (int), 0 is the timeout value
Example command: x_pos = socket_get_var("POS_X")
Sends: GET POS_X\n to socket_0, and expects response within 2s
• Example Parameters:
– name = POS_X → name of variable
– socket_name = default: socket_0
109 URScript
Functions Module interfaces
110 URScript
Functions Module interfaces
socket_read_ascii_float(number, socket_name=’socket_0’,
timeout=2)
Reads a number of ascii formatted floats from the socket. A maximum
of 30 values can be read in one command.
The returned list contains the total numbers read, and then each
number in succession. For example a read_ascii_float on the example
above would return [4, 1.414, 3.14159, 1.616, 0.0].
A failed read or timeout will return the list with 0 as first element and
then "Not a number (nan)" in the following elements (ex. [0, nan, nan,
nan] for a read of three numbers).
Parameters
number: The number of variables to read (int)
socket_name: Name of socket (string)
timeout: The number of seconds until the read action
times out (float). A timeout of 0 or negative
number indicates that the function should
not return until a read is completed.
Return Value
A list of numbers read (list of floats, length=number+1)
Example command: list_of_four_floats =
socket_read_ascii_float(4,"socket_10")
• Example Parameters:
– number = 4 → Number of floats to read
– socket_name = socket_10
∗ returns list
111 URScript
Functions Module interfaces
socket_read_binary_integer(number, socket_name=’socket_0’,
timeout=2)
Reads a number of 32 bit integers from the socket. Bytes are in network
byte order. A maximum of 30 values can be read in one command.
112 URScript
Functions Module interfaces
113 URScript
Functions Module interfaces
socket_read_line(socket_name=’socket_0’, timeout=2)
Deprecated: Reads the socket buffer until the first "\r\n" (carriage
return and newline) characters or just the "\n" (newline) character, and
returns the data as a string. The returned string will not contain the "\n"
nor the "\r\n" characters.
Returns (for example) "reply from the server:", if there is a timeout or the
reply is invalid, an empty line is returned (""). You can test if the line is
empty with an if-statement.
>>> if(line_from_server) :
>>> popup("the line is not empty")
>>> end
Parameters
socket_name: Name of socket (string)
timeout: The number of seconds until the read action
times out (float). A timeout of 0 or negative
number indicates that the function should
not return until a read is completed.
Return Value
One line string
Deprecated: The socket_read_string replaces this function. Set flag
"interpret_escape" to "True" to enable the use of escape sequences
"\n" "\r" and "\t" as a prefix or suffix.
Example command: line_from_server =
socket_read_line("socket_10")
• Example Parameters:
– socket_name = socket_10
114 URScript
Functions Module interfaces
Returns (for example) "reply from the server:\n Hello World". if there is a
timeout or the reply is invalid, an empty string is returned (""). You can
test if the string is empty with an if-statement.
>>> if(string_from_server) :
>>> popup("the string is not empty")
>>> end
By using the "prefix" and "suffix" it is also possible send multiple string to
the controller at once, because the suffix defines where the message
ends. E.g. sending ">hello<>world<" and calling this script function with
the prefix=">" and suffix="<".
Note that leading spaces in the prefix and suffix strings are ignored in
the current software and may cause communication errors in future
releases.
115 URScript
Functions Module interfaces
socket_send_byte(value, socket_name=’socket_0’)
Sends a byte to the server
Sends the byte <value> through the socket. Expects no response. Can
be used to send special ASCII characters: 10 is newline, 2 is start of text,
3 is end of text.
Parameters
value: The number to send (byte)
socket_name: Name of socket (string)
Return Value
a boolean value indicating whether the send operation was
successful
Example command: socket_send_byte(2,"socket_10")
• Example Parameters:
– value = 2
– socket_name = socket_10
∗ Returns True or False (sent or not sent)
socket_send_int(value, socket_name=’socket_0’)
Sends an int (int32_t) to the server
Sends the int <value> through the socket. Send in network byte order.
Expects no response.
Parameters
value: The number to send (int)
socket_name: Name of socket (string)
Return Value
a boolean value indicating whether the send operation was
successful
Example command: socket_send_int(2,"socket_10")
• Example Parameters:
– value = 2
– socket_name = socket_10
∗ Returns True or False (sent or not sent)
116 URScript
Functions Module interfaces
socket_send_line(str, socket_name=’socket_0’)
Sends a string with a newline character to the server - useful for
communicating with the UR dashboard server
Sends the string <str> through the socket in ASCII coding. Expects no
response.
Parameters
str: The string to send (ascii)
socket_name: Name of socket (string)
Return Value
a boolean value indicating whether the send operation was
successful
Example command: socket_send_line("hello","socket_10")
Sends: hello\n to socket_10
• Example Parameters:
– str = hello
– socket_name = socket_10
∗ Returns True or False (sent or not sent)
socket_send_string(str, socket_name=’socket_0’)
Sends a string to the server
Sends the string <str> through the socket in ASCII coding. Expects no
response.
Parameters
str: The string to send (ascii)
socket_name: Name of socket (string)
Return Value
a boolean value indicating whether the send operation was
successful
Example command: socket_send_string("hello","socket_10")
Sends: hello to socket_10
• Example Parameters:
– str = hello
– socket_name = socket_10
∗ Returns True or False (sent or not sent)
117 URScript
Functions Module interfaces
write_output_boolean_register(address, value)
Writes the boolean value into one of the output registers, which can
also be accessed by a Field bus. Note, uses it’s own memory space.
Parameters
address: Address of the register (0:127)
value: Value to set in the register (True, False)
Note: The lower range of the boolean output registers [0:63] is reserved
for FieldBus/PLC interface usage. The upper range [64:127] cannot be
accessed by FieldBus/PLC interfaces, since it is reserved for external
RTDE clients.
>>> write_output_boolean_register(3, True)
Example command: write_output_boolean_register(3,True)
• Example Parameters:
– address = 3
– value = True
118 URScript
Functions Module interfaces
write_output_float_register(address, value)
Writes the float value into one of the output registers, which can also
be accessed by a Field bus. Note, uses it’s own memory space.
Parameters
address: Address of the register (0:47)
value: Value to set in the register (float)
Note: The lower part of the float output registers [0:23] is reserved for
FieldBus/PLC interface usage. The upper range [24:47] cannot be
accessed by FieldBus/PLC interfaces, since it is reserved for external
RTDE clients.
>>> write_output_float_register(3, 37.68)
Example command: write_output_float_register(3,37.68)
• Example Parameters:
– address = 3
– value = 37.68
write_output_integer_register(address, value)
Writes the integer value into one of the output registers, which can also
be accessed by a Field bus. Note, uses it’s own memory space.
Parameters
address: Address of the register (0:47)
value: Value to set in the register [-2,147,483,648 :
2,147,483,647]
Note: The lower range of the integer output registers [0:23] is reserved
for FieldBus/PLC interface usage. The upper range [24:47] cannot be
accessed by FieldBus/PLC interfaces, since it is reserved for external
RTDE clients.
>>> write_output_integer_register(3, 12)
Example command: write_output_integer_register(3,12)
• Example Parameters:
– address = 3
– value = 12
119 URScript
Variables Module interfaces
write_port_bit(address, value)
Writes one of the ports, which can also be accessed by Modbus clients
>>> write_port_bit(3,True)
Parameters
address: Address of the port (See port map on Support
site, page "Modbus Server" )
value: Value to be set in the register (True, False)
Example command: write_port_bit(3,True)
• Example Parameters:
– Address = 3
– Value = True
write_port_register(address, value)
Writes one of the ports, which can also be accessed by Modbus clients
>>> write_port_register(3,100)
Parameters
address: Address of the port (See port map on Support
site, page "Modbus Server" )
value: Value to be set in the port (0 : 65536) or (-32768 :
32767)
Example command: write_port_register(3,100)
• Example Parameters:
– Address = 3
– Value = 100
zero_ftsensor()
Zeroes the TCP force/torque measurement from the builtin force/torque
sensor by subtracting the current measurement from the subsequent.
Note: Function only applicable in G5
5.2 Variables
Name Description
__package__ Value: None
120 URScript
Module ioconfiguration
6 Module ioconfiguration
6.1 Functions
modbus_set_runstate_dependent_choice(signal_name,
runstate_choice)
Sets the output signal levels depending on the state of the program.
Parameters
signal_name: A string identifying a digital or register output
signal that in advance has been added.
state: 0: Preserve signal state,
1: Set signal Low when program is not
running,
2: Set signal High when program is not
running,
3: Set signal High when program is running
and low when it is stopped,
4: Set signal Low when program terminates
unscheduled,
5: Set signal High from the moment a
program is started and Low when a program
terminates unscheduled.
Note: An unscheduled program termination is caused when a
Protective stop, Fault, Violation or Runtime exception occurs.
Example command:
modbus_set_runstate_dependent_choice("output2", 3)
• Example Parameters:
– Signal name = output2
– Runstate dependent choice = 3 → set Low when a program
is stopped and High when a program is running
121 URScript
Functions Module ioconfiguration
set_analog_outputdomain(port, domain)
Set domain of analog outputs
Parameters
port: analog output port number
domain: analog output domain: 0: 4-20mA, 1: 0-10V
Example command: set_analog_outputdomain(1,1)
• Example Parameters:
– port is analog output port 1 (on controller)
– domain = 1 (0-10 volts)
set_configurable_digital_input_action(port, action)
Using this method sets the selected configurable digital input register to
either a "default" or "freedrive" action.
See also:
• set_input_actions_to_default
• set_standard_digital_input_action
• set_tool_digital_input_action
• set_gp_boolean_input_action
Parameters
port: The configurable digital input port number.
(integer)
action: The type of action. The action can either be
"default" or "freedrive". (string)
Example command: set_configurable_digital_input_action(0,
"freedrive")
• Example Parameters:
– n is the configurable digital input register 0
– f is set to "freedrive" action
122 URScript
Functions Module ioconfiguration
set_gp_boolean_input_action(port, action)
Using this method sets the selected gp boolean input register to either
a "default" or "freedrive" action.
Parameters
port: The gp boolean input port number. integer: [0:127]
action: The type of action. The action can either be
"default" or "freedrive". (string)
Note: The lower range of the boolean input registers [0:63] is reserved
for FieldBus/PLC interface usage. The upper range [64:127] cannot be
accessed by FieldBus/PLC interfaces, since it is reserved for external
RTDE clients.
See also:
• set_input_actions_to_default
• set_standard_digital_input_action
• set_configurable_digital_input_action
• set_tool_digital_input_action
Example command: set_gp_boolean_input_action(64,
"freedrive")
• Example Parameters:
– n is the gp boolean input register 0
– f is set to "freedrive" action
set_input_actions_to_default()
Using this method sets the input actions of all standard, configurable,
tool, and gp_boolean input registers to "default" action.
See also:
• set_standard_digital_input_action
• set_configurable_digital_input_action
• set_tool_digital_input_action
• set_gp_boolean_input_action
Example command: set_input_actions_to_default()
123 URScript
Functions Module ioconfiguration
set_runstate_configurable_digital_output_to_value(outputId, state)
Sets the output signal levels depending on the state of the program.
>>> set_runstate_configurable_digital_output_to_value(5, 2)
Parameters
outputId: The output signal number (id), integer: [0:7]
state: 0: Preserve signal state,
1: Set signal Low when program is not running,
2: Set signal High when program is not running,
3: Set signal High when program is running and
low when it is stopped,
4: Set signal Low when program terminates
unscheduled,
5: Set signal High from the moment a program is
started and Low when a program terminates
unscheduled.
Note: An unscheduled program termination is caused when a
Protective stop, Fault, Violation or Runtime exception occurs.
Example command:
set_runstate_configurable_digital_output_to_value(5, 2)
• Example Parameters:
– outputid = configurable digital output on port 5
– Runstate choice = 4 → configurable digital output on port 5
goes low when a program is terminated unscheduled.
124 URScript
Functions Module ioconfiguration
set_runstate_gp_boolean_output_to_value(outputId, state)
Sets the output value depending on the state of the program.
Parameters
outputId: The output signal number (id), integer: [0:127]
state: 0: Preserve signal state,
1: Set signal to False when program is not
running,
2: Set signal to True when program is not running,
3: Set signal to True when program is running
and False when it is stopped,
4: Set signal to False when program terminates
unscheduled,
5: Set signal to True from the moment a program
is started and False when a program terminates
unscheduled.
Notes:
• The lower range of the boolean output registers [0:63] is
reserved for FieldBus/PLC interface usage. The upper
range [64:127] cannot be accessed by FieldBus/PLC
interfaces, since it is reserved for external RTDE clients.
• An unscheduled program termination is caused when a
Protective stop, Fault, Violation or Runtime exception
occurs.
Example command:
set_runstate_gp_boolean_output_to_value(64, 2)
• Example Parameters:
– outputid = output on port 64
– Runstate choice = 2 → sets signal on port 64 to True when
program is not running
125 URScript
Functions Module ioconfiguration
set_runstate_gp_float_output_to_value(outputId, state)
Sets the output value depending on the state of the program.
Parameters
outputId: The output signal number (id), integer: [0:47]
state: 0 = Preserve signal state,
1 = Set signal to 0.0 when program is not running,
2 = Set signal to 1.0 when program is not running,
3 = Set signal to 1.0 when program is running
and 0.0 when it is stopped.
4: Set signal to 0.0 when program terminates
unscheduled,
5: Set signal to 1.0 from the moment a program
is started and 0.0 when a program terminates
unscheduled.
Notes:
• The lower range of the float output registers [0:23] is
reserved for FieldBus/PLC interface usage. The upper
range [24:47] cannot be accessed by FieldBus/PLC
interfaces, since it is reserved for external RTDE clients.
• An unscheduled program termination is caused when a
Protective stop, Fault, Violation or Runtime exception
occurs.
Example command:
set_runstate_gp_boolean_output_to_value(24, 2)
• Example Parameters:
– outputid = output on port 24
– Runstate choice = 1 → sets signal on port 24 to 0.0 when
program is not running
126 URScript
Functions Module ioconfiguration
set_runstate_gp_integer_output_to_value(outputId, state)
Sets the output value depending on the state of the program.
Parameters
outputId: The output signal number (id), integer: [0:47]
state: 0: Preserve signal state,
1: Set signal to 0 when program is not running,
2: Set signal to 1 when program is not running,
3: Set signal to 1 when program is running and 1
when it is stopped,
4: Set signal to 0 when program terminates
unscheduled,
5: Set signal to 1 from the moment a program is
started and 0 when a program terminates
unscheduled.
Notes:
• The lower range of the integer output registers [0:23] is
reserved for FieldBus/PLC interface usage. The upper
range [24:47] cannot be accessed by FieldBus/PLC
interfaces, since it is reserved for external RTDE clients.
• An unscheduled program termination is caused when a
Protective stop, Fault, Violation or Runtime exception
occurs.
Example command:
set_runstate_gp_boolean_output_to_value(24, 2)
• Example Parameters:
– outputid = output on port 24
– Runstate choice = 2 → sets signal on port 24 to 1 when
program is not running
127 URScript
Functions Module ioconfiguration
set_runstate_standard_analog_output_to_value(outputId, state)
Sets the output signal levels depending on the state of the program.
>>> set_runstate_standard_analog_output_to_value(1, 2)
Parameters
outputId: The output signal number (id), integer: [0:1]
state: 0: Preserve signal state,
1: Set signal Low when program is not running,
2: Set signal High when program is not running,
3: Set signal High when program is running and
low when it is stopped,
4: Set signal Low when program terminates
unscheduled,
5: Set signal High from the moment a program is
started and Low when a program terminates
unscheduled.
Note: An unscheduled program termination is caused when a
Protective stop, Fault, Violation or Runtime exception occurs.
Example command:
set_runstate_standard_analog_output_to_value(1, 2)
• Example Parameters:
– outputid = standard analog output on port 1
– Runstate choice = 2 → analog output on port 1 goes High
when program is not running
128 URScript
Functions Module ioconfiguration
set_runstate_standard_digital_output_to_value(outputId, state)
Sets the output signal level depending on the state of the program.
>>> set_runstate_standard_digital_output_to_value(5, 2)
Parameters
outputId: The output signal number (id), integer: [0:7]
state: 0: Preserve signal state,
1: Set signal Low when program is not running,
2: Set signal High when program is not running,
3: Set signal High when program is running and
low when it is stopped,
4: Set signal Low when program terminates
unscheduled,
5: Set signal High from the moment a program is
started and Low when a program terminates
unscheduled.
Note: An unscheduled program termination is caused when a
Protective stop, Fault, Violation or Runtime exception occurs.
Example command:
set_runstate_standard_digital_output_to_value(5, 2)
• Example Parameters:
– outputid = standard digital output on port 1
– Runstate choice = 2 → sets digital output on port 1 to High
when program is not running
129 URScript
Functions Module ioconfiguration
set_runstate_tool_digital_output_to_value(outputId, state)
Sets the output signal level depending on the state of the program.
Example: Set tool digital output 1 to high when program is not running.
>>> set_runstate_tool_digital_output_to_value(1, 2)
Parameters
outputId: The output signal number (id), integer: [0:1]
state: 0: Preserve signal state,
1: Set signal Low when program is not running,
2: Set signal High when program is not running,
3: Set signal High when program is running and
low when it is stopped,
4: Set signal Low when program terminates
unscheduled,
5: Set signal High from the moment a program is
started and Low when a program terminates
unscheduled.
Note: An unscheduled program termination is caused when a
Protective stop, Fault, Violation or Runtime exception occurs.
Example command:
set_runstate_tool_digital_output_to_value(1, 2)
• Example Parameters:
– outputid = tool digital output on port 1
– Runstate choice = 2 → digital output on port 1 goes High
when program is not running
set_standard_analog_input_domain(port, domain)
Set domain of standard analog inputs in the controller box
130 URScript
Functions Module ioconfiguration
set_standard_digital_input_action(port, action)
Using this method sets the selected standard digital input register to
either a "default" or "freedrive" action.
See also:
• set_input_actions_to_default
• set_configurable_digital_input_action
• set_tool_digital_input_action
• set_gp_boolean_input_action
Parameters
port: The standard digital input port number. (integer)
action: The type of action. The action can either be
"default" or "freedrive". (string)
Example command: set_standard_digital_input_action(0,
"freedrive")
• Example Parameters:
– n is the standard digital input register 0
– f is set to "freedrive" action
set_tool_analog_input_domain(port, domain)
Set domain of analog inputs in the tool
131 URScript
Module processpath
set_tool_digital_input_action(port, action)
Using this method sets the selected tool digital input register to either a
"default" or "freedrive" action.
See also:
• set_input_actions_to_default
• set_standard_digital_input_action
• set_configurable_digital_input_action
• set_gp_boolean_input_action
Parameters
port: The tool digital input port number. (integer)
action: The type of action. The action can either be
"default" or "freedrive". (string)
Example command: set_tool_digital_input_action(0,
"freedrive")
• Example Parameters:
– n is the tool digital input register 0
– f is set to "freedrive" action
6.2 Variables
Name Description
__package__ Value: None
7 Module processpath
NOTE:
1. These script functions are only accessible if the program is being run from within
Polyscope.
2. The Remote TCP & Toolpath URCap Controller must run in order for the script func-
tions to work. Go to Installation > URCaps > Remote TCP & Toolpath URCap to
start the controller from the URCap home page.
3. The script functions are available in the Functions dropdown within the Script
node (Program > Advanced > Script). Note: mc_add_circular() requires six
arguments, but only five arguments are displayed in the Functions dropdown.
Please make sure to specify the sixth argument ‘mode’ when using this function.
132 URScript
Functions Module processpath
7.1 Functions
133 URScript
Functions Module processpath
mc_add_linear(pose, a, v, r)
Add a motion to move to pose (linear in tool-space).
134 URScript
Functions Module processpath
mc_add_path(path_id, a, v, r)
Add a motion to move according to the g-codes specified in the
nc_file.
Parameters
path_id: path ID returned from the mc_load_path call
a: tool acceleration [m/s^2]
v: tool speed [m/s]
r: blend radius [m]
Return Value
The motion ID
Example command: id = mc_add_path(path_id=1, a=1.2,
v=0.25, r=0)
• Example Parameters:
– path_id = 1 → path_id from the mc_load_path call
– a = 1.2 → acceleration is 1.2 m/s^2
– v = 0.25 → velocity is 250 mm/s. This value is ignored if
useFeedRate=True when calling mc_load_path
– r = 0 → the blend radius is 0 meters
mc_get_target_rtcp_speed()
This command returns the target linear speed of a Remote TCP. To get
the target linear speed of a regular TCP, please use
get_target_tcp_speed_along_path().
Return Value
Remote TCP speed in m/s. This is a scalar without any
indication of travel direction.
Example command: rtcpSpeed = mc_get_target_rtcp_speed()
135 URScript
Functions Module processpath
This command must be called before every TCP motion sequence. The
command resets the speed factor to 1 (see also
mc_set_speed_factor), the Part Coordinate System to identity (see
also mc_set_pcs), and the motion ID counter to 0. The command
automatically turns on path divergence check if not in simulation
mode.
Parameters
mode: 0: Initialize regular TCP motion.
1: Initialize remote TCP motion.
tcp: If mode = 0, the regular TCP offset, i.e. the
transformation from the output flange coordinate
system to the TCP as a pose.
If mode = 1, the remote TCP offset, i.e. the
transformation from the robot base to the remote TCP
as a pose.
doc: degree of constraints
6: Constrain all 6-Degree of Freedom (DOF) of the
tool.
5: Constrain 5-DOF of the tool. The rotation about
z-axis is not constrained.
Example command: mc_initialize(1, p[0, 0.2, 0.3, 0, 3.14,
0], doc=6)
• Example Parameters:
– mode = 1 → remote TCP motion
– tcp = p[0, 0.2, 0.3, 0, 3.14, 0] → tool center point is set to x =
0mm, y = 200mm, z = 300mm, rotation vector is rx = 0deg, ry =
180deg, rz = 0deg, in robot base coordinates.
– doc = 6 → constrain 6-DOF
136 URScript
Functions Module processpath
mc_load_path(nc_file, useFeedRate)
Load a .nc toolpath file. This function returns a path id which is to be
used with the subsequent mc_add_path call. This function has to be
called for the same nc_file if it is to be executed with different speed
and acceleration values.
Parameters
nc_file: the .nc file on the disk
useFeedRate: specify whether to use feedrate mentioned
in the NC file
Return Value
The path ID
Example command: path_id =
mc_load_path("/programs/path.nc", useFeedRate=True)
• Example Parameters:
– nc_file = /programs/path.nc → the file that contains GCode
is /programs/path.nc
– useFeedRate = True → use the feedrate from .nc file
mc_run_motion(id=-1)
Run through the motion with ID id.
This command starts to move the robot (if not already started) then
waits for the motion with ID = id to finish. A motion with ID = x will only
be executed if mc_run_motion is called on id >= x or -1. This command
is used to run all queued motions (if id = -1) or when users would like to
call some instantaneous script (such as set_standard_digital_out) after
a particular motion. Do not call commands that take time to finish
(such as movep). Doing so will likely cause path divergence error.
Parameters
id: the motion ID. If id = -1, the command will run all
motions queued. If id = x, where x >= 0, the command
will run all motions with ID <= x.
Example command: mc_run_motion(id=2)
• Example Parameters:
– id = 2 → run motion with ID = 0, 1 and 2 to finish.
137 URScript
Examples Module processpath
mc_set_pcs(pcs)
Set the Part Coordinate System (PCS).
This command sets the PCS either in robot base coordinates (if called
after mc_initialize with mode = 0) or in tool flange coordinates (if
called after mc_initialize with mode = 1). Subsequent poses/paths
of motions will be relative to this PCS.
Parameters
pcs: The part coordinate system as a pose.
Example command: mc_set_pcs(p[0, 0.2, 0.3, 0, 3.14, 0])
• Example Parameters:
– pcs = p[0, 0.2, 0.3, 0, 3.14, 0] → part coordinate system is set
to x = 0mm, y = 200mm, z = 300mm, rotation vector is rx =
0deg, ry = 180deg, rz = 0deg.
mc_set_speed_factor(s)
Set speed factor in range [0, 1]. The tool speed will be v × s, where v is
the commanded tool speed in each motion.
7.2 Variables
Name Description
__package__ Value: ’ProcessPath’
7.3 Examples
138 URScript
Examples Module processpath
# Add motions
mc_add_linear(waypoint1, acc_factor, speed_factor, blend_radius)
mc_add_linear(waypoint2, acc_factor, speed_factor, blend_radius)
mc_add_circular(circle_viapoint, circle_endpoint, acc_factor,
speed_factor, blend_radius, mode)
mc_set_pcs(pcs)
mc_add_path("/programs/myToolPathFile.nc", acc_factor, speed_factor, 0.0)
139 URScript
Examples Module processpath
140 URScript
myToolPathFile.nc Module processpath
7.4 myToolPathFile.nc
%PM0
N10 G74 Z-5. L1
N20 G7
N30 G54
N40 ; Operation 1
N50 S1000 T1 M6 ; (Bull Mill, Diameter: 10, Flute Length: 25,
; Shoulder Length: 40, Overall Length: 40, Length including Holder: 40,
; Corner Radius: 2, Corner Radius Type: Corner)
N60 M3
N70 G74 Z-5. L1
N80 G54 I0
N90 G7
N100 M8
N110 G01 X-39.5178 Y-0.0003 Z24.9995 C0.0000 B0.0000 F1500
N120 G01 X-38.2246 Y-1.9469 Z24.9995 C0.0000 B0.0000 F1500
N130 G01 X-36.9313 Y-3.8934 Z24.9995 C0.0000 B0.0000 F1500
N140 G01 X-35.6381 Y-5.8400 Z24.9995 C0.0000 B0.0000 F1500
N150 G01 X-34.3448 Y-7.7866 Z24.9995 C0.0000 B0.0000 F1500
N160 G01 X-33.0515 Y-9.7332 Z24.9995 C0.0000 B0.0000 F1500
N170 G01 X-31.7583 Y-11.6798 Z24.9995 C0.0000 B0.0000 F1500
N180 G01 X-30.4650 Y-13.6264 Z24.9995 C0.0000 B0.0000 F1500
N190 G01 X-29.1718 Y-15.5729 Z24.9995 C0.0000 B0.0000 F1500
N200 G01 X-27.8785 Y-17.5195 Z24.9995 C0.0000 B0.0000 F1500
N210 G01 X-26.5853 Y-19.4661 Z24.9995 C0.0000 B0.0000 F1500
N220 G01 X-25.2920 Y-21.4127 Z24.9995 C0.0000 B0.0000 F1500
N230 G01 X-23.9988 Y-23.3593 Z24.9995 C0.0000 B0.0000 F1500
N240 G01 X-22.7055 Y-25.3059 Z24.9995 C0.0000 B0.0000 F1500
N250 G01 X-21.4123 Y-27.2524 Z24.9995 C0.0000 B0.0000 F1500
N260 G01 X-20.1190 Y-29.1990 Z24.9995 C0.0000 B0.0000 F1500
N270 G01 X-18.8258 Y-31.1456 Z24.9995 C0.0000 B0.0000 F1500
N280 G01 X-17.5325 Y-33.0922 Z24.9995 C0.0000 B0.0000 F1500
N290 G01 X-16.2393 Y-35.0388 Z24.9995 C0.0000 B0.0000 F1500
N300 G01 X-14.9460 Y-36.9854 Z24.9995 C0.0000 B0.0000 F1500
N310 G01 X-13.6527 Y-38.9319 Z24.9995 C0.0000 B0.0000 F1500
N320 G01 X-12.3595 Y-40.8785 Z24.9995 C0.0000 B0.0000 F1500
N330 G01 X-11.0662 Y-42.8251 Z24.9995 C0.0000 B0.0000 F1500
N340 G01 X-9.7730 Y-44.7717 Z24.9995 C0.0000 B0.0000 F1500
N350 G01 X-8.4797 Y-46.7183 Z24.9995 C0.0000 B0.0000 F1500
N360 G01 X-7.1865 Y-48.6649 Z24.9995 C0.0000 B0.0000 F1500
N370 G01 X-5.1870 Y-47.5105 Z24.9995 C0.0000 B0.0000 F1500
N380 G01 X-3.1876 Y-46.3561 Z24.9995 C0.0000 B0.0000 F1500
N390 G01 X-1.1882 Y-45.2017 Z24.9995 C0.0000 B0.0000 F1500
N400 G01 X0.8113 Y-44.0473 Z24.9995 C0.0000 B0.0000 F1500
N410 G01 X2.8107 Y-42.8929 Z24.9995 C0.0000 B0.0000 F1500
N420 G01 X4.8102 Y-41.7385 Z24.9995 C0.0000 B0.0000 F1500
N430 G01 X6.8096 Y-40.5841 Z24.9995 C0.0000 B0.0000 F1500
141 URScript
myToolPathFile.nc Module processpath
142 URScript
myToolPathFile.nc Module processpath
143 URScript
myToolPathFile.nc Module processpath
144 URScript
myToolPathFile.nc Module processpath
145 URScript
myToolPathFile.nc Module processpath
146 URScript
myToolPathFile.nc Module processpath
147 URScript
myToolPathFile.nc Module processpath
148 URScript
INDEX INDEX
Index
interfaces (module), 82–120
interfaces.enable_external_ft_sensor (function), 84
interfaces.ft_rtde_input_enable (function), 84
interfaces.get_analog_in (function), 85
interfaces.get_analog_out (function), 86
interfaces.get_configurable_digital_in (function), 86
interfaces.get_configurable_digital_out (function), 87
interfaces.get_digital_in (function), 87
interfaces.get_digital_out (function), 88
interfaces.get_flag (function), 88
interfaces.get_standard_analog_in (function), 89
interfaces.get_standard_analog_out (function), 89
interfaces.get_standard_digital_in (function), 89
interfaces.get_standard_digital_out (function), 90
interfaces.get_tool_analog_in (function), 90
interfaces.get_tool_digital_in (function), 91
interfaces.get_tool_digital_out (function), 91
interfaces.get_tool_digital_output_mode (function), 92
interfaces.get_tool_output_mode (function), 92
interfaces.modbus_add_signal (function), 92
interfaces.modbus_delete_signal (function), 93
interfaces.modbus_get_signal_status (function), 94
interfaces.modbus_send_custom_command (function), 94
interfaces.modbus_set_digital_input_action (function), 95
interfaces.modbus_set_output_register (function), 96
interfaces.modbus_set_output_signal (function), 96
interfaces.modbus_set_signal_update_frequency (function), 97
interfaces.read_input_boolean_register (function), 97
interfaces.read_input_float_register (function), 98
interfaces.read_input_integer_register (function), 98
interfaces.read_output_boolean_register (function), 99
interfaces.read_output_float_register (function), 99
interfaces.read_output_integer_register (function), 100
interfaces.read_port_bit (function), 100
interfaces.read_port_register (function), 101
interfaces.rpc_factory (function), 101
interfaces.rtde_set_watchdog (function), 102
interfaces.set_analog_inputrange (function), 103
interfaces.set_analog_out (function), 104
interfaces.set_configurable_digital_out (function), 104
interfaces.set_digital_out (function), 105
interfaces.set_flag (function), 105
interfaces.set_standard_analog_out (function), 105
interfaces.set_standard_digital_out (function), 106
interfaces.set_tool_communication (function), 106
interfaces.set_tool_digital_out (function), 107
interfaces.set_tool_digital_output_mode (function), 108
149 URScript
INDEX INDEX
150 URScript
INDEX INDEX
internals.popup (function), 53
internals.powerdown (function), 54
internals.set_gravity (function), 54
internals.set_payload (function), 54
internals.set_payload_cog (function), 55
internals.set_payload_mass (function), 55
internals.set_tcp (function), 56
internals.sleep (function), 56
internals.str_at (function), 56
internals.str_cat (function), 57
internals.str_empty (function), 58
internals.str_find (function), 59
internals.str_len (function), 59
internals.str_sub (function), 60
internals.sync (function), 61
internals.textmsg (function), 61
internals.to_num (function), 62
internals.to_str (function), 63
internals.tool_contact (function), 64
internals.tool_contact_examples (function), 64
ioconfiguration (module), 120–132
ioconfiguration.modbus_set_runstate_dependent_choice (function), 121
ioconfiguration.set_analog_outputdomain (function), 121
ioconfiguration.set_configurable_digital_input_action (function), 122
ioconfiguration.set_gp_boolean_input_action (function), 122
ioconfiguration.set_input_actions_to_default (function), 123
ioconfiguration.set_runstate_configurable_digital_output_to_value (function), 123
ioconfiguration.set_runstate_gp_boolean_output_to_value (function), 124
ioconfiguration.set_runstate_gp_float_output_to_value (function), 125
ioconfiguration.set_runstate_gp_integer_output_to_value (function), 126
ioconfiguration.set_runstate_standard_analog_output_to_value (function), 127
ioconfiguration.set_runstate_standard_digital_output_to_value (function), 128
ioconfiguration.set_runstate_tool_digital_output_to_value (function), 129
ioconfiguration.set_standard_analog_input_domain (function), 130
ioconfiguration.set_standard_digital_input_action (function), 130
ioconfiguration.set_tool_analog_input_domain (function), 131
ioconfiguration.set_tool_digital_input_action (function), 131
151 URScript
INDEX INDEX
motion.force_mode (function), 21
motion.force_mode_example (function), 22
motion.force_mode_set_damping (function), 23
motion.force_mode_set_gain_scaling (function), 23
motion.freedrive_mode (function), 24
motion.get_conveyor_tick_count (function), 24
motion.get_target_tcp_pose_along_path (function), 24
motion.get_target_tcp_speed_along_path (function), 24
motion.movec (function), 25
motion.movej (function), 26
motion.movel (function), 27
motion.movep (function), 28
motion.path_offset_disable (function), 29
motion.path_offset_enable (function), 29
motion.path_offset_get (function), 30
motion.path_offset_set (function), 30
motion.path_offset_set_alpha_filter (function), 31
motion.path_offset_set_max_offset (function), 32
motion.pause_on_error_code (function), 32
motion.position_deviation_warning (function), 33
motion.reset_revolution_counter (function), 34
motion.screw_driving (function), 35
motion.servoc (function), 36
motion.servoj (function), 37
motion.set_conveyor_tick_count (function), 38
motion.set_pos (function), 39
motion.set_safety_mode_transition_hardness (function), 40
motion.speedj (function), 40
motion.speedl (function), 40
motion.stop_conveyor_tracking (function), 41
motion.stopj (function), 41
motion.stopl (function), 42
motion.teach_mode (function), 42
motion.track_conveyor_circular (function), 42
motion.track_conveyor_linear (function), 43
152 URScript
INDEX INDEX
urmath.atan (function), 66
urmath.atan2 (function), 67
urmath.binary_list_to_integer (function), 67
urmath.ceil (function), 68
urmath.cos (function), 68
urmath.d2r (function), 69
urmath.floor (function), 69
urmath.get_list_length (function), 69
urmath.integer_to_binary_list (function), 70
urmath.interpolate_pose (function), 70
urmath.inv (function), 71
urmath.length (function), 71
urmath.log (function), 72
urmath.norm (function), 72
urmath.normalize (function), 73
urmath.point_dist (function), 73
urmath.pose_add (function), 74
urmath.pose_dist (function), 74
urmath.pose_inv (function), 75
urmath.pose_sub (function), 75
urmath.pose_trans (function), 76
urmath.pow (function), 77
urmath.r2d (function), 78
urmath.random (function), 78
urmath.rotvec2rpy (function), 78
urmath.rpy2rotvec (function), 79
urmath.sin (function), 80
urmath.size (function), 80
urmath.sqrt (function), 81
urmath.tan (function), 81
urmath.transpose (function), 81
urmath.wrench_trans (function), 82
153 URScript