Table of Contents

Class RoboDK

Namespace
RoboDk.API
Assembly
RoboDkApi.dll

The RoboDK API class is the link that allows you to communicate with RoboDK. Any interaction is made through "items" (IItem() objects). An item is an object in the RoboDK tree (it can be either a robot, an object, a tool, a frame, a program, ...).

public class RoboDK : IRoboDK, IDisposable
Inheritance
RoboDK
Implements
Inherited Members

Constructors

RoboDK()

Creates a link with RoboDK

public RoboDK()

Fields

FILE_OPENSTATION

public const string FILE_OPENSTATION = "FILE_OPENSTATION"

Field Value

string

PATH_DESKTOP

public const string PATH_DESKTOP = "PATH_DESKTOP"

Field Value

string

PATH_OPENSTATION

public const string PATH_OPENSTATION = "PATH_OPENSTATION"

Field Value

string

Properties

ApiVersion

RoboDK API protocol version.

public int ApiVersion { get; }

Property Value

int

ApplicationDir

Filepath to the RoboDK.exe. Typically C:/RoboDK/bin/RoboDK.exe. Leave empty to use the registry key: HKEY_LOCAL_MACHINE\SOFTWARE\RoboDK

public string ApplicationDir { get; set; }

Property Value

string

AutoUpdate

If AUTO_UPDATE is 1, updating and rendering objects the 3D the scene will be delayed until 100 ms after the last call. This value can be changed in Tools-Options-Other-API Render delay, or using the RoboDK.Command('AutoRenderDelay', value) and RoboDK.Command('AutoRenderDelayMax', value)

public bool AutoUpdate { get; set; }

Property Value

bool

CustomCommandLineArgumentString

The custom command line options will be appended to the standard command line argument string returned by RoboDkCommandLineParameter.CommandLineArgumentString. See https://robodk.com/doc/en/RoboDK-API.html#CommandLine

public string CustomCommandLineArgumentString { get; set; }

Property Value

string

DefaultApiServerPort

public int DefaultApiServerPort { get; }

Property Value

int

DefaultSocketTimeoutMilliseconds

Default Socket send / receive timeout in milliseconds: 10 seconds

public int DefaultSocketTimeoutMilliseconds { get; set; }

Property Value

int

DoNotUseRecentlyUsedFileList

public bool DoNotUseRecentlyUsedFileList { get; set; }

Property Value

bool

DoNotUseSettingsFile

public bool DoNotUseSettingsFile { get; set; }

Property Value

bool

EventChannelVersion

RoboDK Event protocol version.

public int EventChannelVersion { get; set; }

Property Value

int

ExitRoboDkAfterClosingLastApiConnection

public bool ExitRoboDkAfterClosingLastApiConnection { get; set; }

Property Value

bool

Hidden

public bool Hidden { get; set; }

Property Value

bool

HideReferenceFrames

public bool HideReferenceFrames { get; set; }

Property Value

bool

HideWindowWhileLoadingFiles

public bool HideWindowWhileLoadingFiles { get; set; }

Property Value

bool

HideWindowsWhileLoadingNcFile

public bool HideWindowsWhileLoadingNcFile { get; set; }

Property Value

bool

ItemInterceptFunction

Allows to install a function which can intercept all interface methods. Used for Aspect oriented programming (e.g. Add loging to an Interface). Example: rdk.InterceptorFunction = ItemInterceptorFunction; private IItem ItemInterceptorFunction(IItem item) { var behaviour = new LoggingAspect(_logger); var itemProxy = Unitity.Interception.Intercept.ThroughProxy(item, new InterfaceInterceptor(), new[] {behaviour}); return itemProxy; }

public Func<IItem, IItem> ItemInterceptFunction { get; set; }

Property Value

Func<IItem, IItem>

LastStatusMessage

public string LastStatusMessage { get; set; }

Property Value

string

LoadSettingsFromFile

public string LoadSettingsFromFile { get; set; }

Property Value

string

Logfile

public string Logfile { get; set; }

Property Value

string

Name

Name of the RoboDK instance. In case of multiple instances the name can help to identify the instance.

public string Name { get; set; }

Property Value

string

NoCommunicationToRoboDkServer

public bool NoCommunicationToRoboDkServer { get; set; }

Property Value

bool

NoDebugOutput

public bool NoDebugOutput { get; set; }

Property Value

bool

NoSplash

public bool NoSplash { get; set; }

Property Value

bool

NoUserInterface

public bool NoUserInterface { get; set; }

Property Value

bool

Process

RoboDK.exe process.

public Process Process { get; }

Property Value

Process

RoboDKBuild

The RoboDK build id and is used for version checking. This value always increases with new versions

public int RoboDKBuild { get; set; }

Property Value

int

RoboDKClientPort

TCP Client Port

public int RoboDKClientPort { get; }

Property Value

int

RoboDKServerEndPort

Port to stop looking for a RoboDK connection.

public int RoboDKServerEndPort { get; set; }

Property Value

int

RoboDKServerIpAddress

Defines the RoboDK Simulator IP Address. Default: localhost (Client and RoboDK Server runs on same computer)

public string RoboDKServerIpAddress { get; set; }

Property Value

string

RoboDKServerPort

TCP Server Port to which this instance is connected to.

public int RoboDKServerPort { get; }

Property Value

int

RoboDKServerStartPort

Port to start looking for a RoboDK connection.

public int RoboDKServerStartPort { get; set; }

Property Value

int

SafeMode

If True checks that provided items exist in memory and poses are homogeneous

public bool SafeMode { get; set; }

Property Value

bool

StartHidden

public bool StartHidden { get; set; }

Property Value

bool

StartNewInstance

public bool StartNewInstance { get; set; }

Property Value

bool

TreeState

public int TreeState { get; set; }

Property Value

int

Methods

AddCurve(Mat, IItem, bool, ProjectionType)

Adds a curve provided point coordinates. The provided points must be a list of vertices. A vertex normal can be provided optionally.

public IItem AddCurve(Mat curvePoints, IItem referenceObject = null, bool addToRef = false, ProjectionType projectionType = ProjectionType.AlongNormalRecalc)

Parameters

curvePoints Mat

matrix 3xN or 6xN -> N must be multiple of 3

referenceObject IItem

object to add the curve and/or project the curve to the surface

