2. RoboDK API (robodk package)

Warning

The RoboDK API was refactored with version 5.4.0.

These changes are backward compatible, but not forward compatible. Effectively, the robolink.py module is now a sub-module of the robodk package (robodk.robolink), and robodk.py is now split into different sub-modules (robodk.robomath, robodk.robodialogs, robodk.robofileio).

You can access the documentation prior to version 5.4.0 here: https://robodk.com/doc/en/PythonAPI/v0/index.html

Before 5.4.0

Most of our examples used the import method below:

from robolink import *
from robodk import *
RDK = Robolink()
pose = eye()
ITEM_TYPE_ROBOT

After 5.4.0

You can use any of the following import methods:

from robodk import robolink, robomath
RDK = robolink.Robolink()
pose = robomath.eye()
robolink.ITEM_TYPE_ROBOT
from robodk.robolink import Robolink, ITEM_TYPE_ROBOT
from robodk.robomath import eye
RDK = Robolink()
pose = eye()
ITEM_TYPE_ROBOT
from robodk.robolink import *
from robodk.robomath import *
RDK = Robolink()
pose = eye()
ITEM_TYPE_ROBOT

The robodk package is the distributed entry point of the Python API. It is the common parent of all sub-packages and modules that constitute the Python API.

Overview of the RoboDK API:

2.2. robomath.py

The robomath module is a robotics toolbox for Python, based on Peter Corke’s Robotics Toolbox (regarding pose transformations): http://petercorke.com/Robotics_Toolbox.html. The robomath sub-module includes the Mat class to represent transformations in 3D.

The following page provides a brief overview of the RoboDK API for Python: https://www.robodk.com/offline-programming

A summary regarding the RoboDK API is available in the documentation: https://robodk.com/doc/en/RoboDK-API.html

robodk.robomath.Adept_2_Pose(xyzrpw)

Converts an Adept XYZRPW target to a pose (4x4 matrix)

robodk.robomath.Comau_2_Pose(xyzrpw)

Converts a Comau XYZRPW target to a pose (4x4 matrix), the same representation required by PDL Comau programs.

robodk.robomath.Fanuc_2_Pose(xyzwpr)

Converts a Motoman target to a pose (4x4 matrix)

robodk.robomath.KUKA_2_Pose(xyzrpw)

Converts a KUKA XYZABC target to a pose (4x4 matrix), required by KUKA KRC controllers.

class robodk.robomath.Mat(rows=None, ncols=None)

Mat is a matrix object. The main purpose of this object is to represent a pose in the 3D space (position and orientation).

A pose is a 4x4 matrix that represents the position and orientation of one reference frame with respect to another one, in the 3D space.

Poses are commonly used in robotics to place objects, reference frames and targets with respect to each other.

Example:

from robodk.robolink import *           # import the robolink library
from robodk.robomath import *           # import the robomath library

RDK = Robolink()                        # connect to the RoboDK API
robot  = RDK.Item('', ITEM_TYPE_ROBOT)  # Retrieve a robot available in RoboDK
#target  = RDK.Item('Target 1')         # Retrieve a target (example)


pose = robot.Pose()                     # retrieve the current robot position as a pose (position of the active tool with respect to the active reference frame)
# target = target.Pose()                # the same can be applied to targets (taught position)

# Read the 4x4 pose matrix as [X,Y,Z , A,B,C] Euler representation (mm and deg): same representation as KUKA robots
XYZABC = Pose_2_KUKA(pose)
print(XYZABC)

# Read the 4x4 pose matrix as [X,Y,Z, q1,q2,q3,q4] quaternion representation (position in mm and orientation in quaternion): same representation as ABB robots (RAPID programming)
xyzq1234 = Pose_2_ABB(pose)
print(xyzq1234)

# Read the 4x4 pose matrix as [X,Y,Z, u,v,w] representation (position in mm and orientation vector in radians): same representation as Universal Robots
xyzuvw = Pose_2_UR(pose)
print(xyzuvw)

