C# API

The RoboDK API for C# is a RoboDK.cs source file that contains the RoboDK class (similar to Python’s Robolink class), the RoboDK.Item class (similar to Python’s Robolink.Item class API), and other tools for robotics such as a Matrix class (RoboDK.Mat) for matrix operations to operate with pose transformations.

C# (pronounced "C sharp") is a programming language developed by Microsoft and designed for building a variety of applications that run on the .NET Framework. C# is simple, powerful, type-safe, and object-oriented. The main section of this document explains the advantages of using the RoboDK API with a widely used programming language such as C# for robot programming.

The RoboDK API for C# is provided with a sample project as shown in the following image (the complete source code is included). It is also possible to use it as a NuGet package to integrate it in any .Net project.

RoboDK API - Image 16

Select Load File to open a RoboDK station or any other file supported by RoboDK. If a robot is loaded, the ROBOT variable will be updated accordingly (same as using Select Robot).

C# Simulation

C# programs are simulated by default when robot commands are used (such as MoveJ, MoveL or setDO). When the sample C# project is started, the simulation mode is also selected by default.

RoboDK API - Image 17

This means the robot movements will be simulated in RoboDK. For example, we can move the robot by steps of 10 mm selecting the buttons on the right (+Tx, -Tx, …), or we can select Run Test Program to run a hexagonal movement around the current location of the robot.

Set any breakpoints to debug your application and inspect robot targets. Robot targets can be defined as joint coordinates or Mat variables (4x4 pose Matrices) and they can be inspected as XYZWPR format to troubleshoot program issues. More information about reference frames in the Reference Frames section.

RoboDK API - Image 18

It is also possible to change the Run Mode to Offline Programming or Online Programming (Run on Robot), as shown in the following sections.


C# OLP

C# programs can be generated offline using the same C# code used to simulate the robot (Offline Programming). Follow these steps to test this feature:

1.Select Offline Programming in the Run Mode section

2.Select Run Test Program or any other combination of movements

3.Select Generate Prog to obtain the vendor-specific robot program

In this case the program is not simulated but quickly executed to obtain the result: a robot program specific to a robot controller. The Run Mode will be changed back to Simulation once the program is generated.

RoboDK API - Image 19


C# Online Programming

C# programs can be directly executed on the robot using the same C# code used for simulation. Online programming allows running a generic program on a specific robot controller using Robot Drivers. Follow these steps to test this feature using the C# sample project:

1.Select Run on Robot in the Run Mode section

2.Select any other commands that will make a robot move

The movements will run on the real robot and the simulator will synchronize the movements with the robot.

RoboDK API - Image 20

RDK = Robolink();

RDK.setRunMode(RUNMODE_RUN_ROBOT);