addToRef bool

If True, the curve will be added as part of the object in the RoboDK item tree (a reference object must be provided)

projectionType ProjectionType

Type of projection. For example: ProjectionType.AlongNormalRecalc will project along the point normal and recalculate the normal vector on the surface projected.

Returns

IItem

added object/curve (use item.Valid() to check if item is valid.)

AddFile(string, IItem)

Load a file and attaches it to parent and returns the newly added IItem.

public IItem AddFile(string filename, IItem parent = null)

Parameters

filename string

Any file to load, supported by RoboDK. Supported formats include STL, STEP, IGES, ROBOT, TOOL, RDK,... It is also possible to load supported robot programs, such as SRC (KUKA), SCRIPT (Universal Robots), LS (Fanuc), JBI (Motoman), MOD (ABB), PRG (ABB), ...

parent IItem

item to attach the newly added object (optional)

Returns

IItem

AddFrame(string, IItem)

Adds a new Frame that can be referenced by a robot.

public IItem AddFrame(string name, IItem parent = null)

Parameters

name string

name of the reference frame

parent IItem

parent to attach to (such as the robot base frame)

Returns

IItem

The new reference frame created

AddMachiningProject(string, IItem)

Add a new robot machining project. Machining projects can also be used for 3D printing, following curves and following points. It returns the newly created :class:.IItem containing the project settings. Tip: Use the macro /RoboDK/Library/Macros/MoveRobotThroughLine.py to see an example that creates a new "curve follow project" given a list of points to follow(Option 4).

public IItem AddMachiningProject(string name = "Curve follow settings", IItem itemrobot = null)

Parameters

name string

Name of the project settings

itemrobot IItem

Robot to use for the project settings(optional). It is not required to specify the robot if only one robot or mechanism is available in the RoboDK station.

Returns

IItem

AddPoints(Mat, IItem, bool, ProjectionType)

Adds a list of points to an object. The provided points must be a list of vertices. A vertex normal can be provided optionally.

public IItem AddPoints(Mat points, IItem referenceObject = null, bool addToRef = false, ProjectionType projectionType = ProjectionType.AlongNormalRecalc)

Parameters

points Mat

list of points as a matrix (3xN matrix, or 6xN to provide point normals as ijk vectors)

referenceObject IItem

item to attach the newly added geometry (optional)

addToRef bool

If True, the points will be added as part of the object in the RoboDK item tree (a reference object must be provided)

projectionType ProjectionType

Type of projection.Use the PROJECTION_* flags.

Returns

IItem

added object/shape (0 if failed)

AddProgram(string, IItem)

Add a new program to the RoboDK station. Programs can be used to simulate a specific sequence, to generate vendor specific programs (Offline Programming) or to run programs on the robot (Online Programming).

public IItem AddProgram(string name, IItem robot = null)

Parameters

name string

Name of the program

robot IItem

Robot that will be used for this program. It is not required to specify the robot if the station has only one robot or mechanism.

Returns

IItem

Newly created Program IItem

AddShape(Mat, IItem, bool, Color?)

Adds a shape provided triangle coordinates. Triangles must be provided as a list of vertices. A vertex normal can be provided optionally.

public IItem AddShape(Mat trianglePoints, IItem addTo = null, bool shapeOverride = false, Color? color = null)

Parameters

trianglePoints Mat

List of vertices grouped by triangles (3xN or 6xN matrix, N must be multiple of 3 because vertices must be stacked by groups of 3)

addTo IItem

item to attach the newly added geometry (optional). Leave empty to create a new object.

shapeOverride bool

Set to true to replace any other existing geometry

color Color?

Color of the added shape

Returns

IItem

added object/shape (use item.Valid() to check if item is valid.)

AddShape(List<Mat>, IItem, bool, List<Color>)

Adds a shape provided triangle coordinates. Triangles must be provided as a list of vertices. A vertex normal can be provided optionally.

public IItem AddShape(List<Mat> listTrianglePoints, IItem add_to = null, bool shape_override = false, List<Color> listColor = null)

Parameters

listTrianglePoints List<Mat>

List of Mat objects. Each mat object is a list of vertices grouped by triangles of the same color (3xN or 6xN matrix, N must be multiple of 3 because vertices must be stacked by groups of 3)

add_to IItem
shape_override bool
listColor List<Color>

Optionally specify the color as RGBA [0-1] (list of same length as triangle_points_list)

Returns

IItem

AddStation(string)

Add a new empty station.

public IItem AddStation(string name)

Parameters

name string

Name of the station

Returns

IItem

Newly created station IItem

AddTarget(string, IItem, IItem)

Add a new target that can be reached with a robot.

public IItem AddTarget(string name, IItem parent = null, IItem robot = null)

Parameters

name string

Target name

parent IItem

Reference frame to attach the target

robot IItem

Robot that will be used to go to target (optional)

Returns

IItem

Newly created target item.

AddTargetJ(IItem, string, double[], IItem, IItem)

Add a joint movement to a program

public IItem AddTargetJ(IItem pgm, string targetName, double[] joints, IItem robotBase = null, IItem robot = null)

Parameters

pgm IItem
targetName string
joints double[]
robotBase IItem
robot IItem

Returns

IItem

New target item created.

AddText(string, IItem)

Add Text to 3D View

public IItem AddText(string text, IItem parent = null)

Parameters

text string

Text to add to the scene

parent IItem

item to attach the newly added text object (optional)

Returns

IItem

BuildMechanism(int, List<IItem>, List<double>, List<double>, List<double>, List<double>, List<double>, List<double>, Mat, Mat, string, IItem)

Create a new robot or mechanism.

public IItem BuildMechanism(int type, List<IItem> listObj, List<double> param, List<double> jointsBuild, List<double> jointsHome, List<double> jointsSenses, List<double> jointsLimLow, List<double> jointsLimHigh, Mat baseFrame = null, Mat tool = null, string name = "New robot", IItem robot = null)

Parameters

type int

Type of the mechanism

listObj List<IItem>
param List<double>

robot parameters in the same order as shown in the RoboDK menu: Utilities-Build Mechanism or robot

jointsBuild List<double>
jointsHome List<double>
jointsSenses List<double>
jointsLimLow List<double>
jointsLimHigh List<double>
baseFrame Mat
tool Mat

