URScript Programming Guide
URScript Programming Guide
PolyScope X
15.11. end_teach_mode() 32
15.12. force_mode(task_frame, selection_vector, wrench, type, limits) 32
15.13. force_mode_example() 33
15.14. force_mode_get_damping() 33
15.15. force_mode_get_gain_scaling() 33
15.16. force_mode_set_damping(damping) 34
15.17. force_mode_set_gain_scaling(scaling) 34
15.18. freedrive_mode (freeAxes=[1, 1, 1, 1, 1, 1], feature=p[0, 0, 0, 0, 0, 0]) 34
15.19. freedrive_mode_no_incorrect_payload_check() 35
15.20. get_conveyor_tick_count() 35
15.21. get_freedrive_status() 36
15.22. get_target_tcp_pose_along_path() 36
15.23. get_target_tcp_speed_along_path() 36
15.24. jerk_gain_scaling_get() 36
15.25. jerk_gain_scaling_set() 37
15.26. motion_version_get() 38
15.27. motion_version_set(version) 38
15.28. movec(pose_via, pose_to, a=1.2, v=0.25, r =0, mode=0) 39
15.29. movej 40
15.30. movel 41
15.31. movep(pose, a=1.2, v=0.25, r=0) 41
15.32. optimovej(goal, a=0.3, v=0.3, r=0) 42
15.33. optimovel(goal, a=0.3, v=0.3, r=0) 43
15.34. path_offset_disable(a=20) 44
15.35. path_offset_enable() 44
15.36. path_offset_get(type) 45
16.29. get_target_tcp_pose() 65
16.30. get_target_tcp_speed() 65
16.31. get_target_waypoint() 66
16.32. get_tcp_force() 66
16.33. get_tcp_offset() 67
16.34. get_tool_accelerometer_reading() 67
16.35. get_tool_current() 67
16.36. get_tool_temp() 67
16.37. high_holding_torque_disable() 68
16.38. high_holding_torque_enable() 68
16.39. is_steady() 68
16.40. is_within_safety_limits(position, qNear=current joint configuration) 69
16.41. popup(s, title=’Popup’, warning=False, error=False, blocking=False) 69
16.42. powerdown() 70
16.43. protective_stop() 70
16.44. set_base_acceleration(a) 70
16.45. set_baselight_off() 71
16.46. set_baselight_iec() 71
16.47. set_baselight_solid(r,g,b) 71
16.48. set_gravity(d) 71
16.49. set_payload(m, cog) 72
16.50. set_payload_cog(CoG) 73
16.51. set_payload_mass(m) 73
16.52. set_target_payload(m, cog, inertia=[0, 0, 0, 0, 0, 0], transition_time=0) 73
16.53. set_tcp(pose, tcp_name="") 74
1. Introduction
The Universal Robot can be controlled at two levels:
• The PolyScope or the Graphical User Interface Level
• 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.
2. Connecting to URControl
URControl is the low-level robot controller running on the Embedded PC in the Control Box cabinet. 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-<serial number> (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"
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
Important:
It is recommended to always read data from the socket. At least 79 bytes have to be read from socket before
closing to ensure that underlying TCP protocol closes socket orderly. Otherwise data sent from client may be
discarded before script is executed.
It is especially important in cases when socket is opened just to send single script, and closed immediately.
It is recommended to keep sockets open instead of opening end closing for each and every request.
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 that may appear to operate on characters (e.g. str_len), actually
operates on bytes and the result may not correspond to the expected one in case of string containing
sequences of multi-byte or variable-length characters. Refer to the description of the single function for more
details.
The struct function takes one or more named arguments, and each argument name becomes a member in the
struct. All values must be initialized by value, and the type of the value cannot be changed subsequently.
Create a struct:
myStruct = struct(identifier1 = 1, identifier2 = 2, myMember = "Hello structs",
listMember = [1,2,3])
Reassign a member:
[Link] = "Goodbye structs"
Use a member:
myVar = [Link]
Use a nested list:
myListElement = [Link][0]
Use the second member by index (identifier2):
myVar = myStruct[1]
A nested struct, stored by value:
myStruct = struct(myStructMember = struct(myMember = "Hi nested struct") )
Conversion of a struct to a list, if all the struct members are of same type and if the list has the same type.
Value of myList will be [1.1, 2.2, 3.3, 4.4].
Structs can be passed to and returned from function. In this example we create a new struct extended with a
boolean member.
struct_local.m3 = struct_arg.m3
struct_local.extra_member = True
return struct_local
end
new_extended_struct = ExtendStructWithBoolMember(struct_1)
4.2. List
A list is a set of variables with the same type aggregated into a single object.
A list object in URScript has two attributes: length and capacity. The length indicates how many elements the
list currently holding. The capacity tells how many elements the list can hold maximum.
Once declared, the capacity of the list cannot be changed.
Fixed length lists can be created with square bracket operator:
aa = [11, 22, 33, 44, 55, 66, 77]
List can be assigned only to existing list of greater or equal capacity to the length of source list:
List can hold structs (aka complex data types). All structs in the list have to be exactly of the same type:
If list is returned from a function or list method, then the target list have to be earlier initialized with enough
capacity.
List of lists is not supported as this is how matrices are implemented in URScript.
[Link](88) # add element to the end of the list, length increases, exception
thrown if capacity exceeded
capacity()
Returns the maximum capacity of the list (>=length).
Example: merge list 2 to list 1 until list 1 is full. result: [-1, -1, -1, -1, -1, 6, 7, 8, 9, 10]
clear()
Clear the list by setting length to 0.
list_1.clear() # list_1 will be []
excess_capacity()
Returns the unused capacity (= capacity-length).
Example: add element if the list has free space. result: [9,9,9,9,9,1,2,3,4,5]; popup "no more space"
l1 = make_list(5, 9, 10)
l2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
idx = 0
while(idx < [Link]()):
if(l1.excess_capacity() > 0):
[Link](l2[idx])
else:
popup("no more space")
break
end
idx = idx + 1
end
extend(list of elements)
Adds all elements from the parameter list at the end. Raises an error if at capacity. The list in the input must be
of the same type as the list.
Example: add list 2 to list 1. result = [0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
l1 = make_list(2, 0, 100)
l2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
if l1.excess_capacity() >= [Link]():
[Link](l2)
end
length()
Returns the current length of the list.
Example: update elements of a list in a loop
l1 = [1, 2, 3, 4, 5, 6]
idx = 0
while (idx < [Link]()):
l1[idx] = 10 + idx
idx = idx + 1
end
pop()
Removes the last element from the list.
remove(index)
Removes the element at a given index.
Example: remove even numbers from a collection.
end
to_string()
Returns a string representation of the list. has ...] if out of space.
to_string()
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
get_row(index)
Returns the row at the index by value.
shape()
Returns the number of rows and columns in the matrix.
to_string()
Returns a string representation of the list. has ...] if out of space.
matrix = [[1,2],[3,4],[5,6]]
b = matrix[0,0]
matrix[2,1] = 20
Matrix and array can be manipulated by matrix-matrix, array-array,matrix-array,matrixscalar and array-scalar
sub2 = 5 - [[10,20],[30,40]]
mod1 = [11,22,33] % 5
mod2 = 121 % [[10,20],[30,40]]
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
6. Flow of Control
The flow of control of a program is changed by if-statements:
if a > 3:
a = a + 1
elif b < 7:
b = b * a
else:
a = a + b
end
and while-loops:
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.
7. Function
A function is declared as follows:
return a+b
end
def add(a=0,b=0):
return a+b
end
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
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
if (! [Link]("RGB")):
[Link]()
[Link]()
...
First the rpc_factory (see Interfaces section) creates an XMLRPC connection to the specified
remote server. The camera variable is the handle for the remote function calls. You must initialize the camera
and therefore call [Link]("RGB").
The function returns a boolean value to indicate if the request was successful. In order to find a target position,
the camera first takes a picture, hence the [Link]() call. Once the snapshot is taken, the
image analysis in the remote site calculates the location of the target. Then the program asks for the exact
target location with the function call target = [Link](). On return the target
variable is as- signed the result. The [Link]("RGB"), takeSnapshot() and
getTarget() functions are the responsibility of the RPC server.
The closeXMLRPCClientConnection is closing the XMLRPC connection created by the rpc_factory. It
is recommended to close the connection periodically, or when it's not used for a longer time. Some server
implementations by default have a limit of rpc requests or inactivity watchdog timers.
NOTE: The RPC handle does not automatically close the connecetion.
The technical support website: [Link] contains more examples of XMLRPC
servers.
8.1. closeXMLRPCClientConnection()
9. Scoping rules
A URScript program is declared as a function without parameters:
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.
• global qualifier forces a variable declared inside a function, to be globally accessible.
For each variable the controller determines the scope binding, i.e. whether the variable 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.
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
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():
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 function 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
def myProg():
a = 0
def myFun():
a = 1
...
end
...
end
10. Threads
Threads are supported by a number of special commands.
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.
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
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:
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.
To kill a running thread, use the kill command:
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
return False
end
1Before the start of each frame the threads are sorted, such that the thread with the largest remaining time
slice is to be scheduled first.
2If this expectation is not met, the program is stopped.
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 control the robot, otherwise an exception like "Lost communication with Controller" can be
raised with a consequent protective stop.
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
$ 2 "var_1= True"
sec secondaryProgram():
set_digital_out(1,True)
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
end
the program until the end of program execution, thus they can be called/accessed in subsequent calls to
interpreter_mode().
Example statement:
• interpreter_mode()
• Starts interpreter mode with default behavior.
• interpreter_mode(clearQueueOnEnter = False)
• Starts interpreter mode by interpreting and executing the statements already in the
interpreter queue.
Important: It is the programmers responsibility to implement the synchronization necessary to ensure that
the program is in the wanted interpreter mode, and that it is ready to receive the statements. It is
insufficient to detect if interpreter mode is running, as multiple interpreter mode can exist in the same
program.
Ends the interpreter mode, and causes the interpreter_mode() function to return. This function can
be compiled into the program by sending it to the interpreter socket(30020) as any other statement, or can
be called from anywhere else in the program.
By default everything interpreted will be cleared when ending, though the state of the robot, the
modifications to local variables from the enclosing scope, and the global variables will remain affected by
any changes made. The interpreter thread will be idle after this call.
Clears all interpreted statements, objects, functions, threads, etc. generated in the current interpreter
mode. Threads started in current interpreter session will be stopped, and deleted. Variables defined
outside of the current interpreter mode will not be affected by a call to this function.
Only statements interpreted before the clear_interpreter() function will be cleared. Statements
sent after clear_interpreter() will be queued. When cleaning is done, any statements queued are
interpreted and responded to. Note that commands such as abort, skipbuffer and state commands are
executed as soon as they are received.
Note: This function can only be called from an interpreter mode.
Tip: To expedite the clean, skipbuffer can be sent right before clear_interpreter().
The interpreter mode furthermore supports the opportunity to skip already sent but not executed
statements. The interpreter thread will then (after finishing the currently executing statement) skip all
received but not executed statements.
After the skip, the interpreter thread will idle until new statements are received. skipbuffer will only skip
already received statements, new statements can therefore be send right away.
Return value should be ignored
Note: skipbuffer must be sent in a line by itself, and thus cannot be combined with other commands or
statements.
Note that these ids start at 1 and might wrap around to 1 in very long running programs. A 0 represents an
uninitialized or undefined value, such as the last executed statement if none has been executed yet.
statelastexecuted
Replies with the largest id of a statement that has started being executed.
state: <id>: statelastexecuted
statelastinterpreted
Replies with the latest interpreted id, i.e. the highest number of interpreted statement so far.
state: <id>: statelastinterpreted
statelastcleared
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
Replies with the id for the latest statement to be cleared from the interpreter mode. This clear can happen
when ending interpreter mode, or by calls to clear_interpreter()
state: <id>: statelastcleared
stateunexecuted
Replies with the number of non executed statements, i.e. the number of statements that would have be
skipped if skipbuffer was called instead.
state: <#unexecuted>: stateunexecuted
All interpreter mode log files are included in failure report files.
14.2. Availablity
The motion version script API is accessible starting with PolyScope 5.22. On some platforms, motion version 1
is not available, details can be found in the table below.
When trying to set a motion version that is unavailable, PolyScope will ignore the setting and log a warning.
Available Motion
PolyScope Version Robot
Versions
PolyScope 5.22 and above eSeries, UR20, UR30 1, 2
PolyScopeX 10.9 and above Any 2
Any UR15 and newer 2
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
15.1. conveyor_pulse_decode(type, A, B)
• 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
Sets the target torque for all robot joints at 500Hz. This function must be called continuously at each robot
time step; otherwise, the robot will return to position control mode. The function always compensates for
gravity, meaning that the provided target torque should not include gravity compensation. Friction
compensation is enabled by default, but can be disabled by setting friction_comp=False.
Parameters
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
torques: List of target joint torques (Nm) to be commanded to the robot joints (length 6).
friction_comp: (Optional) Enable internal friction compensation. Default is True.
Notes:
• This function is an advanced low-level function, as it bypasses many of the compliance features,
which means it needs to be used with care.
• You are responsible for keeping the robot within safety limits. If the robot violates these limits, it will
result in a violation and the robot will stop.
• It uses one timestep regardless of speed scaling, similar to sync().
• If not called every timestep, the robot will revert to position control mode.
• get_target_joint_accelerations() will return zeros when using direct_torque(), as
there is no commanded target acceleration in this mode. Please use get_actual_joint_
accelerations() instead, as these values are derived from the encoders.
• When returning to position control mode, the robot arm needs to receive a command indicating how
to continue the movement or stop. This can be done, for example, by using speedj() to continue
moving or stopj() to make it stop.
• It is recommended to run your control loop in URScript and receive targets or gains via RTDE,
sockets, or ROS 2 (PolyScopeX only) to avoid communication delays.
Example command:
This example shows how to call direct_torque() and thereby go into torque control and back to
position control mode and to a standstill after 10 seconds.
To disable friction compensation:
timer = 0.0
direct_torque(tau)
end
stopj(10)
direct_torque([0,0,0,0,0,0], friction_comp=False)
15.3. encoder_enable_pulse_decode(encoder_index,
decoder_type, A, B)
15.4. 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)
This example shows how to set up encoder 0 to expect counts in the range of [-2147483648 ;
2147483647].
Parameters
encoder_index:
Index of the encoder to define. Must be either 0 or 1.
range_id:
decoder_index: Range of the encoder
(integer). Needed to handle wrapping nicely.
0 is a 32 bit signed encoder, range [-2147483648 ; 2147483647]
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]
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
Tells the robot controller the tick count of the encoder. This function is useful for absolute encoders (e.g.
MODBUS).
>>> encoder_set_tick_count(0, 1234)
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.
15.7. encoder_unwind_delta_tick_count(encoder_index,
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.
Consider the following situation: You are using an encoder with a UINT16 range, meaning the tick count is
always in the [0; 65536[ range. When the encoder is ticking, it may cross either end of the range, which
causes the tick count to wrap around to the other end. During your program, the current tick count is
assigned to a variable (start:=encoder_get_tick_count(...)). Later, the tick count is assigned to another
variable (current:=encoder_get_tick_count(...)). To calculate the distance the conveyor has traveled
between the two sample points, the two tick counts are subtracted from each other.
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).
Conveyor tracking applications rely on these kinds of encoder calculations. Unless special care is taken to
compensate the encoder wrapping around, the application will not be robust and may produce weird
behaviors (e.g., singularities or exceeded speed limits) which are difficult to explain and to reproduce.
This heuristic function checks that a given delta_tick_count value is reasonable. If the encoder wrapped
around the end of the range, it compensates (i.e., unwinds) and returns the adjusted result. If a delta_tick_
count is larger than half the range of the encoder, wrapping is assumed and is compensated. As a
consequence, this function only works when the range of the encoder is explicitly known, and therefore the
designated encoder must be enabled. If not, this function will always return nil.
Parameters
encoder_index: Index of the encoder to query. Must be either 0 or 1.
delta_tick_count: The delta (difference between two) tick count to unwind (float)
Return Value
The unwound delta_tick_count (float)
15.8. end_force_mode()
15.9. end_freedrive_mode()
Set robot back in normal position control mode after freedrive mode.
15.10. end_screw_driving()
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
15.11. end_teach_mode()
Deprecated:
Set robot back in normal position control mode after teach mode.
This function is replaced by end_freedrive_mode and it should therefore not be used moving forward.
An integer [1;3] specifying how the robot interprets the force frame.
1: The force frame is transformed in a way such that its y-axis is aligned with a vector pointing from the
robot tcp towards the origin of the force frame.
2: The force frame is not transformed.
3: The force frame is transformed in a way such that its x-axis is the projection of the robot tcp velocity
vector onto the x-y plane of the force frame.
limits: (Float) 6d vector. For compliant axes, these values are the maximum allowed tcp speed
along/about the axis. For non-compliant axes, these values are the maximum allowed deviation
along/about an axis between the actual tcp position and the one set by the program.
Note: Avoid movements parallel to compliant axes and high deceleration (consider inserting a short sleep
command of at least 0.02s) just before entering force mode. Avoid high acceleration in force mode as this
decreases the force control accuracy.
15.13. force_mode_example()
15.14. force_mode_get_damping()
15.15. force_mode_get_gain_scaling()
15.16. force_mode_set_damping(damping)
15.17. force_mode_set_gain_scaling(scaling)
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
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.
The default parameters enables the robot to move freely in all directions. It is possible to enable
Constrained Freedrive by providing user specific parameters.
Parameters
freeAxes: A 6 dimensional vector that contains 0’s and 1’s, these indicates in which axes movement is
allowed. The first three values represents the cartesian directions along x, y, z, and the last three defines
the rotation axis, rx, ry, rz. All relative to the selected feature.
feature: A pose vector that defines a freedrive frame relative to the base frame. For base and tool
reference frames predefined constants "base", and "tool" can be used in place of pose vectors.
Example commands:
• freedrive_mode()
• Robot can move freely in all directions.
• freedrive_mode(freeAxes=[1,0,0,0,0,0], feature=p[0.1,0,0,0,0.785])
• Example Parameters:
• freeAxes = [1,0,0,0,0,0] -> The robot is compliant in the x direction relative to
the feature.
• feature = p[0.1,0,0,0,0.785] -> This feature is offset from the base frame with
100 mm in the x direction and rotated 45 degrees in the rz direction.
• freedrive_mode(freeAxes=[0,1,0,0,0,0], feature="tool")
• Example Parameters:
• freeAxes = [0,1,0,0,0,0] -> The robot is compliant in the y direction relative to
the "tool" feature.
• feature = "tool" -> The "tool" feature is located in the active TCP.
High acceleration and deceleration can both decrease the control accuracy and cause protective stops.
15.19. freedrive_mode_no_incorrect_payload_check()
This method, like teach_mode() and freedrive_mode(), changes the robot mode to teach mode, but this
function does not check for an incorrect payload during the initial state change, nor if the payload is
updated during freedrive. For this reason, it is exceedingly important for users to be certain the payload is
correct.
It is possible for the user to exit teach mode/freedrive in the usual manner, using: end_teach_mode() or
end_freedrive_mode()
15.20. 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.
15.21. get_freedrive_status()
15.22. get_target_tcp_pose_along_path()
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
Query the target TCP pose as given by the trajectory being followed.
This script function is useful in conjunction with conveyor tracking to know what the target pose of the TCP
would be if no offset was applied.
Return Value
Target TCP pose
15.23. get_target_tcp_speed_along_path()
Query the target TCP speed as given by the trajectory being followed.
This script function is useful in conjunction with conveyor tracking to know what the target speed of the
TCP would be if no offset was applied.
Return Value
Target TCP speed as a vector
15.24. jerk_gain_scaling_get()
Return value
double: Jerk gain scaling
See also:
15.25 jerk_gain_scaling_set() on the facing page
15.25. jerk_gain_scaling_set()
The following motion profiles have a jerk limited acceleration and deceleration phase:
• movej[motionversion=>2] and optimovej
• movel[motionversion=>2] and optimovel
The value is stored until this function is called again or until reboot. Add this to the beginning of your
program to ensure it is called before the first move (otherwise default value will be used).
See also:
15.24 jerk_gain_scaling_get() on page 36
15.26. motion_version_get()
15.27. motion_version_set(version)
Set which Motion Version will be used for movej and movel motion planning.
This command overrides the PolyScope GUI "Installation → Motion → Motion Version → Motion Version
2" setting.
Parameters:
version: 1 or 2. See Motion Version for details.
Example command: motion_version_set(2)
• Example Parameters:
version = 2 → movej and movel perform as motion version 2
NOTICE
Motion version 1 has identical motion profiles to prior versions of PolyScope
NOTICE
New robot models as well as PolyScopeX only support motion version 2
• 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
15.29. movej
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
15.30. movel
(pose, a=1.2, v=0.25, t=0, r=0)
Move Process
Blend circular (in tool-space) and move linear (in tool-space) to position. Accelerates to and moves with
constant tool speed v.
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]
r: blend radius [m]
Example command: movep(pose, a=1.2, v=0.25, 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
• r = 0 -> the blend radius is zero meters.
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
a (optional): Joint acceleration as a fraction of what the joints are able to perform - a∈ (0.0,1.0]
v (optional): Joint speed as a fraction of how fast the joints can move during the motion - v∈ (0.0,1.0]
r (optional): Blend radius [m]
If a blend radius is set, the robot arm trajectory will be modified within the blend radius of the destination
position.
Example command: optimovej([0, 1.57, -1.57, 3.14, -1.57, 1.57], a=0.4, v=0.6,
r=0.0)
• Example Parameters:
• goal = [0, 1.57, -1.57, 3.14, -1.57, 1.57] → joint positions with base at 0 deg rotation,
shoulder at 90 deg rotation, elbow at -90 deg rotation, wrist 1 at 180 deg rotation, wrist 2 at -
90 deg rotation, wrist 3 at 90 deg rotation.
• a = 0.4 → acceleration at either end of the motion is 40% of the acceleration the robot is
capable of producing in the specific joint configuration.
• v = 0.6 → velocity during motion cruise phase is 60% of the velocity the joints can move at.
• r = 0.0 → the blend radius is zero meters, meaning the robot will stop at the waypoint.
Notes:
• The absolute speed and acceleration of the robot depends on the joint configuration during the
move. A value of e.g. 0.4 might therefore produce a faster speed/acceleration in one area of the
robot's workspace and a slower speed/acceleration in another area of the robot's workspace.
Values of 1.0 will always give the highest speed and acceleration that are possible for a given robot
path.
• To avoid high accelerations that can cause dropped items in e.g. suction cup grippers, consider
a (optional): Tool acceleration as a fraction of what the robot is able to perform - a∈ (0.0,1.0]
v (optional): Tool speed as a fraction of the maximum Cartesian velocity the robot can travel at during the
trajectory, given the maximum joint speeds - v∈ (0.0,1.0]
r (optional): Blend radius [m]
If a blend radius is set, the robot arm trajectory will be modified within the blend radius of the destination
position.
Example command: optimovel(pose, a=0.4, v=0.6, r=0.0)
• Example Parameters:
• goal = 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 deg, ry = 0 deg, rz = 180 deg.
• a = 0.4 -> acceleration at either end of the motion is 40% of the acceleration the robot is
capable of producing in the specific joint configuration.
• v = 0.6 -> velocity during motion cruise phase is 60% of the velocity the joints can move at.
• r = 0.0 -> the blend radius is zero meters, meaning the robot will stop at the waypoint.
Notes:
• The absolute speed and acceleration of the robot depends on the joint configuration during the
move. A value of e.g. 0.4 might therefore produce a faster speed/acceleration in one area of the
robot's workspace and a slower speed/acceleration in another area of the robot's workspace
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
(typically close to singularities). Values of 1.0 will always give the highest speed and acceleration
that are possible for a given robot path.
• To avoid high accelerations that can cause dropped items in e.g. suction cup grippers, consider
using the command tool_wrench_limit_set() to limit the acceleration of the items held by the
gripper.
• It is possible to blend into this move type from movej/l and optimovej/l. When coming from other
movement types the robot should be at standstill when starting the move.
15.34. 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.
Use the script function path_offset_enable to enable path offsetting
Parameters
a: joint acceleration [rad/s^2] (optional)
15.35. path_offset_enable()
Enabling path offsetting doesn’t cancel the effects of previous calls to the script functions path_offset_
set_max_offset and path_offset_set_alpha_filter. Path offset configuration will persist
through cycles of enable and disable.
Using Path offset at the same time as Conveyor Tracking and/or Force can lead to program conflict. Do
not use this function togther with Conveyor Tracking and/or Force.
15.36. path_offset_get(type)
path_offset_set(offset, type)
Specify the Cartesian path offset to be applied.
Use the script function path_offset_enable beforehand to enable offsetting. The calculated offset is
applied during each cycle at 500Hz.
Discontinuous or jerky offsets are likely to cause protective stops. If offsets are not smooth the function
path_offset_set_alpha_filter can be used to engage a simple filter.
The following example uses a harmonic wave (cosine) to offset the position of the TCP along the Z-axis of
the robot base:
>>> thread OffsetThread():
>>> while(True):
>>> # 2Hz cosine wave with an amplitude of 5mm
>>> global x = 0.005*(cos(p) - 1)
>>> global p = p + 4*3.14159/500
>>> path_offset_set([0,0,x,0,0,0], 1)
>>> sync()
>>> end
>>> end
Parameters
offset: Pose specifying the translational and rotational offset.
15.38. path_offset_set_alpha_filter(alpha)
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
Engage offset filtering using a simple alpha filter (EWMA) and set the filter coefficient.
When applying an offset, it must have a smooth velocity profile in order for the robot to be able to follow the
offset trajectory. This can potentially be cumbersome to obtain, not least as offset application starts,
unless filtering is applied.
The alpha filter is a very simple 1st order IIR filter using a weighted sum of the commanded offset and the
previously applied offset: filtered_offset= alpha*offset+ (1-alpha)*filtered_offset.
See more details and examples in the UR Support Site: Modify Robot Trajectory
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.
The necessary alpha value will depend on robot calibration, robot mounting, payload mass, payload
center of gravity, TCP offset, robot position in workspace, path offset rate of change and underlying
motion.
rotLimit: The maximum allowed rotational offset around any axis in radians.
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, 3)
In the above example, the robot will pause on errors with code 173 if its argument equals 3 (corresponding
to ’C173A3’ in the log).
>>> pause_on_error_code(173)
15.41. 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.
Reset the revolution counter, if no offset is specified. This is applied on joints which safety limits are set to
"Unlimited" and are only applied when new safety settings are applied with limitted joint angles.
>>> reset_revolution_counter()
Parameters
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
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.
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
• lookahead time = .1 time [S], range [0.03,0.2] smoothens the trajectory with this lookahead
time
• gain = 300 proportional gain for following target position, range [100,2000]
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:
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
15.46. set_pos(q)
• 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
15.47. 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.
Joint speed
Accelerate linearly in joint space and continue with constant joint speed. The time t is optional; if provided
the function will return after time t, regardless of the target speed has been reached. If the time t is not
provided, the function will return when the target speed is reached.
Parameters
qd: joint speeds [rad/s]
a: joint acceleration [rad/s^2] (of leading axis)
t: time [s] before the function returns (optional)
Example command: speedj([0.2,0.3,0.1,0.05,0,0], 0.5, 0.5)
• Example Parameters:
• qd -> Joint speeds of: base=0.2 rad/s, shoulder=0.3 rad/s, elbow=0.1 rad/s, wrist1=0.05
rad/s, wrist2 and wrist3=0 rad/s
• a = 0.5 rad/s^2 -> acceleration of the leading axis (shoulder in this case)
• t = 0.5 s -> time before the function returns
Accelerate linearly in Cartesian space and continue with constant tool speed. The time t is optional; if
provided the function will return after time t, regardless of the target speed has been reached. If the time t
is not provided, the function will return when the target speed is reached.
Parameters
xd: tool speed [m/s] (spatial vector)
a: tool positional acceleration [m/s^2]
t: time [s] before function returns (optional)
aRot: tool rotational acceleration [rad/s^2] (optional). If not defined, position acceleration value in
[rad/s^2] will be used
Example command: speedl([0.5,0.4,0,1.57,0,0], 0.5, 0.5)
• Example Parameters:
• xd -> Tool speeds of: x=500 mm/s, y=400 mm/s, rx=90 deg/s, ry and rz=0 deg/s
• a = 0.5 m/s^2 -> acceleration of the tool
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
15.50. stop_conveyor_tracking(a=20)
15.51. stopj(a)
Limit the wrench (forces and torques) caused by motion of the robot in a frame given relative to the tool
flange. The wrench is limited in normal and reduced mode operation, as well as during protective stops,
safeguard stops, 3PE stops and emergency stops. For this reason, it can affect robot motion speed to
ensure adherence to safety limits. Usage can help prevent dropping items by limiting accelerations as well
as reducing wrench applied to the attached tool.
This limitation does not affect the forces and torques that can be applied in force control.
Parameters:
frame_offset: Pose specifying frame relative to the tool flange similarly to how the TCP offset is
specified. The first three coordinates specify translational offset along the x- y- and z-axis in meters. The
last three specify the rotational offset using the axis-angle representation in radians.
Fx (optional): Float, setting maximum acceleration force along the X-axis in the specified frame.
Fy (optional): Float, setting maximum acceleration force along the Y-axis in the specified frame.
Fz (optional): Float, setting maximum acceleration force along the Z-axis in the specified frame.
Mx (optional): Float, setting maximum acceleration torque around the X-axis in the specified frame.
My (optional): Float, setting maximum acceleration torque around the Y-axis in the specified frame.
Mz (optional): Float, setting maximum acceleration torque around the Z-axis in the specified frame.
Any optional parameter not specified means the axis is only limited by standard robot limitations.
• frame_offset = p[0, 0, 0.1, 0, 0, 1.57] → limitation will be applied in a frame offset 10 cm in front of
the tool flange rotated by 90 degrees around the axis of displacement.
• Mx = 10 → acceleration torque will be limited to 10 Nm around the X-axis in the specified frame.
• My = 15 → acceleration torque will be limited to 15 Nm around the Y-axis in the specified frame.
NOTICE
The set limit is persisted until shutdown of the controller or until explicitly disabled by
executing tool_wrench_limit_disable().
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
15.54. tool_wrench_limit_disable()
15.55. teach_mode()
Deprecated:
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.
Deprecated:
This function is replaced by freedrive_mode and it should therefore not be used moving forward.
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:
• 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.
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
Return value:
struct[mass, cog]
mass is a double representing the weight of the payload in kg.
cog is a 3d vector representing the offset from the tool flange to the payload center of
gravity in tool frame in meters.
16.3. get_actual_joint_accelerations()
Returns the list of joint accelerations derived directly from the encoders.
Return Value
List of joint accelerations. Note: The output may be noisy.
16.4. get_actual_joint_positions()
16.5. get_actual_joint_positions_history(steps=0)
16.6. get_actual_joint_speeds()
Return Value
The current actual joint angular velocity vector in rad/s: [Base, Shoulder, Elbow, Wrist1, Wrist2, Wrist3]
16.7. get_actual_tcp_pose()
16.8. get_actual_tcp_speed()
16.9. get_actual_tool_flange_pose()
16.10. get_base_acceleration()
Returns the robot base acceleration vector (see set_base_acceleration) currently active in the controller
and SCB kinematics and dynamics models.
Return Value
User specified robot base acceleration vector in m/s^2 as a 3D vector ([float, float, float])
16.11. get_controller_temp()
Return Value
A temperature in degrees Celcius (float)
Returns the summed list of Coriolis and centrifugal joint torques for the robot at the specified joint positions
and velocities.
Parameters
q: (Optional) List of joint positions. If not specified, uses the current robot position.
qd: (Optional) List of joint velocities. If not specified, uses the current robot velocities.
Return Value
List of Coriolis and centrifugal joint torques.
16.13. 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.
16.14. get_gravity()
Returns the gravity acceleration vector (see set_gravity) currently active in the controller and SCB
kinematics and dynamics models.
Calculate the inverse kinematic transformation (tool space -> joint space). If qnear is defined, the solution
closest to qnear is returned.
Otherwise, the solution closest to the current joint positions is returned. If no tcp is provided the currently
active tcp of the controller is used.
Parameters
x: tool pose
qnear: list of joint positions (Optional)
maxPositionError: the maximum allowed position error (Optional)
maxOrientationError: the maximum allowed orientation error (Optional)
tcp: tcp offset pose (Optional)
Return Value
joint positions
Example command: get_inverse_kin(p[.1,.2,.2,0,3.14,0], [0.,3.14,1.57,.785,0,0])
• Example Parameters:
• x = p[.1,.2,.2,0,3.14,0] -> pose with position of x=100mm, y=200mm, z=200mm and rotation
vector of rx=0 deg., ry=180 deg, rz=0 deg.
• qnear = [0.,3.14,1.57,.785,0,0] -> solution should be near to joint angles of j0=0 deg, j1=180
Returns the Jacobian matrix for the robot at the specified joint positions and TCP offset.
Parameters
q: (Optional) List of joint space position. If not specified, uses the robot's current joint positions.
tcp: (Optional) Pose of the TCP offset. If not specified, uses the active TCP offset.
Return Value
The Jacobian matrix.
Returns the time derivative of the Jacobian matrix for the robot at the specified joint positions, joint
velocities, and TCP offset.
Parameters
q: (Optional) List of joint space position. If not specified, uses the robot's current joint positions.
qd: (Optional) List of joint space velocities. If not specified, uses the robot's current joint velocities.
tcp: (Optional) Pose of the TCP offset. If not specified, uses the active TCP offset.
Return Value
The time derivative of the Jacobian matrix.
16.19. get_joint_temp(j)
16.20. get_joint_torques()
Returns the mass (inertia) matrix of the robot at the specified joint positions. Optionally includes the inertia
of the motor side of the gear.
Parameters
q: (Optional) List of joint positions. If not specified, uses the current robot joint positions.
include_rotor_inertia: (Optional) If True, includes the inertia on the motor side of the gear.
Default is False.
Return Value
The mass matrix.
16.22. get_steptime()
16.23. get_target_joint_accelerations()
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
Returns the list of joint accelerations derived from the motion commands.
Return Value
List of joint accelerations.
Note: There is no commanded target acceleration when using direct_torque.
16.24. get_target_joint_positions()
Returns the desired angular positions that are sent to all the joints at each time step
The angular target positions are expressed in radians and returned as a vector of length 6. Note that the
output might differ from the output of get_actual_joint_positions(), especially during acceleration and
heavy loads.
Return Value
The current target joint angular position vector in rad: [Base, Shoulder, Elbow, Wrist1, Wrist2, Wrist3]
16.25. get_target_joint_speeds()
16.26. get_target_payload()
16.27. get_target_payload_cog()
16.28. get_target_payload_inertia()
16.29. get_target_tcp_pose()
16.30. get_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)
16.31. get_target_waypoint()
This method is useful for calculating relative movements where the previous move command uses blends.
Return Value
The desired waypoint TCP vector [X, Y, Z, Rx, Ry, Rz]
16.32. get_tcp_force()
end
def get_wrench_at_tcp():
return wrench_trans(get_tcp_offset(), get_wrench_at_tool_flange())
end
16.33. 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
16.35. get_tool_current()
16.36. get_tool_temp()
16.37. high_holding_torque_disable()
Disables automatically applying high hold torque when the robot is stationary, which is the default
behavior. The UR controller automatically applies high holding torque when the following is true:
• The program state is PROGRAM_STATE_RUNNING
• All actual joint movement <= 0.01 rad/s
• All target joint velocities == 0
Parameters:
None
Example command:
high_holding_torque_disable()
This function script disables the high holding torque behavior. Note that the default is restored to enabled
after restarting the controller.
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
See also:
high_holding_torque_enable()
Applications: Disable high holding torque if you want a stationary robot to issue a protective stop when
colling with an object. For example, if the robot is being transported on a linear rail or vertical lift. However,
if just the base of the robot collides with an object while moving, the protective stop may not be issued.
Adequate safety precautions should be put in place to guard against this situation.
16.38. high_holding_torque_enable()
Enables high hold torque when the robot is stationary. This function is used to reverse the behavior of the
high_holding_torque_disable() command.
Parameters:
None
Example command:
high_holding_torque_enable()
See also
high_holding_torque_disable()
16.39. is_steady()
The function will return true when the robot has been standing still with zero target velocity for 500ms
When the function returns true, the robot is able to adapt to large external forces and torques, e.g. from
screwdrivers, without issuing a protective stop.
Return Value
True when the robot able to adapt to external forces, false otherwise (bool)
Checks if the given pose or joint positions are reachable and within the currently active safety limits of the
robot.
This check considers:
• Joint position limits
Parameters
position: Pose or joint positions. When a pose is provided, it is recommended to also supply qNear to
ensure that the correct inverse kinematics solution is checked.
qNear: List of joint angles (optional). Only used for calculating inverse kinematics when position is a pose.
If not specified, the current joint positions are used.
Return Value
True if within limits, false otherwise (bool).
NOTICE
In order to simply check if a pose is physically reachable by the robot, use get_inverse_
kin_has_solution instead.
16.42. powerdown()
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
Shut down the robot, and power off the robot and controller.
16.43. protective_stop()
Trigger a protective stop, pausing the program and stopping motion on the planned trajectory.
Notes:
This function is not intended for use for simply pausing the running program (see Special keywords:
pause).
16.44. set_base_acceleration(a)
Sets the acceleration of the robot base. This function is used when the robot is attached to a moving base
such a linear rail or vertical lift. Specifying the base acceleration is used to prevent premature protective
stops by informing the control system that forces are being exerted on the robot through acceleration of
the base.
Parameters
a: the linear acceleration of the base in x, y, z directions
Example command:
set_base_acceleration([0.10 0.0 0.0])
Example Parameters:
a = [0.10 0 0] specifies acceleration in the linear X direction of 0.10 m/s²
16.45. set_baselight_off()
NOTICE
Only applies to UR Series
16.46. set_baselight_iec()
NOTICE
Only applies to UR Series
16.47. set_baselight_solid(r,g,b)
NOTICE
Only applies to UR Series
Set a color on the entire baselight ring as specified by the given RGB values in the range 0-255.
16.48. 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.
>>> set_gravity([0, 9.82*sin(theta), 9.82*cos(theta)])
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).
Parameters
m: mass in kilograms
cog: Center of Gravity, a vector [CoGx, CoGy, CoGz] specifying the displacement (in meters) from the
toolmount.
Deprecated: See set_target_payload to set mass, CoG and payload inertia matrix at the same time.
Set payload mass and center of gravity while resetting payload inertia matrix
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
Sets the mass and center of gravity (abbr. CoG) of the payload.
This function must be called, when the payload mass or mass CoG offset changes - i.e. when the robot
picks up or puts down a workpiece.
Note: The force torque measurements are automatically zeroed when setting the payload. That ensures
the readings are compensated for the payload. This is similar to the behavior of zero_ftsensor()
Warnings:
• This script is deprecated since SW 5.10.0 because of the risk of inconsistent payload parameters.
Use the set_target_payload instead to set mass, CoG and inertia matrix.
• Omitting the cog parameter is not recommended. The Tool Center Point (TCP) will be used if the
cog parameter is missing with the side effect that later calls to set_tcp will change also the CoG to
the new TCP. Use the set_payload_mass function to change only the mass or use the get_
target_payload_cog as second argument to not change the CoG.
• Using this script function to modify payload parameters will reset the payload inertia matrix.
Example command:
• set_payload(3., [0,0,.3])
• Example Parameters:
• m = 3 → mass is set to 3 kg payload
• cog = [0,0,.3] Center of Gravity is set to x=0 mm, y=0 mm, z=300 mm from the
center of the tool mount in tool coordinates
• set_payload(2.5, get_target_payload_cog())
• Example Parameters:
• m = 2.5 → mass is set to 2.5 kg payload
• cog = use the current COG setting
16.50. set_payload_cog(CoG)
Deprecated: See set_target_payload to set mass, CoG and payload inertia matrix at the same time.
Set the Center of Gravity (CoG) and reset payload inertia matrix
Warning: Using this script function to modify payload parameters will reset the payload inertia matrix.
Note: The force torque measurements are automatically zeroed when setting the payload. That ensures
the readings are compensated for the payload. This is similar to the behavior of zero_ftsensor()
16.51. set_payload_mass(m)
Parameters
Sets the mass, CoG (center of gravity), the inertia matrix of the active payload and the transition time for
applying new settings.
This function must be called when the payload mass, the mass displacement (CoG) or the inertia matrix
changes - (i.e. when the robot picks up or puts down a workpiece).
Parameters
m: mass in kilograms.
cog: Center of Gravity, a vector with three elements [CoGx, CoGy, CoGz] specifying the offset (in meters)
from the tool mount.
inertia: payload inertia matrix (in kg*m^2), as a vector with six elements [Ixx, Iyy, Izz, Ixy, Ixz, Iyz] with
origin in the CoG and the axes aligned with the tool flange axes.
• Setting a transition time larger than zero avoids the robot doing a small "jump" when payload
changes. This is useful when picking up or releasing heavy objects.
• The internal force/torque sensor in the robot tool is reset each time the payload is updated. This
means that the final reset will be performed at the end of the payload transition time. If the payload
is being accelerated at the time of the final reset, the force/torque measurement will be affected. It's
always recommended to call zero_ftsensor() to reset the force/torque sensor before using it,
e.g. in Force Mode.
Sets the active tcp offset, i.e., the transformation from the output flange coordinate system to the TCP as a
pose, and assigns a name to the TCP. If no name is provided, the default name is an empty string.
Parameters
• pose: A pose describing the transformation.
• tcp_name (optional, default=""): A string that assigns a name to the TCP.
16.54. sleep(t)
t: time [s]
Example command: sleep(3.)
• Example Parameters:
• t = 3. -> time to sleep
16.55. time(mode=0)
Return
Function retruns structure in format struct(sec, nanosec)
Example 1: Get seconds part of current time counted since low level controller start.
current_time_s = time().sec
Example 2: Get current system time in seconds including fraction of second.
t = time() global current_time_s = [Link] + [Link] / 1000000000
Example 3: Get current date derived from system clock. NOTE: time(2) function returns GMT time.
# Converts seconds since 1970.01.01 to date
# Based on [Link]
# Returns:
# struct(year, month, day)
def seconds_to_date(z):
local d = struct(year = 0, month = 0, day = 0)
z = floor(z / 86400)
z = z + 719468
local era = floor(z/146097)
local doe = z - era * 146097
local yoe = floor((doe - floor(doe/1460) + floor(doe/36524) - floor
(doe/146096)) / 365)
[Link] = yoe + era * 400
local doy = doe - (365*yoe + floor(yoe/4) - floor(yoe/100))
date_gmt = seconds_to_date(time(2).sec)
Example 4: Get current GMT time derived from system clock.
Converts seconds since 1970.01.01 to time of day
# Returns:
# struct(hour, minute, second)
def seconds_to_time(z):
local t = struct(hour = 0, minute = 0, second = 0)
local sod = z % 86400
[Link] = floor(sod / 3600)
[Link] = floor((sod - [Link] * 3600) / 60)
[Link] = sod % 60
return t
end
time_gmt = seconds_to_time(time(2).sec)
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.
The resulting string cannot exceed 1023 characters, an exception is thrown otherwise.
Float numbers will be formatted with 6 decimals, and trailing zeros will be removed.
The function can be nested to create complex strings (see last example).
Parameters
op1: first operand
op2: second operand
Return Value
String concatenation of op1 and op2
Example command:
• str_cat("Hello", " World!")
• returns "Hello World!"
• str_cat("Integer ", 1)
• returns "Integer 1"
• str_cat("", p[1.0, 2.0, 3.0, 4.0, 5.0, 6.0])
• returns "p[1, 2, 3, 4, 5, 6]"
16.58. str_empty(str)
16.60. str_len(str)
len: (optional) length of the substring in the range [0, MAX_INT]. If len is not specified, the string in the
range [index, src length].
Return Value
the portion of src that starts at byte index and spans len characters.
Example command:
• str_sub("0123456789abcdefghij", 5, 3)
• returns "567"
• str_sub("0123456789abcdefghij", 10)
• returns "abcdefghij"
• str_sub("0123456789abcdefghij", 2, 0)
• returns "" (len is 0)
• str_sub("abcde", 2, 50)
• returns "cde"
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
16.62. sync()
Uses up the remaining "physical" time a thread has in the current frame.
16.64. to_num(str )
16.65. to_str(val)
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])
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
16.67. 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:
>>> def testToolContact():
>>> while True:
>>> step_back = tool_contact()
>>> if step_back <= 0:
>>> # Continue moving with 100mm/s
>>> speedl([0,0,-0.100,0,0,0], 0.5, t=get_steptime())
>>> else:
>>> # Contact detected!
tool_contact(direction = [1,0,0,0,0,0])
• Example Parameters:
• direction=[1,0,0,0,0,0] will detect contacts in the direction robot base X
• Example Parameters:
• f is the cos of 45 deg. (.785 rad)
• Returns .785
17.2. asin(f )
17.3. atan(f )
17.4. atan2(x, y)
17.5. binary_list_to_integer(l)
• Example Parameters:
• l represents the binary values 1001
• Returns 9
17.6. ceil(f )
rounded integer
Example command: ceil(1.43)
• Example Parameters:
• Returns 2
17.7. cos(f )
17.8. d2r(d)
Returns degrees-to-radians of d
Returns the radian value of ’d’ degrees. Actually: (d/180)*MATH_PI
Parameters
17.9. floor(f )
Create a new list of length "length" with the initial value of each element given by "initial_value" and assign
it to a variable.
The "initial_value" sets the type of the list. It can be a complex type like struct. If not provided, the
"capacity" will be defaulted to "length".
Creation list of list with this function is not supported (they are matrices in URScript).
Parameters
length: Number of elements which will be initialized
initial_value: Initial value of the elements
capacity: Maximum number of elements. List can be extended and contracted between 0, and capacity
(Optional default value equals to length)
Example command 1: list_1 = make_list(5, "a")
Equivalent to ["a", "a", "a", "a", "a"]
• Example Parameters:
• length = 5
• initial_value = "a"
• capacity = 5
• initial_value = 0
• capacity = 100
17.11. get_list_length(v)
17.12. integer_to_binary_list(x)
Return Value
A list of 32 bools, where False represents a zero and True represents a one. The bool at index 0 is the
least significant bit.
Example command: integer_to_binary_list(57)
• Example Parameters:
• x integer 57
• Returns binary list
17.14. inv(m)
17.15. length(v)
17.16. log(b, f )
17.17. norm(a)
17.18. normalize(v)
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 addition
Both arguments contain three position parameters (x, y, z) jointly called P, and three rotation parameters
(R_x, R_y, R_z) jointly called R. This function calculates the result x_3 as the addition of the given poses
as follows:
p_3.P = p_1.P + p_2.P
p_3.R = p_1.R * p_2.R
Parameters
p_1: tool pose 1(pose)
p_2: tool pose 2 (pose)
Return Value
Sum of position parts and product of rotation parts (pose)
Example command: pose_add(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.4,1.0,0.7,3.14,0,0]
Pose distance
Parameters
p_from: tool pose (pose)
NOTICE
angle = norm(dist_orientation_as_rotation_vector)
pose_dist = max(dist_translation, angle*0.25)
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]
Pose transformation
The first argument, p_from, is used to transform the second argument, p_from_to, and the result is then
returned. This means that the result is the resulting pose, when starting at the coordinate system of p_
from, and then in that coordinate system moving p_from_to.
This function can be seen in two different views. Either the function transforms, that is translates and
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
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.
If the poses were regarded as transformation matrices, it would look like:
T_world->to = T_world->from * T_from->to T_x->to = T_x->from * T_from->to
Parameters
p_from: starting pose (spatial vector)
p_from_to: pose change relative to starting pose (spatial vector)
Return Value
resulting pose (spatial vector)
Example command: pose_trans(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.4,-0.0996,0.60048,3.14,0.0,0.0]
17.26. r2d(r)
Returns radians-to-degrees of r
Returns the degree value of ’r’ radians.
17.27. random()
Random Number
Return Value
pseudo-random number between 0 and 1 (float)
17.28. rotvec2rpy(rotation_vector)
Return Value
The RPY vector (Vector3d) in radians, describing a roll-pitch-yaw sequence of extrinsic rotations about the
X-Y-Z axes, (corresponding to intrinsic rotations about the Z-Y’-X” axes). In matrix form the RPY vector is
defined as Rrpy = Rz(yaw)Ry(pitch)Rx(roll).
Example command: rotvec2rpy([3.14,1.57,0])
• Example Parameters:
• rotation_vector = [3.14,1.57,0] -> rx=3.14, ry=1.57, rz=0
• Returns [-2.80856, -0.16202, 0.9] -> roll=-2.80856, pitch=-0.16202, yaw=0.9
17.29. rpy2rotvec(rpy_vector)
Returns the rotation vector corresponding to ’rpy_vector’ where the RPY (roll-pitch-yaw) rotations are
extrinsic rotations about the X-Y-Z axes (corresponding to intrinsic rotations about the Z-Y’-X” axes).
Parameters
rpy_vector: The RPY vector (Vector3d) in radians, describing a roll-pitch-yaw sequence of extrinsic
rotations about the X-Y-Z axes, (corresponding to intrinsic rotations about the Z-Y’-X” axes). In matrix form
the RPY vector is defined as Rrpy = Rz(yaw)Ry(pitch)Rx(roll).
Return Value
The rotation vector (Vector3d) in radians, also called the Axis-Angle vector (unit-axis of rotation multiplied
by the rotation angle in radians).
Example command: rpy2rotvec([3.14,1.57,0])
• Example Parameters:
• rpy_vector = [3.14,1.57,0] -> roll=3.14, pitch=1.57, yaw=0
• Returns [2.22153, 0.00177, -2.21976] -> rx=2.22153, ry=0.00177, rz=-2.21976
17.30. sin(f )
• Example Parameters:
• f is angle of 1.57 rad (90 deg)
• Returns 1.0
17.31. 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.
17.32. sqrt(f )
17.33. tan(f)
Returns the tangent of f
Returns the tangent of an angle of f radians.
Parameters
17.34. transpose(m)
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 transformation
Move the point of view of a wrench.
Note: Transforming wrenches is not as trivial as transforming poses as the torque scales with the length of
the translation.
w_to = T_from->to * w_from
Parameters
T_from_to: The transformation to the new point of view (Pose)
w_from: wrench to transform in list format [F_x, F_y, F_z, M_x, M_y, M_z]
Return Value
resulting wrench, w_to in list format [F_x, F_y, F_z, M_x, M_y, M_z]
Deprecated:
This function is used for enabling and disabling the use of external F/T measurements in the controller. Be
aware that the following function is impacted:
• force_mode
• screw_driving
• freedrive_mode
This function is used for enabling and disabling the use of external F/T measurements in the controller. Be
aware that the following function is impacted:
• force_mode
• screw_driving
• freedrive_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
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
• ft_rtde_input_enable(True, 0.5)
• Example Parameters:
• enable S{rarr} Enabling the feed of an external F/T measurements in the
controller.
• sensor_mass S{rarr} mass of F/T sensor is set to 0.5 Kg.
• Both sensor measuring offset and sensor's center of gravity are zero.
• @example:
• C{ft_rtde_input_enable(False)}
• Disable the feed of external F/T measurements in the controller (no other
parameters required)
18.3. get_analog_in(n)
18.4. get_analog_out(n)
• Example Parameters:
• n is analog output 1
• Returns value of analog output #1
18.5. get_configurable_digital_in(n)
18.6. get_configurable_digital_out(n)
18.7. get_digital_in(n)
18.8. get_digital_out(n)
18.9. 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
18.10. get_rtde_value(key)
Returns the corresponding value of the supplied RTDE output field key.
This function retrieves an RTDE value from the RTDE output buffer, which also can be collected through a
client. The RTDE value is one time step behind, therefore it is suggested to make a sync() call, before
calling get_rtde_value(key).
Parameters
key: RTDE output field key of value to retrieve. See the complete list of available fields and their
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
Example command:get_rtde_value("target_qd")
• Example Parameters:
• key = "target_qd" → retrieve target joint velocities.
18.11. get_standard_analog_in(n)
• Example Parameters:
• n is standard analog input 1
• Returns value of standard analog input #1
18.12. get_standard_analog_out(n)
18.13. get_standard_digital_in(n)
18.14. get_standard_digital_out(n)
18.15. get_tool_analog_in(n)
18.16. get_tool_digital_in(n)
18.17. get_tool_digital_out(n)
Adds a new Modbus signal for the controller to supervise. Expects no response. If the signal is an output
type, then until the first set_output_signal/register() command the function code will be 2/3, after the call it
will switch to 15/16.
Matrix of function codes used for accessing coils or discrete inputs:
Read Write
Signal type Single Coil Multiple Single Coil Multiple Coils
Coils
0 = Digital input 2 2 - -
1 = Digital output 1 1 15 15
15 = Multiple digital 1 1 15 15
outputs
Read Write
Signal type Single Multiple Single Multiple
register registers register registers
2 = Register input 4 4 - -
3 = Register output 3 3 6 16
16 = Multiple register 3 3 16 16
outputs
greater or equal to 0.
signal_type: An integer specifying the type of signal to add. 0 = digital input, 1 = digital output, 2 =
register input, 3 = register output, 15 = multiple digital output, 16 = multiple register output. Note: this
function does not accept 23 = multiple read-write signal type.
signal_name: A string uniquely identifying the signal. If a string is supplied which is equal to an already
added signal, the new signal will replace the old one. The length of the string can not exceed 20
characters. The signal name cannot be empty.
sequential_mode: Setting to True forces the Modbus client to wait for a response before sending the
next request. This mode is required by some fieldbus units (Optional).
register_count: Number of registers/coils accessed by the signal [1-123] (Optional, the default value
is 1).
Example command 1: modbus_add_signal("[Link]", 255, 5, 1, "output1")
• Example Parameters:
• IP address = [Link]
• Slave number = 255
• Signal address = 5
• Signal type = 1 digital output
• Signal name = output 1
Adds a new modbus signal for the controller to supervise. This function will use the function code 23. The
read and write addresses can overlap. Until the first set_output_register() command the function code will
be 3, after the call it will switch to 23.
>>> modbus_add_rw_signal("[Link]", 255, 5, 10, 15, 10, "output1")
• Example Parameters:
• IP address = [Link]
• Slave number = 255
• Signal read address = 5
• Signal read register count = 10
• Signal write address = 15
• Signal write register count = 10
• Signal name = output 1
18.20. modbus_delete_signal(signal_name)
>>> modbus_delete_signal("output1")
Parameters
signal_name: A string equal to the name of the signal that should be deleted. The signal name can not
be empty.
Example command: modbus_delete_signal("output1")
• Example Parameters:
• Signal name = output1
Reads the current value(s) of a specific signal. If the modbus watchdog is active, this will return the last
valid value(s). No error will be thrown within the watchdog time. If needed, the modus_get_error() or the
modbus_get_time_since_signal_invalid() can be used to detected that the signal is in an error state before
the watchdog expires.
>>> 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. Can not be
empty.
is_secondary_program: A boolean for internal use only. Must be set to False. (Optional, default is
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. If the signal was declared to have access for multiple registers/coild,
then the return value will be an array of unsigned integers / booleans. The length of the returned array is
equal to the register_count of the signal.
Example command: modbus_get_signal_status("output1")
Example Parameters:
• Signal name = output 1
• Is_secondary_program = False by default
18.23. modbus_set_digital_input_action(signal_name,
action)
Sets the selected digital input signal to either a "default" or "freedrive" action.
>>> modbus_set_digital_input_action("input1", "freedrive")
Parameters
signal_name: A string identifying a digital input signal that was previously added. Can not be empty.
action: The type of action. The action can either be "default" or "freedrive". Can not be empty. (string)
Example command: modbus_set_digital_input_action("input1", "freedrive")
• Example Parameters:
• Signal name = "input1"
• Action = "freedrive"
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
18.24. modbus_set_output_register(signal_name,
register_value, is_secondary_program=False)
Sets the output register(s) 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. Can not be
empty.
register_value: An integer which must be a valid word (0-65535) value or a list of integer values. The
list can not be empty. The size of the list must be less than 123 and must be equal or less to the signal's
declared register count. Note: if a shorter list is given as an input, then registers with greater indexes will
keep previous value
is_secondary_program: A boolean for internal use only. Must be set to False. (Optional, false by
default)
Example command 1: 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)
Example command 2:
modbus_add_signal("[Link]", 255, 0, 16, "output2", False, 10)
list_var:=[10,9,8,7,6,5,4,3,2,1]
modbus_set_output_register("output2", list_var)
• Example Parameters:
• Signal name = output2
• Register values = 10,9,8,7,6,5,4,3,2,1
• Is_secondary_program = False by default
Sets the output digital signal(s) identified by the given name to the given value.
>>> modbus_set_output_signal("output2",True,False)
Parameters
Example command 2:
modbus_add_signal("[Link]", 255, 0, 15, "output2", False, 5)
list_var:=[True, False, True, False, True]
modbus_set_output_signal("output2", list_var)
• Example Parameters:
• Signal name = output2
• Digital values = True, False, True, False, True
• Is_secondary_program = False by default.
18.26. 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. Can not be
empty.
update_frequency: An integer in the range 0-500 specifying the update frequency in Hz.
Note: The function accepts -1 and 0 as a valid input as a special value to create acyclic signals.
Note: If the input is 0 the signal will be acyclic.
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
18.27. modbus_get_error(signal_name)
Connection errors
Values from 1-113, see details in [Link] and
[Link]
NOTICE
If combined errors are requested, then the returned value's upper 2 bytes will store the
connection error, the lower 2 bytes will store the device errors. Example returned value:
0xFFFE0004 (dec:-131068) -> upper 0xFFFE = -2 Disconnected ; lower 0x0004 =
Device error - server failure
Returns the time in seconds since the signal is invalid (has communication or device error).For input
signals function tells how long ago was last time when signal value was successfully read from remote
device. For output signals function tells how long ago was last time when signal value was successfully
written to remote device.
>>> modbus_get_time_since_signal_invalid("output1")
Parameters
signal_name: A string equal to the name of the signal. The signal name can not be empty.
Return Value
A float number representing the time in seconds since the signal is in a communication or device error.
Example command: modbus_get_time_since_signal_invalid("output1")
• Example Parameters:
• Signal name = output1
18.29. modbus_request_update_signal_value(signal_
name)
Tear down, and reconnect all signals to remote device. By default it will block as long as there are errors in
the connection.
>>> modbus_reset_connection("[Link]")
Parameters
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
connection_id: A string specifying the IP address of the modbus unit to which the modbus signal is
connected. The IP can not be empty.
Example command: modbus_reset_connection("[Link]")
Example Parameters:
• connection_id = [Link]
• is_blocking = True
Set tolerance for modbus errors (both communication, and device exceptions) as minimum time between
valid device responses. No error will be thrown within the watchdog time. If needed, the modus_get_error
() or the modbus_get_time_since_signal_invalid() can be used to detected that the signal is in an error
state before the watchdog [Link] signal timeout is 2 seconds.
>>> modbus_set_signal_watchdog("signal1", 5)
Parameters
signal_name: A string identifying an output digital signal that in advance has been added. Can not be
empty.
new_timeout_in_sec: A number in range 0-300 representing seconds.
Example command: modbus_set_signal_watchdog("signal1", 10.5)
Example Parameters:
• signal_name = signal1
• new_timeout_in_sec = 10.5 seconds
18.32. 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)
18.33. 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
18.34. 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
18.35. read_output_boolean_register(address)
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
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
18.36. 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
18.37. 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.
18.38. read_port_bit(address)
Reads one of the ports, which can also be accessed by Modbus clients
>>> boolval = read_port_bit(3)
Parameters
address: Address of the port (See port map on Support site, page "Modbus Server" )
Return Value
The value held by the port (True, False)
Example command: read_port_bit(3)
• Example Parameters:
• Address = port bit 3
18.39. read_port_register(address)
Reads one of the ports, which can also be accessed by Modbus clients
>>> intval = read_port_register(3)
Parameters
address: Address of the port (See port map on Support site, page "Modbus Server" )
Return Value
The signed integer value held by the port (-32768 : 32767)
Example command: read_port_register(3)
Example Parameters:
Address = port register 3
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
Creates a new Remote Procedure Call (RPC) handle. Please read the subsection ef{Remote Procedure
Call (RPC)} for a more detailed description of RPCs.
>>> proxy = rpc_factory("xmlrpc", "[Link]
Parameters
type: The type of RPC backed to use. Currently only the "xmlrpc" protocol is available.
url: The URL to the RPC server. Currently two protocols are supported: pstream and http. The pstream
URL looks like "<ip-address>:<port>", for instance "[Link]:8080" to make a local connection on port
8080. A http URL generally looks like "[Link] whereby the <path> depends
on the setup of the http server. In the example given above a connection to a local Python webserver on
port 8080 is made, which expects XMLRPC calls to come in on the path "RPC2".
Return Value
A RPC handle with a connection to the specified server using the designated RPC backend. If the server is
not available the function and program will fail. Any function that is made available on the server can be
called using this instance. For example "bool isTargetAvailable(int number, ...)" would be
"[Link](var_1, ...)", whereby any number of arguments are supported (denoted by the
...).
Note: Giving the RPC instance a good name makes programs much more readable (i.e. "proxy" is not a
very good name).
Example command: rpc_factory("xmlrpc", "[Link]
• Example Parameters:
• type = xmlrpc
• url = [Link]
This function will activate a watchdog for a particular input variable to the RTDE. When the watchdog did
not receive an input update for the specified variable in the time period specified by min_frequency (Hz),
the corresponding action will be taken. All watchdogs are removed on program stop.
>>> rtde_set_watchdog("input_int_register_0", 10, "stop")
Parameters
variable_name: Input variable name (string), as specified by the RTDE interface
min_frequency: The minimum frequency (float) an input update is expected to arrive.
action: Optional: Either "ignore", "pause" or "stop" the program on a violation of the minimum frequency.
The default action is "pause".
Return Value
18.43. set_analog_out(n, f )
18.44. set_configurable_digital_out(n, b)
18.45. set_digital_out(n, b)
• Example Parameters:
• n is digital output 1
• b = True
18.46. 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)
18.47. set_standard_analog_out(n, f)
18.48. set_standard_digital_out(n, b)
• Example Parameters:
• n is standard digital output 1
• f = True
18.49. set_tool_digital_out(n, b)
This function will activate or deactivate the ’Tool Communication Interface’ (TCI). The TCI will enable
communication with a external tool via the robots analog inputs hereby avoiding external wiring.
>>> set_tool_communication(True, 115200, 1, 2, 1.0, 3.5)
Parameters
enabled: Boolean to enable or disable the TCI (string). Valid values: True (enable), False (disable)
baud_rate: The used baud rate (int). Valid values: 9600, 19200, 38400, 57600, 115200, 1000000,
2000000, 5000000.
parity: The used parity (int). Valid values: 0 (none), 1 (odd), 2 (even).
stop_bits: The number of stop bits (int). Valid values: 1, 2.
rx_idle_chars: Amount of chars the RX unit in the tool should wait before marking a message as over /
sending it to the PC (float). Valid values: min=1.0 max=40.0.
tx_idle_chars: Amount of chars the TX unit in the tool should wait before starting a new transmission
since last activity on bus (float). Valid values: min=0.0 max=40.0.
Return Value
None
Note:
Enabling this feature will disable the robot tool analog inputs.
Example command:
set_tool_communication(True, 115200, 1, 2, 1.0, 3.5)
• Example Parameters:
• enabled = True
• baud rate = 115200
• parity = ODD
• stop bits = 2
• rx idle time = 1.0
• tx idle time = 3.5
• Example Parameters:
• 1 is the power (dual pin) mode.
The digital outputs are used as extra supply
18.53. 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:
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
• voltage = 24 volts
18.54. socket_close(socket_name=’socket_0’)
Reads a number of ascii formatted floats from the socket. A maximum of 30 values can be read in one
command.
The format of the numbers should be in parantheses, and seperated by ",". An example list of four
numbers could look like "( 1.414 , 3.14159, 1.616, 0.0 )".
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 (length=number+1, list of floats)
• Example command: list_of_four_floats = socket_read_ascii_float(4,"socket_
10")
• Example Parameters:
• number = 4 → Number of floats to read
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
• socket_name = socket_10
• returns list
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.
Returns (for example) [3,100,2000,30000], if there is a timeout or the reply is invalid, [0,-1,-1,-1] is
returned, indicating that 0 integers have been read
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 (length=number+1, list of ints)
Example command: list_of_ints = socket_read_binary_integer(4,"socket_10")
• Example Parameters:
• number = 4 -> Number of integers to read
• socket_name = socket_10
Reads a number of bytes from the socket. A maximum of 30 values can be read in one command.
Returns (for example) [3,100,200,44], if there is a timeout or the reply is invalid, [0,-1,-1,-1] is returned,
indicating that 0 bytes have been read
Parameters
number: The number of bytes 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
18.60. 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
18.61. socket_read_string(socket_name=’socket_0’,
prefix =’’, suffix =’’, interpret_escape=’False’, timeout=2)
Reads all data from the socket and returns the data as a string.
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.
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
Maxium length of received string including termination characters is limited to 1024 characters.
>>> if(string_from_server) :
>>> popup("the string is not empty")
>>> end
The optional parameters "prefix" and "suffix", can be used to express what is extracted from the socket.
The "prefix" specifies the start of the substring (message) extracted from the socket. The data up to the
end of the "prefix" will be ignored and removed from the socket. The "suffix" specifies the end of the
substring (message) extracted from the socket. Any remaining data on the socket, after the "suffix", will be
preserved.
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.
The optional parameter "interpret_escape" can be used to allow the use of escape sequences "\n", "\t" and
"\r" as part of the prefix or suffix.
Parameters
socket_name: Name of socket (string)
prefix: Defines a prefix (string)
suffix: Defines a suffix (string)
interpret_escape: Enables the interpretation of escape sequences (bool)
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
String
Example command: string_from_server = socket_read_string("socket_
10",prefix=">",suffix="<")
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
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
• Example Parameters:
• str = hello
• socket_name = socket_10
• Returns True or False (sent or not sent)
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
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:
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
• address = 3
• value = 37.68
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
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
Writes one of the ports, which can also be accessed by Modbus clients
18.72. zero_ftsensor()
Zeroes the TCP force/torque measurement from the builtin force/torque sensor by subtracting the current
measurement from the subsequent.
18.73. request_boolean_from_primary_client(message)
Request input from operator. Polyscope shows dialog box with "yes" and "no" buttons.
Function blocks until operator selects option on the Polyscope screen.
NOTE: Operator can also stop program by pressing "Cancel" button
Parameters
message: A string with a message shown on Polyscope dialog box. Can not be empty.
Return Value
True or False: Value selected by the operator.
18.74. request_float_from_primary_client(message)
Request input from operator. Polyscope shows dialog box with decimal number entry field.
Function blocks until operator enters value on the Polyscope screen.
NOTE: Operator can also stop program by pressing "Cancel" button
Parameters
message: A string with a message shown on Polyscope dialog box. Can not be empty.
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
Return Value
Float: Value entered by the operator.
Example command: offset_mm = request_float_from_primary_client("Enter gripping
offset [mm]")
Show message to the operator, and save reply to offset_mm variable
18.75. request_integer_from_primary_client(message)
Request input from operator. Polyscope shows dialog box with integer number entry field.
Function blocks until operator enters value on the Polyscope screen.
NOTE: Operator can also stop program by pressing "Cancel" button
Parameters
message: A string with a message shown on Polyscope dialog box. Can not be empty.
Return Value
Integer: Value entered by the operator.
Example command: number_of_parts = request_integer_from_primary_client("Enter
number of parts")
Show message to the operator, and save reply to number_of_parts variable
18.76. request_string_from_primary_client(message)
Request input from operator. Polyscope shows dialog box with string entry field.
Function blocks until operator enters value on the Polyscope screen.
19.1. 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. Can not be empty.
state:
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
• Example Parameters:
• port is analog output port 1 (on controller)
• domain = 1 (0-10 volts)
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
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
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
19.5. 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
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
set_gp_boolean_input_action
Example command: set_input_actions_to_default()
19.6. set_runstate_configurable_digital_output_to_value
(outputId, state)
Using this method assigns the output to one of the states. This will set the output signal level depending on
the state.
Example: Set configurable digital output 5 to high when program is not running.
>>> 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,
6: Set signal High when the robot has drive power,
7: Set signal Low when the robot has drive power.
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.
19.7. set_runstate_gp_boolean_output_to_value
(outputId, state)
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
19.8. set_runstate_standard_analog_output_to_value
(outputId, state)
Using this method assigns the output to one of the states. This will set the output signal level depending on
the state.
Example: Set standard analog output 1 to high when program is not running.
>>> 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,
Copyright © 2009–2025 by Universal Robots A/S. All rights reserved.
19.9. set_runstate_standard_digital_output_to_value
(outputId, state)
Using this method assigns the output to one of the states. This will set the output signal level depending on
the state.
Example: Set standard digital output 5 to high when program is not running.
>>> 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,
6: Set signal High when the robot has drive power,
7: Set signal Low when the robot has drive power.
Note: An unscheduled program termination is caused when a Protective stop, Fault, Violation or Runtime
exception occurs.
Example command:
19.10. set_runstate_tool_digital_output_to_value
(outputId, state)
Sets the output signal level depending on the state of the program (running or stopped).
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
Parameters
port: analog input port number: 0 or 1
domain: analog input domains: 0: 4-20mA, 1: 0-10V
Example command: set_standard_analog_input_domain(1,0)
• Example Parameters:
• port = analog input port 1
• domain = 0 (4-20 mA)
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
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