x,y,z,a,b,c = XYZABC                    # Use the KUKA representation (for example) and calculate a new pose based on the previous pose
XYZABC2 = [x,y,z+50,a,b,c+45]
pose2 = KUKA_2_Pose(XYZABC2)            # Convert the XYZABC array to a pose (4x4 matrix)

robot.MoveJ(pose2)                      # Make a joint move to the new position
# target.setPose(pose2)                  # We can also update the pose to targets, tools, reference frames, objects, ...
Cols()

Retrieve the matrix as a list of columns (list of list of float).

Example:

>>> transl(10,20,30).Rows()
[[1, 0, 0, 10], [0, 1, 0, 20], [0, 0, 1, 30], [0, 0, 0, 1]]

>>> transl(10,20,30).Cols()
[[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [10, 20, 30, 1]]
ColsCount()

Return the number of coumns. Same as len().

Offset(x, y, z, rx=0, ry=0, rz=0)

Calculates a relative target with respect to the reference frame coordinates. X,Y,Z are in mm, W,P,R are in degrees.

Pos()

Returns the position of a pose (assumes that a 4x4 homogeneous matrix is being used)

RelTool(x, y, z, rx=0, ry=0, rz=0)

Calculates a target relative with respect to the tool coordinates. X,Y,Z are in mm, W,P,R are in degrees. The behavior of this function is the same as ABB’s RAPID RelTool command.

Rot33()

Returns the sub 3x3 rotation matrix

Rows()

Get the matrix as a list of lists

RowsCount()

Return the number of rows

SaveCSV(strfile)

Save the Mat Matrix to a CSV (Comma Separated Values) file. The file can be easily opened as a spreadsheet such as Excel.

See also

SaveMat(), SaveList(), LoadList(), LoadMat()

SaveMat(strfile, separator=',')

Save the Mat Matrix to a CSV or TXT file

See also

SaveCSV(), SaveList(), LoadList(), LoadMat()

VX()

Returns the X vector of a pose (assumes that a 4x4 homogeneous matrix is being used)

VY()

Returns the Y vector of a pose (assumes that a 4x4 homogeneous matrix is being used)

VZ()

Returns the Z vector of a pose (assumes that a 4x4 homogeneous matrix is being used)

catH(mat2)

Concatenate with another matrix (horizontal concatenation)

catV(mat2)

Concatenate with another matrix (vertical concatenation)

eye(m=4)

Make identity matrix of size (mxm)

inv()

Returns the inverse of this pose (homogeneous matrix assumed)

invH()

Returns the inverse of this pose (homogeneous matrix assumed)

isHomogeneous()

returns 1 if it is a Homogeneous matrix

list()

Returns the first column of the matrix as a list

list2()

Returns the matrix as list of lists (one list per column)

rotationPose()

Return the rotation pose of this matrix. The position returned is set to [0,0,0] (assumes that a 4x4 homogeneous matrix is being used)

setPos(newpos)

Sets the XYZ position of a pose (assumes that a 4x4 homogeneous matrix is being used)

setVX(v_xyz)

Sets the VX vector of a pose, which is the first column of a homogeneous matrix (assumes that a 4x4 homogeneous matrix is being used)

setVY(v_xyz)

Sets the VY vector of a pose, which is the first column of a homogeneous matrix (assumes that a 4x4 homogeneous matrix is being used)

setVZ(v_xyz)

Sets the VZ vector of a pose, which is the first column of a homogeneous matrix (assumes that a 4x4 homogeneous matrix is being used)

size(dim=None)

Returns the size of a matrix (m,n). Dim can be set to 0 to return m (rows) or 1 to return n (columns)

tolist()

Returns the first column of the matrix as a list

tr()

Returns the transpose of the matrix

translationPose()

Return the translation pose of this matrix. The rotation returned is set to identity (assumes that a 4x4 homogeneous matrix is being used)

exception robodk.robomath.MatrixError

An exception class for Matrix

robodk.robomath.Motoman_2_Pose(xyzwpr)

Converts a Motoman target to a pose (4x4 matrix)

robodk.robomath.Nachi_2_Pose(xyzwpr)

Converts a Nachi XYZRPW target to a pose (4x4 matrix)

robodk.robomath.Offset(target_pose, x, y, z, rx=0, ry=0, rz=0)

Calculates a relative target with respect to the reference frame coordinates. X,Y,Z are in mm, RX,RY,RZ are in degrees.

Parameters
  • x (float) – translation along the Reference X axis (mm)

  • y (float) – translation along the Reference Y axis (mm)

  • z (float) – translation along the Reference Z axis (mm)

  • rx (float) – rotation around the Reference X axis (deg) (optional)

  • ry (float) – rotation around the Reference Y axis (deg) (optional)

  • rz (float) – rotation around the Reference Z axis (deg) (optional)

robodk.robomath.Pose(x, y, z, rxd, ryd, rzd)

Returns the pose (Mat) given the position (mm) and Euler angles (deg) as an array [x,y,z,rx,ry,rz]. The result is the same as calling: H = transl(x,y,z)*rotx(rx*pi/180)*roty(ry*pi/180)*rotz(rz*pi/180) This pose format is printed for homogeneous poses automatically. This Pose is the same representation used by Mecademic or Staubli robot controllers.

Parameters
  • tx (float) – position (X coordinate)

  • ty (float) – position (Y coordinate)

  • tz (float) – position (Z coordinate)

  • rxd (float) – first rotation in deg (X coordinate)

  • ryd (float) – first rotation in deg (Y coordinate)

  • rzd (float) – first rotation in deg (Z coordinate)

robodk.robomath.PosePP(x, y, z, r, p, w)

Create a pose from XYZRPW coordinates. The pose format is the one used by KUKA (XYZABC coordinates). This is function is the same as KUKA_2_Pose (with the difference that the input values are not a list). This function is used as “p” by the intermediate file when generating a robot program.

robodk.robomath.Pose_2_ABB(H)

Converts a pose to an ABB target (using quaternion representation).

Parameters

H (Mat) – pose

robodk.robomath.Pose_2_Adept(H)

Converts a pose to an Adept target

Parameters

H (Mat) – pose

robodk.robomath.Pose_2_Comau(H)

Converts a pose to a Comau target, the same representation required by PDL Comau programs.

Parameters

H (Mat) – pose

robodk.robomath.Pose_2_Fanuc(H)

Converts a pose (4x4 matrix) to a Fanuc XYZWPR target (mm and deg)

Parameters

H (Mat) – pose

robodk.robomath.Pose_2_KUKA(H)

Converts a pose (4x4 matrix) to an XYZABC KUKA target (Euler angles), required by KUKA KRC controllers.

Parameters

H (Mat) – pose

robodk.robomath.Pose_2_Motoman(H)

Converts a pose (4x4 matrix) to a Motoman XYZWPR target (mm and deg)

Parameters

H (Mat) – pose

robodk.robomath.Pose_2_Nachi(pose)

Converts a pose to a Nachi XYZRPW target

Parameters

pose (Mat) – pose

robodk.robomath.Pose_2_Staubli(H)

Converts a pose (4x4 matrix) to a Staubli XYZWPR target

Parameters

H (Mat) – pose

robodk.robomath.Pose_2_Techman(H)

Converts a pose (4x4 matrix) to a Techman XYZWPR target (mm and deg)

Parameters

H (Mat) – pose

robodk.robomath.Pose_2_TxyzRxyz(H)

Retrieve the position (mm) and Euler angles (rad) as an array [x,y,z,rx,ry,rz] given a pose. It returns the values that correspond to the following operation: H = transl(x,y,z)*rotx(rx)*roty(ry)*rotz(rz).

Parameters

H (Mat) – pose

robodk.robomath.Pose_2_UR(pose)

Calculate the p[x,y,z,u,v,w] position with rotation vector for a pose target. This is the same format required by Universal Robot controllers.

robodk.robomath.Pose_Split(pose1, pose2, delta_mm=1.0)

Create a sequence of poses that transitions from pose1 to pose2 by steps of delta_mm in mm (the first and last pose are not included in the list)

robodk.robomath.RelTool(target_pose, x, y, z, rx=0, ry=0, rz=0)

Calculates a relative target with respect to the tool coordinates. This procedure has exactly the same behavior as ABB’s RelTool instruction. X,Y,Z are in mm, W,P,R are in degrees.

Parameters
  • x (float) – translation along the Tool X axis (mm)

  • y (float) – translation along the Tool Y axis (mm)

  • z (float) – translation along the Tool Z axis (mm)

  • rx (float) – rotation around the Tool X axis (deg) (optional)

  • ry (float) – rotation around the Tool Y axis (deg) (optional)

  • rz (float) – rotation around the Tool Z axis (deg) (optional)

robodk.robomath.Techman_2_Pose(xyzwpr)

Converts a Techman target to a pose (4x4 matrix)

robodk.robomath.TxyzRxyz_2_Pose(xyzrpw)

Returns the pose given the position (mm) and Euler angles (rad) as an array [x,y,z,rx,ry,rz]. The result is the same as calling: H = transl(x,y,z)*rotx(rx)*roty(ry)*rotz(rz)

Parameters

xyzrpw (list of float) – [x,y,z,rx,ry,rz] in mm and radians

robodk.robomath.UR_2_Pose(xyzwpr)

Calculate the pose target given a p[x,y,z,u,v,w] cartesian target with rotation vector. This is the same format required by Universal Robot controllers.

robodk.robomath.acos(value)

Returns the arc cosinus in radians

robodk.robomath.add3(a, b)

Adds two 3D vectors c=a+b

robodk.robomath.angle3(a, b)

Returns the angle in radians of two 3D vectors

robodk.robomath.angles_2_joints(jin, type)

Converts the angles between links into the robot motor space depending on the type of the robot.

robodk.robomath.asin(value)

Returns the arc sine in radians

robodk.robomath.atan2(y, x)

Returns angle of a 2D coordinate in the XY plane

robodk.robomath.catH(mat1, mat2)

Concatenate 2 matrices (horizontal concatenation)

robodk.robomath.catV(mat1, mat2)

Concatenate 2 matrices (vertical concatenation)

robodk.robomath.cos(value)

Returns the cosine of an angle in radians

robodk.robomath.cross(a, b)

Returns the cross product of two 3D vectors

robodk.robomath.dh(rz, tx=None, tz=None, rx=None)

Returns the Denavit-Hartenberg 4x4 matrix for a robot link. calling dh(rz,tx,tz,rx) is the same as using rotz(rz)*transl(tx,0,tz)*rotx(rx) calling dh(rz,tx,tz,rx) is the same as calling dh([rz,tx,tz,rx])

robodk.robomath.dhm(rx, tx=None, tz=None, rz=None)

Returns the Denavit-Hartenberg Modified 4x4 matrix for a robot link (Craig 1986).

calling dhm(rx,tx,tz,rz) is the same as using rotx(rx)*transl(tx,0,tz)*rotz(rz)

calling dhm(rx,tx,tz,rz) is the same as calling dhm([rx,tx,tz,rz])

robodk.robomath.distance(a, b)

Calculates the distance between two points

robodk.robomath.dot(a, b)

Returns the dot product of two 3D vectors

robodk.robomath.eye(size=4)

Returns the identity matrix

T(t_x, t_y, t_z) = \begin{bmatrix} 1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 \\
0 & 0 & 1 & 0 \\
0 & 0 & 0 & 1
\end{bmatrix}

Parameters

size (int) – square matrix size (4x4 Identity matrix by default, otherwise it is initialized to 0)

robodk.robomath.fitPlane(points)

Best fits a plane to a cloud of points

robodk.robomath.intersect_line_2_plane(pline, vline, pplane, vplane)

Calculates the intersection betweeen a line and a plane

robodk.robomath.invH(matrix)

Returns the inverse of a homogeneous matrix

Parameters

matrix (Mat) – pose

robodk.robomath.joints_2_angles(jin, type)

Converts the robot encoders into angles between links depending on the type of the robot.

robodk.robomath.mult3(v, d)

Multiplies a 3D vector to a scalar

robodk.robomath.name_2_id(str_name_id)

Returns the number of a numbered object. For example: “Frame 3”, “Frame3”, “Fram3 3” returns 3.

robodk.robomath.norm(p)

Returns the norm of a 3D vector

robodk.robomath.normalize3(a)

Returns the unitary vector

robodk.robomath.pause(seconds)

Pause in seconds

Parameters

pause (float) – time in seconds

robodk.robomath.point_Zaxis_2_pose(point, zaxis, yaxis_hint1=[0, 0, 1], yaxis_hint2=[0, 1, 1])

Returns a pose given the origin as a point, a Z axis and a preferred orientation for the Y axis

robodk.robomath.pose_2_quaternion(Ti)

Returns the quaternion orientation vector of a pose (4x4 matrix)

Parameters

Ti (Mat) – pose

robodk.robomath.pose_2_xyzrpw(H)

Calculates the equivalent position (mm) and Euler angles (deg) as an [x,y,z,r,p,w] array, given a pose. It returns the values that correspond to the following operation: transl(x,y,z)*rotz(w*pi/180)*roty(p*pi/180)*rotx(r*pi/180)

Parameters

H (Mat) – pose

Returns

[x,y,z,w,p,r] in mm and deg

robodk.robomath.pose_angle(pose)

Returns the angle in radians of a 4x4 matrix pose

Parameters

pose (Mat) – pose

robodk.robomath.pose_angle_between(pose1, pose2)

Returns the angle in radians between two poses (4x4 matrix pose)

robodk.robomath.pose_is_similar(a, b, tolerance=0.1)

Check if the pose is similar. Returns True if both poses are less than 0.1 mm or 0.1 deg appart. Optionally provide the tolerance in mm+deg

robodk.robomath.print_pose_ABB(pose)

Displays an ABB RAPID target (the same way it is displayed in IRC5 controllers).

Parameters

pose (Mat) – pose

robodk.robomath.proj_pt_2_line(point, paxe, vaxe)

Projects a point to a line

robodk.robomath.proj_pt_2_plane(point, planepoint, planeABC)

Projects a point to a plane

robodk.robomath.quaternion_2_pose(qin)

Returns the pose orientation matrix (4x4 matrix) given a quaternion orientation vector

Parameters

qin (list) – quaternions as 4 float values

robodk.robomath.rotx(rx)

Returns a rotation matrix around the X axis (radians)

R_x(\theta) = \begin{bmatrix} 1 & 0 & 0 & 0 \\
0 & c_\theta & -s_\theta & 0 \\
0 & s_\theta & c_\theta & 0 \\
0 & 0 & 0 & 1
\end{bmatrix}

Parameters

rx (float) – rotation around X axis in radians

robodk.robomath.roty(ry)

Returns a rotation matrix around the Y axis (radians)

R_y(\theta) = \begin{bmatrix} c_\theta & 0 & s_\theta & 0 \\
0 & 1 & 0 & 0 \\
-s_\theta & 0 & c_\theta & 0 \\
0 & 0 & 0 & 1
\end{bmatrix}

Parameters

ry (float) – rotation around Y axis in radians

robodk.robomath.rotz(rz)

Returns a rotation matrix around the Z axis (radians)

R_x(\theta) = \begin{bmatrix} c_\theta & -s_\theta & 0 & 0 \\
s_\theta & c_\theta & 0 & 0 \\
0 & 0 & 1 & 0 \\
0 & 0 & 0 & 1
\end{bmatrix}

Parameters

ry (float) – rotation around Y axis in radians

robodk.robomath.sin(value)

Returns the sine of an angle in radians

robodk.robomath.size(matrix, dim=None)

Returns the size of a matrix (m,n). Dim can be set to 0 to return m (rows) or 1 to return n (columns)

Parameters
  • matrix (Mat) – pose

  • dim (int) – dimension

robodk.robomath.sqrt(value)

Returns the square root of a value

robodk.robomath.sqrtA(value)

Returns the square root of a value if it’s greater than 0, else 0 (differs from IEEE-754).

robodk.robomath.subs3(a, b)

Subtracts two 3D vectors c=a-b

robodk.robomath.tic()

Start a stopwatch timer

robodk.robomath.toc()

Read the stopwatch timer

robodk.robomath.tr(matrix)

Returns the transpose of the matrix

Parameters

matrix (Mat) – pose

robodk.robomath.transl(tx, ty=None, tz=None)

Returns a translation matrix (mm)

T(t_x, t_y, t_z) = \begin{bmatrix} 1 & 0 & 0 & t_x \\
0 & 1 & 0 & t_y \\
0 & 0 & 1 & t_z \\
0 & 0 & 0 & 1
\end{bmatrix}

Parameters
  • tx (float) – translation along the X axis

  • ty (float) – translation along the Y axis

  • tz (float) – translation along the Z axis

See also

rotx(), roty(), rotz()

robodk.robomath.xyzrpw_2_pose(xyzrpw)

Calculates the pose from the position (mm) and Euler angles (deg), given a [x,y,z,r,p,w] array. The result is the same as calling: H = transl(x,y,z)*rotz(w*pi/180)*roty(p*pi/180)*rotx(r*pi/180)

2.3. robodialogs.py

The robodialogs sub-module is a dialogs toolbox. It contains, open and save file dialogs, message prompts, etc.

robodk.robodialogs.ShowMessage(msg, title=None)

Show a blocking message

robodk.robodialogs.ShowMessageYesNo(msg, title=None)

Show a blocking message and let the user answer Yes or No

robodk.robodialogs.ShowMessageYesNoCancel(msg, title=None)

Show a blocking message and let the user answer Yes, No or Cancel

robodk.robodialogs.getOpenFile(path_preference='C:/RoboDK/Library/', strfile='', strtitle='Open file ...', defaultextension='.txt', filetypes=[('All files', '.*'), ('Text files', '.txt')])

Pop up a file dialog window to select a file to open. Returns a file object opened in read-only mode. Use returned value.name to retrieve the file path.

robodk.robodialogs.getOpenFileName(path_preference='C:/RoboDK/Library/', strfile='', strtitle='Open file ...', defaultextension='.txt', filetypes=[('All files', '.*'), ('Text files', '.txt')])

Pop up a file dialog window to select a file to open. Returns the file path as a string.

robodk.robodialogs.getOpenFolder(path_preference='C:/RoboDK/Library/', strtitle='Open folder ...')

Pop up a folder dialog window to select a folder to open. Returns the path of the folder as a string.

robodk.robodialogs.getSaveFile(path_preference='C:/RoboDK/Library/', strfile='file.txt', strtitle='Save file as ...', defaultextension='.txt', filetypes=[('All files', '.*'), ('Text files', '.txt')])

Pop up a file dialog window to select a file to save. Returns a file object opened in write-only mode. Use returned value.name to retrieve the file path.

robodk.robodialogs.getSaveFileName(path_preference='C:/RoboDK/Library/', strfile='file.txt', strtitle='Save file as ...', defaultextension='.txt', filetypes=[('All files', '.*'), ('Text files', '.txt')])

Pop up a file dialog window to select a file to save. Returns the file path as a string.

robodk.robodialogs.getSaveFolder(path_programs='/', popup_msg='Select a directory to save your program')

Ask the user to select a folder to save a program or other file. Returns the path of the folder as a string.

robodk.robodialogs.mbox(msg, b1='OK', b2='Cancel', frame=True, t=False, entry=None)

Create an instance of MessageBox, and get data back from the user.

Parameters
  • msg (str) – string to be displayed

  • b1 (str, tuple) – left button text, or a tuple (<text for button>, <to return on press>)

  • b2 (str, tuple) – right button text, or a tuple (<text for button>, <to return on press>)

  • frame (bool) – include a standard outerframe: True or False

  • t (int, float) – time in seconds (int or float) until the msgbox automatically closes

  • entry (None, bool, str) – include an entry widget that will provide its contents returned. Provide text to fill the box

Example:

name = mbox('Enter your name', entry=True)
name = mbox('Enter your name', entry='default')
if name:
    print("Value: " + name)

value = mbox('Male or female?', ('male', 'm'), ('female', 'f'))
mbox('Process done')

2.4. robofileio.py

The robofileio sub-module is a file operation toolbox. It contains file properties, CSV exporter, FTP, etc.

robodk.robofileio.DateCreated(filepath, stringformat=False)

Returns the time that a file was modified

robodk.robofileio.DateModified(filepath, stringformat=False)

Returns the time that a file was modified

robodk.robofileio.DirExists(folder)

Returns true if the folder exists

robodk.robofileio.FileExists(file)

Returns true if the file exists

robodk.robofileio.FilterName(namefilter, safechar='P', reserved_names=None)

Get a safe program or variable name that can be used for robot programming

robodk.robofileio.LoadList(strfile, separator=',', codec='utf-8')

Load data from a CSV file or a TXT file to a Python list (list of list of numbers)

Example:

csvdata = LoadList(strfile, ',')
values = []
for i in range(len(csvdata)):
    print(csvdata[i])
    values.append(csvdata[i])

# We can also save the list back to a CSV file
# SaveList(csvdata, strfile, ',')
robodk.robofileio.LoadMat(strfile, separator=',')

Load data from a CSV file or a TXT file to a Mat Matrix

See also

LoadList()

robodk.robofileio.RemoveDirFTP(ftp, path)

Recursively delete a directory tree on a remote server.

robodk.robofileio.RemoveFileFTP(ftp, filepath)

Delete a file on a remote server.

robodk.robofileio.SaveList(list_variable, strfile, separator=',')

Save a list or a list of lists as a CSV or TXT file.

robodk.robofileio.UploadDirFTP(localpath, server_ip, remote_path, username, password)

Upload a folder to a robot through FTP recursively

robodk.robofileio.UploadFTP(program, robot_ip, remote_path, ftp_user, ftp_pass, pause_sec=2)

Upload a program or a list of programs to the robot through FTP provided the connection parameters

robodk.robofileio.UploadFileFTP(file_path_name, server_ip, remote_path, username, password)

Upload a file to a robot through FTP

robodk.robofileio.getBaseName(filepath)

Returns the file name and extension of a file path

robodk.robofileio.getFileDir(filepath)

Returns the directory of a file path

robodk.robofileio.getFileName(filepath)

Returns the file name (with no extension) of a file path

robodk.robofileio.searchfiles(pattern='C:\\RoboDK\\Library\\*.rdk')

List the files in a directory with a given extension

2.5. roboapps.py

The roboapps sub-module is a RoboDK Apps toolbox. More info here: https://github.com/RoboDK/Plug-In-Interface/tree/master/PluginAppLoader

Warning

The roboapps sub-module is specific to the Python API.

App/actions control utilities.

Use these to control your App’s actions: run on click, run while checked, do not kill, etc.

class robodk.roboapps.AppSettings(settings_param='App-Settings')

Generic application settings class to save and load settings to a RoboDK station with a built-in UI.

CopyFrom(other)

Copy settings from another instance

Load(rdk=None)

Load the class attributes from a RoboDK binary parameter

Save(rdk=None, autorecover=False)

Save the class attributes as a RoboDK binary parameter

ShowUI(windowtitle='Settings', embed=False, wparent=None, callback_frame=None)

Show the Apps Settings in a GUI, using tkinter or Qt depending on availability.

get(attrib, default_value=None)

Get attribute value by key, otherwise it returns None

getAttribs()

Get the list of attributes

robodk.roboapps.Checked()

Verify if the command “Checked” is present. In this case it means the action was just checked from RoboDK (applicable to checkable actions only).

robodk.roboapps.KeepChecked()

Keep an action checked even if the execution of the script completed (this is applicable to Checkable actions only)

robodk.roboapps.Registry(varname, setvalue=None)

Read value from the registry or set a value. It will do so at HKEY_CURRENT_USER so no admin rights required.

class robodk.roboapps.RunApplication(rdk=None)

Class to detect when the terminate signal is emitted to stop an action.

run = RunApplication()
while run.Run():
    # your main loop to run until the terminate signal is detected
    ...
Run()

Run callback.

Returns

True as long as the App is permitted to run.

Return type

bool

robodk.roboapps.SkipKill()

For Checkable actions, this setting will tell RoboDK App loader to not kill the process a few seconds after the terminate function is called. This is needed if we want the user input to save the file. For example: The Record action from the Record App.

robodk.roboapps.Str2FloatList(str_values, expected_nvalues=3)

Convert a string into a list of values. It returns None if the array is smaller than the expected size.

robodk.roboapps.Unchecked()

Verify if the command “Unchecked” is present. In this case it means the action was just unchecked from RoboDK (applicable to checkable actions only).

robodk.roboapps.get_robodk_theme(RDK=None)

Get RoboDK’s active theme (Options->General->Theme)

robodk.roboapps.set_qt_theme(app, RDK=None)

Set a Qt application theme to match RoboDK’s theme.

robodk.roboapps.value_to_qt_widget(value)

Get a Qt Widget based on a value. For instance, a float into a QDoubleSpinBox, a bool into a QCheckBox. Returns a widget and a function to retrieve the widget’s value.

robodk.roboapps.value_to_tk_widget(value, frame)

Get a Tkinter Widget based on a value. For instance, a float into a Spinbox, a bool into a Checkbutton. Returns a widget and a function to retrieve the widget’s value.

2.6. robolinkutils.py

The robolinkutils sub-module provides utility functions using the Robolink module.

Warning

The robolinkutils sub-module is specific to the Python API.

robodk.robolinkutils.getAncestorPose(item_child, item_parent)

Gets the pose between two Items that have a hierarchical relationship in the Station’s tree. There can be N Items between the two.

Parameters
  • item_child (Item) – The child Item

  • item_parent (Item) – The parent Item

Returns

The pose from the child to the parent

Return type

robomath.Mat

robodk.robolinkutils.getAncestors(item, parent_types=None)

Get the list of parents of an Item up to the Station, with type filtering (i.e. [ITEM_TYPE_FRAME, ITEM_TYPE_ROBOT, ..]). By default, it will return all parents of an Item with no regard to their type, ordered from the Item’s parent to the Station.

Parameters
  • item (Item) – The source Item

  • parent_types (list of ITEM_TYPE_*, optional) – The parent allowed types, such as ITEM_TYPE_FRAME, defaults to None

Returns

A list of parents, ordered from the Item’s parent to the Station.

Return type

list of Item

robodk.robolinkutils.getLowestCommonAncestor(item1, item2)

Finds the lowest common ancestor (LCA) between two Items in the Station’s tree.

Parameters
  • item1 (Item) – The first Item

  • item2 (Item) – The second Item

Returns

The lowest common ancestor (LCA)

Return type

Item

robodk.robolinkutils.getPoseWrt(item1, item2)

Gets the pose of an Item (item1) with respect to an another Item (item2).

Parameters
  • item1 (robolink.Item) – The source Item

  • item2 (robolink.Item) – The second Item

Returns

The pose from the source Item to the second Item

Return type

robomath.Mat