tool pose

name string

robot name (you can also use setName()

robot IItem

existing robot in the station to replace it (optional)

Returns

IItem

CalibrateReference(Mat, ReferenceCalibrationType, bool, IItem)

Calibrate a Reference Frame given a list of points or joint values. Important: If the robot is calibrated, provide joint values to maximize accuracy.

public Mat CalibrateReference(Mat joints, ReferenceCalibrationType method = ReferenceCalibrationType.Frame3P_P1OnX, bool useJoints = false, IItem robot = null)

Parameters

joints Mat

points as a 3xN matrix or nDOFsxN) - List of points or a list of robot joints

method ReferenceCalibrationType

type of algorithm(by point, plane, ...)

useJoints bool

use points or joint values. The robot item must be provided if joint values is used.

robot IItem

Returns

Mat

TODO: Document return value.

CalibrateTool(Mat, out double[], EulerType, TcpCalibrationType, IItem)

Calibrate a tool (TCP) given a number of points or calibration joints. Important: If the robot is calibrated, provide joint values to maximize accuracy.

public double[] CalibrateTool(Mat posesJoints, out double[] errorStats, EulerType format = EulerType.EulerRxRyRz, TcpCalibrationType algorithm = TcpCalibrationType.CalibrateTcpByPoint, IItem robot = null)

Parameters

posesJoints Mat

matrix of poses in a given format or a list of joints

errorStats double[]

stats[mean, standard deviation, max] - Output error stats summary

format EulerType

Euler format. Optionally, use EulerType.JointFormat and provide the robot.

algorithm TcpCalibrationType

type of algorithm (by point, plane, ...)

robot IItem

Robot used for calibration (if using joint values)

Returns

double[]

TCP as [x, y, z] - calculated TCP

Cam2DAdd(IItem, string)

Open a simulated 2D camera view. Returns a handle pointer that can be used in case more than one simulated view is used.

public long Cam2DAdd(IItem item, string cameraParameters = "")

Parameters

item IItem

Reference frame or other object to attach the camera

cameraParameters string

Camera parameters as a string. Refer to the documentation for more information.

Returns

long

Camera pointer/handle. Keep the handle if more than 1 simulated camera is used

Cam2DClose(long)

Closes all camera windows or one specific camera if the camera handle is provided.

public bool Cam2DClose(long camHandle = 0)

Parameters

camHandle long

Camera handle(pointer returned by Cam2DAdd). Leave to 0 to close all simulated views.

Returns

bool

Returns true if success, false otherwise.

Cam2DSetParameters(string, long)

Set the parameters of the simulated camera.

public bool Cam2DSetParameters(string cameraParameters, long camHandle = 0)

Parameters

cameraParameters string

parameter settings according to the parameters supported by Cam2D_Add

camHandle long

camera handle (optional)

Returns

bool

Returns true if success, false otherwise.

Cam2DSnapshot(string, IItem, string)

Take a snapshot from a simulated camera view and save it to a file.

public bool Cam2DSnapshot(string fileSaveImg, IItem cam, string cameraParameters = "")

Parameters

fileSaveImg string

file path to save.Formats supported include PNG, JPEG, TIFF, ...

cam IItem

Camera handle(pointer returned by Cam2DAdd)

cameraParameters string

Camera parameters as a string. Refer to the documentation for more information.

Returns

bool

Returns true if image has been saved successfully.

Cam2DSnapshot(string, long)

Take a snapshot from a simulated camera view and save it to a file.

public bool Cam2DSnapshot(string fileSaveImg, long camHandle = 0)

Parameters

fileSaveImg string

file path to save.Formats supported include PNG, JPEG, TIFF, ...

camHandle long

Camera handle(pointer returned by Cam2DAdd)

Returns

bool

Returns true if image has been saved successfully.

CloneRoboDkConnection(ConnectionType)

Open a new additional RoboDK Link to the same already existing RoboDK instance. NOTE: Use IItem.Clone() to use an already existing item on the new RoboDk connection.

public IRoboDK CloneRoboDkConnection(RoboDK.ConnectionType connectionType = ConnectionType.Api)

Parameters

connectionType RoboDK.ConnectionType

Returns

IRoboDK

New RoboDK Link

CloseRoboDK()

Close RoboDK window and finish RoboDK process.

public void CloseRoboDK()

CloseStation()

Closes the current station without suggesting to save

public void CloseStation()

Collision(IItem, IItem, bool)

Check if item1 and item2 collided.

public bool Collision(IItem item1, IItem item2, bool useCollisionMap = true)

Parameters

item1 IItem
item2 IItem
useCollisionMap bool

Turn off collision map check to force collision checking even if it is not set in the collision map

Returns

bool

Returns true if item1 collides with item2; false otherwise.

CollisionLine(double[], double[])

Checks the collision between a line and any objects in the station. The line is composed by 2 points.

public bool CollisionLine(double[] p1, double[] p2)

Parameters

p1 double[]

Start point [x,y,z] of the line

p2 double[]

End point [x,y,z] of the line

Returns

bool

Return true if there is a collision; false otherwise

CollisionLine(double[], double[], Mat)

Checks the collision between a line and any objects in the station. The line is composed by 2 points.

public CollisionLineResult CollisionLine(double[] p1, double[] p2, Mat reference = null)

Parameters

p1 double[]

Start point [x,y,z] of the line

p2 double[]

End point [x,y,z] of the line

reference Mat

Reference of the two points with respect to the absolute station reference

Returns

CollisionLineResult

Return CollisionLineResult with collision object and point of collision

Collisions()

Returns the number of pairs of objects that are currently in a collision state.

public int Collisions()

Returns

int

Number of pairs of objects in a collision state.

Color2Hex(Color)

public static string Color2Hex(Color color)

Parameters

color Color

Returns

string

Command(string, bool)

Send a special command. These commands are meant to have a specific effect in RoboDK, such as changing a specific setting or provoke specific events.

public string Command(string cmd, bool value)

Parameters

cmd string

Command Name, such as Trace, Threads or Window.

value bool

Command value

Returns

string

Command(string, double)

Send a special command. These commands are meant to have a specific effect in RoboDK, such as changing a specific setting or provoke specific events.

public string Command(string cmd, double value)

Parameters

cmd string

Command Name, such as Trace, Threads or Window.

value double

Command value

Returns

string

Command(string, int)

Send a special command. These commands are meant to have a specific effect in RoboDK, such as changing a specific setting or provoke specific events.

public string Command(string cmd, int value)

Parameters

cmd string

Command Name, such as Trace, Threads or Window.

value int

Command value

Returns

string

Command(string, string)

Send a special command. These commands are meant to have a specific effect in RoboDK, such as changing a specific setting or provoke specific events.

public string Command(string cmd, string value = "")

Parameters

cmd string

Command Name, such as Trace, Threads or Window.

value string

Comand value (optional, not all commands require a value)

Returns

string

Connect()

Establish a connection with RoboDK. If RoboDK is not running it will attempt to start RoboDK from the default installation path. (otherwise APPLICATION_DIR must be set properly).

public bool Connect()

Returns

bool

If the connection succeeds it returns True, otherwise it returns False.

Connected()

Checks if the RoboDK Link is connected.

public bool Connected()

Returns

bool

True if connected; False otherwise

Copy(IItem, bool)

Makes a copy of an item (same as Ctrl+C), which can be pasted (Ctrl+V) using Paste().

public void Copy(IItem tocopy, bool copy_children = true)

Parameters

tocopy IItem

Item to copy

copy_children bool

Set to false to prevent copying all items attached to this item

Delete(List<IItem>)

Delete a list of items

public void Delete(List<IItem> item_list)

Parameters

item_list List<IItem>

DisableCollisionCheckingForAllItems()

Set all pairs as NOT checking for collisions:

public void DisableCollisionCheckingForAllItems()

Disconnect()

Stops the communication with RoboDK. If setRunMode is set to MakeRobotProgram for offline programming, any programs pending will be generated.

public void Disconnect()

Dispose()

public void Dispose()

Dispose(bool)

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

EmbedWindow(string, string, int, int, int, int, int, int)

Embed a window from a separate process in RoboDK as a docked window

public bool EmbedWindow(string windowName, string dockedName = null, int width = -1, int height = -1, int pid = 0, int areaAdd = 1, int areaAllowed = 15, int timeout = 500)

Parameters

windowName string

The name of the window currently open. Make sure the window name is unique and it is a top level window

dockedName string

Name of the docked tab in RoboDK (optional, if different from the window name)

width int
height int
pid int

Process ID (optional)

areaAdd int

Set to 1 (right) or 2 (left) (default is 1)

areaAllowed int

Areas allowed (default is 15: no constrain)

timeout int

Timeout to abort attempting to embed the window (optional)

Returns

bool

Returns true if successful.

EnableCollisionCheckingForAllItems()

Set all pairs as checking for collisions:

public void EnableCollisionCheckingForAllItems()

FitAll()

Fit all

public void FitAll()

GetActiveStation()

Returns the active station item (station currently visible)

public IItem GetActiveStation()

Returns

IItem

GetBinaryParameter(string)

Gets a global or a user binary parameter from the open RoboDK station

public byte[] GetBinaryParameter(string parameter)

Parameters

parameter string

RoboDK parameter

Returns

byte[]

Arrray of bytes.

GetCollisionItems()

Return the list of items that are in a collision state. This call will run a check for collisions if collision checking is not activated (if SetCollisionActive is set to Off).

public List<CollisionItem> GetCollisionItems()

Returns

List<CollisionItem>

List of items that are in a collision state

GetCollisionPairs()

Returns the list of pairs of items that are in a collision state. This call will run a check for collisions if collision checking is not activated (if SetCollisionActive is set to Off).

public List<CollisionPair> GetCollisionPairs()

Returns

List<CollisionPair>

GetCursorXYZ(int, int, List<double>)

Returns the position of the cursor as XYZ coordinates (by default), or the 3D position of a given set of 2D coordinates of the window (x and y coordinates in pixels from the top left corner) The XYZ coordinates returned are given with respect to the RoboDK station(absolute reference). If no coordinates are provided, the current position of the cursor is retrieved.

public IItem GetCursorXYZ(int xCoord = -1, int yCoord = -1, List<double> xyzStation = null)

Parameters

xCoord int

X coordinate in pixels

yCoord int

Y coordinate in pixels

xyzStation List<double>

XYZ coordinates in mm (absolute coordinates)

Returns

IItem

Item under the mouse cursor.

GetItemByName(string, ItemType)

Returns an item by its name. If there is no exact match it will return the last closest match. Specify what type of item you are looking for with itemtype. This is useful if 2 items have the same name but different type.

public IItem GetItemByName(string name, ItemType itemType = ItemType.Any)

Parameters

name string

name of the item (name of the item shown in the RoboDK station tree)

itemType ItemType

type of the item to be retrieved (avoids confusion if there are similar name matches).

Returns

IItem

Returns an item by its name.

GetItemFlags(IItem)

Retrieve current item flags. Item flags allow defining how much access the user has to item-specific features.

public ItemFlags GetItemFlags(IItem item)

Parameters

item IItem

Item to get flags

Returns

ItemFlags

Returns ItemFlags of the item.

GetItemList(ItemType)

Returns a list of items of all available items in the currently open station in robodk. Optionally, use a filter to return items of a specific type

public List<IItem> GetItemList(ItemType itemType = ItemType.Any)

Parameters

itemType ItemType

Only return items of this type

Returns

List<IItem>

List of Items (optionally filtered by ItemType).

GetItemListNames(ItemType)

Returns a list of items (list of names) of all available items in the currently open station in robodk. Optionally, use a filter to return specific items (example: GetItemListNames(itemType = ItemType.Robot))

public List<string> GetItemListNames(ItemType itemType = ItemType.Any)

Parameters

itemType ItemType

Only return items of this type.

Returns

List<string>

List of item Names

GetLicense()

Returns the license string (as shown in the RoboDK main window)

public string GetLicense()

Returns

string

license string.

GetOpenStation()

Returns the list of open stations in RoboDK

public List<IItem> GetOpenStation()

Returns

List<IItem>

GetParameter(string)

Gets a global or a user parameter from the open RoboDK station. The parameters can also be modified by right clicking the station and selecting "shared parameters" Some available parameters: PATH_OPENSTATION = folder path of the current .stn file FILE_OPENSTATION = file path of the current .stn file PATH_DESKTOP = folder path of the user's folder Other parameters can be added or modified by the user

public string GetParameter(string parameter)

Parameters

parameter string

RoboDK parameter

Returns

string

parameter value. Null if parameter does not exist.

GetParameterList()

Gets all the user parameters from the open RoboDK station. The parameters can also be modified by right clicking the station and selecting "shared parameters" User parameters can be added or modified by the user

public List<KeyValuePair<string, string>> GetParameterList()

Returns

List<KeyValuePair<string, string>>

list of param-value pair

GetPoints(ObjectSelectionType)

Retrieves the object under the mouse cursor

public GetPointsResult GetPoints(ObjectSelectionType featureType = ObjectSelectionType.HoverObjectMesh)

Parameters

featureType ObjectSelectionType

Set to ObjectSelectionType.HoverObjectMesh to retrieve object under the mouse cursor, the selected feature and mesh, or ObjectSelectionType.HoverObject if you don't need the mesh (faster)

Returns

GetPointsResult

Returns GetPointsResult with an object under the mouse cursor, selected feature, feature id, list of points and description.

public RoboDK.IRoboDKLink GetRoboDkLink()

Returns

RoboDK.IRoboDKLink

GetRunMode()

Returns the behavior of the RoboDK API. By default, robodk shows the path simulation for movement instructions (RunMode.Simulate)

public RunMode GetRunMode()

Returns

RunMode

Returns the currently active RunMode.

GetSelectedItems()

Returns the list of items selected (it can be one or more items)

public List<IItem> GetSelectedItems()

Returns

List<IItem>

Returns the list of selected items.

GetSimulationSpeed()

Gets the current simulation speed. A speed if 1 means real-time simulation.

public double GetSimulationSpeed()

Returns

double

Simulation Speed. 1.0=real-time simulation.

GetSimulationTime()

Retrieve the simulation time (in seconds). Time of 0 seconds starts with the first time this function is called. The simulation time changes depending on the simulation speed. The simulation time is usually faster than the real time (5 times by default)

public double GetSimulationTime()

Returns

double

Returns the simulation time in seconds.

GetViewPose(ViewPoseType)

Get the pose of the wold reference frame with respect to the view (camera/screen)

public Mat GetViewPose(ViewPoseType preset = ViewPoseType.ActiveView)

Parameters

preset ViewPoseType

Optionally specify a ViewPoseType to retrieve the pose for a specific view

Returns

Mat

Returns the current view pose.

GetWindowHandle()

Get RoboDK's main window handle

public IntPtr GetWindowHandle()

Returns

IntPtr

HideRoboDK()

Hides the RoboDK window.

public void HideRoboDK()

IsInside(IItem, IItem)

Check if objectInside is inside the objectParent.

public bool IsInside(IItem objectInside, IItem objectParent)

Parameters

objectInside IItem
objectParent IItem

Returns

bool

Returns true if objectInside is inside the objectParent

IsTcpPortFree(int)

public static bool IsTcpPortFree(int tcpPort)

Parameters

tcpPort int

Returns

bool

ItemUserPick(string, ItemType)

Shows a RoboDK popup to select one object from the open station. An item type can be specified to filter desired items. If no type is specified, all items are selectable. The method always returns an IItem. Use item.Valid() to check if the selected item is a valid item. E.g. if the user exits the dialog without selecting an item, the method still returns an item object, but item.Valid() will return False.

public IItem ItemUserPick(string message = "Pick one item", ItemType itemType = ItemType.Any)

Parameters

message string

Message to pop up

itemType ItemType

optionally filter by ItemType

Returns

IItem

User selected item. Use item.Valid() to check if the item is valid

Joints(List<IItem>)

Get Joint positions of all robots defined in the robotItemList.

public List<double[]> Joints(List<IItem> robotItemList)

Parameters

robotItemList List<IItem>

list of robot items

Returns

List<double[]>

list of robot joints (double x nDOF)

JointsConfig(List<IItem>, List<double[]>)

Returns the robot configuration state for a set of robot joints.

public List<double[]> JointsConfig(List<IItem> robotList, List<double[]> jointsList)

Parameters

robotList List<IItem>

list of items

jointsList List<double[]>

array of joints

Returns

List<double[]>

3-array -> configuration status as [REAR, LOWERARM, FLIP]

LaserTrackerMeasure(double[], bool)

Takes a laser tracker measurement with respect to its own reference frame. If an estimate point is provided, the laser tracker will first move to those coordinates.

public double[] LaserTrackerMeasure(double[] estimate, bool search = false)

Parameters

estimate double[]

estimate point [x,y,z]

search bool

If search is True, the tracker will search for a target.

Returns

double[]

Returns the XYZ coordinates of the target (in mm). If the target was not found it retuns a null pointer.

MeasurePose(int, int, List<double>)

Takes a measurement with a 6D measurement device

public MeasurePoseResult MeasurePose(int target = -1, int averageTime = 0, List<double> tipOffset = null)

Parameters

target int

Target type

averageTime int

Take the measurement for a period of time and average the result

tipOffset List<double>

Offet the measurement to the tip

Returns

MeasurePoseResult

Returns MeasurePoseResult with a pose of measured object reference frame, and error values in mm.

MergeItems(List<IItem>)

Merge multiple object items as one. Source objects are not deleted and a new object is created.

public IItem MergeItems(List<IItem> item_list)

Parameters

item_list List<IItem>

Returns

IItem

New item

OpenRoboDkEventChannel()

Start the event communication channel. Use WaitForEvent to wait for a new event.

public IRoboDKEventSource OpenRoboDkEventChannel()

Returns

IRoboDKEventSource

new event channel instance

Paste(IItem)

Paste the copied item as a dependency of another item (same as Ctrl+V). Paste should be used after Copy(). It returns the newly created item.

public IItem Paste(IItem paste_to = null)

Parameters

paste_to IItem

Item to attach the copied item (optional)

Returns

IItem

New item created

Paste(IItem, int)

Paste the copied item as a dependency of another item (same as Ctrl+V). Paste should be used after Copy(). It returns the newly created item.

public List<IItem> Paste(IItem paste_to, int paste_times)

Parameters

paste_to IItem

Item to attach the copied item

paste_times int

Number of times to replicate the copied object

Returns

List<IItem>

New item created

PluginCommand(string, string, string)

Send a specific command to a RoboDK plugin. The command and value (optional) must be handled by your plugin

public string PluginCommand(string pluginName, string command, string value)

Parameters

pluginName string

The plugin name must match the PluginName() implementation in the RoboDK plugin

command string

Specific command handled by your plugin

value string

Specific value (optional) handled by your plugin

Returns

string

Returns the result as a string.

PluginLoad(string, PluginOperation)

Load or unload the specified plugin (path to DLL, dylib or SO file). If the plugin is already loaded it will unload the plugin and reload it. Pass an empty plugin name to reload all plugins

public bool PluginLoad(string pluginName, PluginOperation operation = PluginOperation.Load)

Parameters

pluginName string

The name of the plugin or path (if it is not in the default directory)

operation PluginOperation

Type of operation (load, unload, reload)

Returns

bool

Returns boolean result of operation.

Popup_ISO9283_CubeProgram(IItem)

Show the popup menu to create the ISO9283 path for path accuracy and performance testing

public IItem Popup_ISO9283_CubeProgram(IItem robot = null)

Parameters

robot IItem

Returns

IItem

IS9283 Program

ProgramStart(string, string, string, IItem)

Defines the name of the program when the program is generated. It is also possible to specify the name of the post processor as well as the folder to save the program. This method must be called before any program output is generated (before any robot movement or other instruction).

public int ProgramStart(string progname, string defaultfolder = "", string postprocessor = "", IItem robot = null)

Parameters

progname string

name of the program

defaultfolder string

folder to save the program, leave empty to use the default program folder

postprocessor string

name of the post processor (for a post processor in C:/RoboDK/Posts/Fanuc_post.py it is possible to provide "Fanuc_post.py" or simply "Fanuc_post")

robot IItem

Robot to link

Returns

int

TODO: Document return value.

ProjectPoints(Mat, IItem, ProjectionType)

Projects a point given its coordinates. The provided points must be a list of [XYZ] coordinates. Optionally, a vertex normal can be provided [XYZijk].

public Mat ProjectPoints(Mat points, IItem objectProject, ProjectionType projectionType = ProjectionType.AlongNormalRecalc)

Parameters

points Mat

matrix 3xN or 6xN -> list of points to project

objectProject IItem

object to project

projectionType ProjectionType

Type of projection. For example: ProjectionType.AlongNormalRecalc will project along the point normal and recalculate the normal vector on the surface projected.

Returns

Mat

It returns the projected points as a list of points (empty matrix if failed).

RecentFiles(string)

Return the list of recently opened files

public static List<string> RecentFiles(string extensionFilter = "")

Parameters

extensionFilter string

Returns

List<string>

Render(bool)

Display/render the scene: update the display. This function turns default rendering (rendering after any modification of the station unless alwaysRender is set to true). Use Update to update the internal links of the complete station without rendering (when a robot or item has been moved).

public void Render(bool alwaysRender = false)

Parameters

alwaysRender bool

Set to True to update the screen every time the station is modified (default behavior when Render() is not used).

RoboDKInstallFound()

Check if RoboDK was installed from RoboDK's official installer

public static bool RoboDKInstallFound()

Returns

bool

RoboDKInstallPath()

Return the RoboDK install path according to the registry (saved by RoboDK installer)

public static string RoboDKInstallPath()

Returns

string

RunCode(string, bool)

Adds code to run in the program output. If the program exists it will also run the program in simulate mode.

public int RunCode(string code, bool codeIsFunctionCall = false)

Parameters

code string

program name or code to generate

codeIsFunctionCall bool

Set to True if the provided code corresponds to a function call (same as RunProgram()), if so, RoboDK will handle the syntax when the code is generated for a specific robot.

Returns

int

TODO: Document possible return values.

RunMessage(string, bool)

Shows a message or a comment in the output robot program.

public void RunMessage(string message, bool messageIsComment = false)

Parameters

message string

message or comment to display.

messageIsComment bool

Set to True to generate a comment in the generated code instead of displaying a message on the teach pendant of the robot.

RunProgram(string)

Adds a function call in the program output. RoboDK will handle the syntax when the code is generated for a specific robot. If the program exists it will also run the program in simulate mode.

public int RunProgram(string function)

Parameters

function string

Function name with parameters (if any)

Returns

int

TODO: Document possible return values.

Save(string, IItem)

Save an item to a file. If no item is provided, the open station is saved.

public void Save(string filename, IItem itemsave = null)

Parameters

filename string

absolute path to save the file

itemsave IItem

object or station to save. Leave empty to automatically save the current station.

SetActiveStation(IItem)

Set the active station (project currently visible)

public void SetActiveStation(IItem station)

Parameters

station IItem

station item, it can be previously loaded as an RDK file

SetBinaryParameter(string, byte[])

Sets a global binary parameter from the RoboDK station. If the parameters exists, it will be modified. If not, it will be added to the station. The parameters can also be modified by right clicking the station and selecting "shared parameters"

public void SetBinaryParameter(string parameter, byte[] data)

Parameters

parameter string

RoboDK parameter name

data byte[]

Parameter binary data

SetCollisionActive(CollisionCheckOptions)

Set collision checking ON or OFF (CollisionCheckOff/CollisionCheckOn) according to the collision map. If collision check is activated it returns the number of pairs of objects that are currently in a collision state.

public int SetCollisionActive(CollisionCheckOptions collisionCheck = CollisionCheckOptions.CollisionCheckOn)

Parameters

collisionCheck CollisionCheckOptions

collision checking ON or OFF

Returns

int

Number of pairs of objects in a collision state

SetCollisionActivePair(CollisionCheckOptions, CollisionPair)

Set collision checking ON or OFF (COLLISION_ON/COLLISION_OFF) for a specific pair of objects. This allows altering the collision map for Collision checking. Specify the link id for robots or moving mechanisms (id 0 is the base).

public bool SetCollisionActivePair(CollisionCheckOptions collisionCheck, CollisionPair collisionPair)

Parameters

collisionCheck CollisionCheckOptions

Set to COLLISION_ON or COLLISION_OFF

collisionPair CollisionPair

Collision pair (item1, id1, item2, id2) to set

Returns

bool

Returns true if succeeded. Returns false if setting the pair failed (wrong id was provided)

SetCollisionActivePair(List<CollisionCheckOptions>, IReadOnlyList<CollisionPair>)

Set collision checking ON or OFF (COLLISION_ON/COLLISION_OFF) for a specific list of pairs of objects. This allows altering the collision map for Collision checking. Specify the link id for robots or moving mechanisms (id 0 is the base).

public bool SetCollisionActivePair(List<CollisionCheckOptions> checkState, IReadOnlyList<CollisionPair> collisionPairs)

Parameters

checkState List<CollisionCheckOptions>

Set to COLLISION_ON or COLLISION_OFF

collisionPairs IReadOnlyList<CollisionPair>

List of collision pairs to set

Returns

bool

Returns true if succeeded. Returns false if setting the pair failed (wrong id was provided)

SetColor(List<IItem>, List<double[]>)

Sets the color for a list of items given a 4D, 3D or 1D array of doubles

public void SetColor(List<IItem> item_list, List<double[]> color_list)

Parameters

item_list List<IItem>

list of items

color_list List<double[]>

list of colors as an array of doubles. Valid colors and alpha channel must be within the range [0-1]. Each array of doubles can be provided as a 4D, 3D or 1D array. Options: [r,g,b,a], [r,g,b], [a]. If you provide [-1,-1,-1,a] only the alpha channel is modified.

SetColor(List<IItem>, List<Color>)

Sets the color for a list of items given the a color object

public void SetColor(List<IItem> item_list, List<Color> color_list)

Parameters

item_list List<IItem>

list of items

color_list List<Color>

list of colors

SetInteractiveMode(InteractiveType, DisplayRefType, List<IItem>, List<DisplayRefType>)

Set the interactive mode to define the behavior when navigating and selecting items in RoboDK's 3D view.

public void SetInteractiveMode(InteractiveType modeType = InteractiveType.MoveReferences, DisplayRefType defaultRefFlags = (DisplayRefType)-1, List<IItem> customItems = null, List<DisplayRefType> customRefFlags = null)

Parameters

modeType InteractiveType

The mode type defines what accion occurs when the 3D view is selected (Select object, Pan, Rotate, Zoom, Move Objects, ...)

defaultRefFlags DisplayRefType

When a movement is specified, we can provide what motion we allow by default with respect to the coordinate system (set apropriate flags)

customItems List<IItem>

Provide a list of optional items to customize the move behavior for these specific items (important: the lenght of custom_ref_flags must match)

customRefFlags List<DisplayRefType>

Provide a matching list of flags to customize the movement behavior for specific items

SetItemFlags(ItemFlags)

Update global item flags. Item flags allow defining how much access the user has to item-specific features. Use FLAG_ITEM_* flags to set one or more flags.

public void SetItemFlags(ItemFlags itemFlags = ItemFlags.All)

Parameters

itemFlags ItemFlags

Item flags

SetJoints(List<IItem>, List<double[]>)

Sets the current robot joints for a list of robot items and a list of a set of joints.

public void SetJoints(List<IItem> robotItemList, List<double[]> jointsList)

Parameters

robotItemList List<IItem>

list of robot items.

jointsList List<double[]>

list of robot joints (double x nDOF).

SetParameter(string, double)

Sets a global parameter from the RoboDK station. If the parameters exists, it will be modified. If not, it will be added to the station. The parameters can also be modified by right clicking the station and selecting "shared parameters"

public void SetParameter(string parameter, double value)

Parameters

parameter string

RoboDK parameter name

value double

parameter value (number)

SetParameter(string, string)

Sets a global parameter from the RoboDK station. If the parameters exists, it will be modified. If not, it will be added to the station. The parameters can also be modified by right clicking the station and selecting "shared parameters"

public void SetParameter(string parameter, string value)

Parameters

parameter string

RoboDK parameter name

value string

parameter value

SetPoses(List<IItem>, List<Mat>)

Sets the relative positions (poses) of a list of items with respect to their parent. For example, the position of an object/frame/target with respect to its parent. Use this function instead of SetPose() for faster speed.

public void SetPoses(List<IItem> items, List<Mat> poses)

Parameters

items List<IItem>

List of items

poses List<Mat>

List of poses for each item

SetPosesAbs(List<IItem>, List<Mat>)

Set the absolute positions (poses) of a list of items with respect to the station reference. For example, the position of an object/frame/target with respect to its parent. Use this function instead of SetPoseAbs() for faster speed.

public void SetPosesAbs(List<IItem> items, List<Mat> poses)

Parameters

items List<IItem>

List of items

poses List<Mat>

List of poses for each item

SetRobotParams(IItem, double[][], Mat, Mat)

Gets the nominal robot parameters.

public bool SetRobotParams(IItem robot, double[][] dhm, Mat poseBase, Mat poseTool)

Parameters

robot IItem
dhm double[][]
poseBase Mat
poseTool Mat

Returns

bool

SetRunMode(RunMode)

Sets the behavior of the RoboDK API. By default, robodk shows the path simulation for movement instructions (RunMode.Simulate). Setting the run_mode to RunMode.QuickValidate allows performing a quick check to see if the path is feasible. If robot.Connect() is used, RUNMODE_RUN_FROM_PC is selected automatically.

public void SetRunMode(RunMode runMode = RunMode.Simulate)

Parameters

runMode RunMode

program run mode.

SetSelectedItems(List<IItem>)

Set the selection in the tree

public void SetSelectedItems(List<IItem> item_list)

Parameters

item_list List<IItem>

SetSimulationSpeed(double)

Set the simulation speed. A simulation speed of 5 (default) means that 1 second of simulation time equals to 5 seconds in a real application. The slowest speed ratio allowed is 0.001. Set a large simmulation ratio (>100) for fast simulation results.

public void SetSimulationSpeed(double speed)

Parameters

speed double

simulation ratio.

SetViewPose(Mat)

Set the pose of the wold reference frame with respect to the view (camera/screen).

public void SetViewPose(Mat pose)

Parameters

pose Mat

view pose frame.

SetVisible(List<IItem>, List<bool>, List<int>)

Sets the visibility for a list of items

public void SetVisible(List<IItem> itemList, List<bool> visibleList, List<int> visibleFrames = null)

Parameters

itemList List<IItem>

list of items

visibleList List<bool>

list visible flags (bool)

visibleFrames List<int>

list visible frames (optional, hidden by default)

SetWindowFlags(WindowFlags)

Update the RoboDK flags. RoboDK flags allow defining how much access the user has to RoboDK features. Use the flags defined in WindowFlags to set one or more flags.

public void SetWindowFlags(WindowFlags flags)

Parameters

flags WindowFlags

RoboDk Window Flags

SetWindowState(WindowState)

Set the state of the RoboDK window

public void SetWindowState(WindowState windowState = WindowState.Normal)

Parameters

windowState WindowState

Window state to be set.

ShowAsCollided(List<IItem>, List<bool>, List<int>)

Show a list of objects or a robot link as collided (red) or as not collided (normal color)

public void ShowAsCollided(List<IItem> item_list, List<bool> collided_list, List<int> robot_link_id = null)

Parameters

item_list List<IItem>

List of items

collided_list List<bool>

List of collided flags (True=show as collided)

robot_link_id List<int>

Robot link ID, when applicable

ShowMessage(string, bool)

Show a message in RoboDK (it can be blocking or non blocking in the status bar)

public void ShowMessage(string message, bool popup = true)

Parameters

message string

Message to display

popup bool

Set to true to make the message blocking or set to false to make it non blocking

ShowRoboDK()

Shows or raises the RoboDK window.

public void ShowRoboDK()

ShowSequence(Mat)

Displays a sequence of joints

public void ShowSequence(Mat sequence)

Parameters

sequence Mat

joint sequence as a 6xN matrix or instruction sequence as a 7xN matrix

ShowSequence(List<double[]>, List<Mat>, SequenceDisplayFlags, int)

Displays a sequence of joints or poses

public void ShowSequence(List<double[]> joints = null, List<Mat> poses = null, SequenceDisplayFlags flags = (SequenceDisplayFlags)-1, int timeout = -1)

Parameters

joints List<double[]>

List of joint arrays

poses List<Mat>

List of poses

flags SequenceDisplayFlags

Display options

timeout int

Display timeout, in milliseconds (default: -1)

SolveFK(List<IItem>, List<double[]>, List<bool>)

Calculate the forward kinematics solution for multiple robots at the same time (faster)

public List<Mat> SolveFK(List<IItem> robotList, List<double[]> jointsList, List<bool> solutionOkList = null)

Parameters

robotList List<IItem>

list of items

jointsList List<double[]>

list of joint

solutionOkList List<bool>

optional list of bool flags to notify about failed/invalid result

Returns

List<Mat>

SolveIK(List<IItem>, List<Mat>)

Calculate the inverse kinematics solution for multiple robots at the same time (faster)

public List<double[]> SolveIK(List<IItem> robotList, List<Mat> poseList)

Parameters

robotList List<IItem>

list of items

poseList List<Mat>

list of poses

Returns

List<double[]>

SolveIK(List<IItem>, List<Mat>, List<double[]>)

Calculate the inverse kinematics solution for multiple robots at the same time (faster)

public List<double[]> SolveIK(List<IItem> robotList, List<Mat> poseList, List<double[]> japroxList)

Parameters

robotList List<IItem>

list of items

poseList List<Mat>

list of poses

japroxList List<double[]>

Returns

List<double[]>

SolveIK_All(List<IItem>, List<Mat>)

Calculate the inverse kinematics solution for multiple robots at the same time. This call allows you to have a bulk calculation for faster performance.

public List<Mat> SolveIK_All(List<IItem> robotList, List<Mat> poseList)

Parameters

robotList List<IItem>

list of items

poseList List<Mat>

list of poses

Returns

List<Mat>

SprayAdd(IItem, IItem, string, Mat, Mat)

Add a simulated spray gun that allows projecting particles to a part. This is useful to simulate applications such as: arc welding, spot welding, 3D printing, painting, inspection or robot machining to verify the trace

public int SprayAdd(IItem tool = null, IItem referenceObject = null, string parameters = "", Mat points = null, Mat geometry = null)

Parameters

tool IItem

Active tool (null for auto detect)

referenceObject IItem

Object in active reference frame (null for auto detect)

parameters string

A string specifying the behavior of the simulated particles

points Mat

Provide the volume as a list of points as described in the sample macro SprayOn.py

geometry Mat

Provide a list of points describing triangles to define a specific particle geometry

Returns

int

Returns ID of the spray gun.

SprayClear(int)

Stops simulating a spray gun. This will clear the simulated particles

public int SprayClear(int sprayId = -1)

Parameters

sprayId int

Spray ID (value returned by SprayAdd). Leave the default -1 to apply to all simulated sprays

Returns

int

Returns result code of the operation.

SprayGetStats(out Mat, int)

Gets statistics from all simulated spray guns or a specific spray gun

public string SprayGetStats(out Mat data, int sprayId = -1)

Parameters

data Mat

Extra data output

sprayId int

Spray ID (value returned by SprayAdd). Leave the default -1 to apply to all simulated sprays

Returns

string

Returns statistics string.

SpraySetState(SprayGunStates, int)

Sets the state of a simulated spray gun (ON or OFF)

public int SpraySetState(SprayGunStates state = SprayGunStates.SprayOn, int sprayId = -1)

Parameters

state SprayGunStates

Set to SprayGunStates.SprayOn or SprayGunStates.SprayOff

sprayId int

Spray ID (value returned by SprayAdd). Leave the default -1 to apply to all simulated sprays

Returns

int

Returns result code of the operation.

StereoCameraMeasure(out Mat, out Mat, out int, out int, out int, out int)

Takes a measurement with the C-Track stereocamera. It returns two poses, the base reference frame and the measured object reference frame.Status is 0 if measurement succeeded.

public void StereoCameraMeasure(out Mat pose1, out Mat pose2, out int npoints1, out int npoints2, out int time, out int status)

Parameters

pose1 Mat

Pose of the measurement reference

pose2 Mat

Pose of the tool measurement

npoints1 int

number of visible targets for the measurement pose

npoints2 int

number of visible targets for the tool pose

time int

time stamp in milliseconds

status int

Status is 0 if measurement succeeded

Update()

Update the screen. This updates the position of all robots and internal links according to previously set values.

public void Update()

Version()

Return the vesion of RoboDK as a 4 digit string: Major.Minor.Revision.Build

public string Version()

Returns

string