RoboDK API - Documentation
RoboDK API for C++

Introduction

This section of the documentation is an introduction to the RoboDK API for C++.

The RoboDK API allows creating simulations for industrial robots and generate vendor-specific robot programs. While RoboDK's graphical user interface can be used to create programs, it is possible to extend the robot controller limitations by using a universal programming language such as C++. The RoboDK API is available in C++, C#, Python, Matlab and Visual Basic.

RoboDK-API-Cpp.png

With the RoboDK API it is possible to simulate and program any industrial robot using your preferred programming language. This avoids using vendor-specific programming languages.

Note: This RoboDK API is not the Plugin Interface:

More information here: Plug-In Interface vs. RoboDK API.

Classes

The RoboDK API for C++ is implemented in 2 files (robodk_api.h and robodk_api.cpp). These files define the following classes.

RoboDK class

The RoboDK class defines the interface to the RoboDK API. The original Python reference is available here: https://robodk.com/doc/en/RoboDK-API.html#RoboDKAPI.

More information about the RoboDK API is available here:

Item class

The Item class can be used to operate on any item available in the RoboDK tree. Use functions such as class: IRoboDK::getItem or class: IRoboDK::getItemList to retrieve items from the RoboDK station tree. Item is a pointer to IItem. Items should be deleted using class: IItem::Delete (not using the class destructor).

More information about the RoboDK Item class (based on the Python API) is available here:

station-tree.png

RoboDK types file

The RoboDK API defines a set of types used by the RoboDK API. Including:

  • The Mat class for Pose manipulations.
  • The tJoints class to represent robot joint variables
  • The tMatrix2D data structure to represent a variable size 2D matrix (mostly used for internal purposes)

Plug-In Interface vs. RoboDK API

The RoboDK API is a generic set of commands that allows you to interact with RoboDK and automate tasks. The RoboDK API is used by default when macros are used in RoboDK. The RoboDK Plug-In is a library (DLL) that can be loaded by RoboDK to extend certain features and customize the RoboDK interface. The interface includes an interface to the RoboDK API.

The main advantages of using the RoboDK API through a Plug-In Inteface are the following:

  • The RoboDK API is much faster because it is loaded as a library (a RoboDK Plug-In is actually a library loaded by RoboDK).
  • You can customize the appearance of RoboDK's main window (including the menu, toolbar, and add docked windows).

You should pay attention to the following when using the RoboDK API inside a Plug-In:

  • Items (Item/IItem) are pointers, not objects. You can check if an item is valid or not by checking if it is a null pointer (nullptr).
  • You must call class: IRoboDK::Render every time you want to update the screen (for example, if you change the position of a robot using class: IItem::Joints). Updading the screen is not done automatically.
  • Plug-Ins can only be deployed as C++ code using Qt libraries.

Requirements

The RoboDK API uses Qt libraries and an example is provided created using Qt Creator. It is recommended to use the APIExample project to get started with your new project (double click RoboDK-API-Cpp-Sample.pro to open it with Qt Creator).

Installation Requirements

Requirements to make RoboDK Plug-Ins work:

  • It is required to install RoboDK (v3.5.4 or later): https://robodk.com/download
  • You should install Qt libraries and Qt Creator (unless you are planning to use Qt libraries on Visual Studio).
qttoolkit.png

Offline Programming Example

The following code (C++) shows an example that uses the RoboDK API for robot simulation and offline programming::

// Draw a hexagon inside a circle of radius 100.0 mm
int n_sides = 6;
float size = 100.0;
// retrieve the reference frame and the tool frame (TCP)
Mat pose_frame = ROBOT->PoseFrame();
Mat pose_tool = ROBOT->PoseTool();
Mat pose_ref = ROBOT->Pose();
// Program start
ROBOT->MoveJ(pose_ref);
ROBOT->setPoseFrame(pose_frame); // set the reference frame
ROBOT->setPoseTool(pose_tool); // set the tool frame: important for Online Programming
ROBOT->setSpeed(100); // Set Speed to 100 mm/s
ROBOT->setRounding(5); // set the rounding instruction (C_DIS & APO_DIS / CNT / ZoneData / Blend Radius / ...)
ROBOT->RunInstruction("CallOnStart"); // run a program
for (int i = 0; i <= n_sides; i++) {
// calculate angle in degrees:
double angle = ((double) i / n_sides) * 360.0;
// create a pose relative to the pose_ref
Mat pose_i(pose_ref);
pose_i.rotate(angle,0,0,1.0);
pose_i.translate(size, 0, 0);
pose_i.rotate(-angle,0,0,1.0);
// add a comment (when generating code)
ROBOT->RunInstruction("Moving to point " + QString::number(i), RoboDK::INSTRUCTION_COMMENT);
// example to retrieve the pose as Euler angles (X,Y,Z,W,P,R)
double xyzwpr[6];
pose_i.ToXYZRPW(xyzwpr);
ROBOT->MoveL(pose_i); // move the robot
}
ROBOT->RunInstruction("CallOnFinish");
ROBOT->MoveL(pose_ref); // move back to the reference point

The same script used for simulation can be used for offline programming, this means that the corresponding program can be generated for the robot controller. RoboDK supports a large number of robot controllers and it is easy to include compatibility for new robot controllers using Post Processors.

For more Examples:

For more information about robot post processors:

Supported robots

The following list includes the robot controllers supported by RoboDK:

  • ABB RAPID IRC5: for ABB IRC5 robot controllers
  • ABB RAPID S4C: for ABB S4C robot controllers
  • Adept Vplus: for Adept V+ programming language
  • Allen Bradley Logix5000: for Allen Bradley Logix5000 PCL
  • CLOOS: for cloos robot controllers
  • Comau C5G: for Comau C5G robot controllers
  • Denso PAC: for Denso RC7 (and older) robot controllers (PAC programming language)
  • Denso RC8: for Denso RC8 (and newer) robot controllers (PacScript programming language)
  • Dobot: for educational Dobot robots
  • Fanuc R30iA: for Fanuc R30iA and R30iB robot controllers
  • Fanuc R30iA Arc: for Fanuc Arc welding
  • Fanuc RJ3: for Fanuc RJ3 robot controllers
  • GCode BnR: for B&R robot controllers
  • GSK: for GSK robots
  • HIWIN HRSS: for HIWIN robots
  • KAIRO: for Keba Kairo robot controllers
  • KUKA IIWA: for KUKA IIWA sunrise programming in Java
  • KUKA KRC2: for KUKA KRC2 robot controllers
  • KUKA KRC2 CamRob: for KUKA CamRob milling option
  • KUKA KRC2 DAT: for KUKA KRC2 robot controllers including DAT data files
  • KUKA KRC4: for KUKA KRC4 robot controllers
  • KUKA KRC4 Config: for KUKA KRC4 robot controllers with configuration data in each line
  • KUKA KRC4 DAT: for KUKA KRC4 robot controllers including DAT data files
  • Kawasaki: for Kawasaki AS robot controllers
  • Mecademic: for Mecademic Meca500 robot
  • Motoman/Yaskawa: For Motoman robot controllers (JBI II and JBI III programming)
  • Mitsubishi: for Mitsubishi robot controllers
  • Nachi AX FD: for Nachi AX and FD robot controllers
  • Daihen OTC: for Daihen OTC robot controllers
  • Precise: for Precise Scara robots
  • Siemens Sinumerik: for Siemens Sinumerik ROBX robot controller
  • Staubli VAL3: for Staubli VAL3 robot programs (CS8 controllers and later)
  • Staubli VAL3 InlineMove: to generate Staubli VAL3 programs with inline movement data
  • Staubli S6: for Staubli S6 robot controllers
  • Toshiba: for Toshiba robots
  • Universal Robots: for UR robots, generates linear movements as pose targets
  • Universal Robots RobotiQ: for UR robots including support for RobotiQ gripper
  • Universal Robots joints: for UR robots, generates linear movements as joint targets
  • Yamaha: for Yamaha robots

Qt Tips

The C++ version of the RoboDK API is based on Qt. Qt is a set of useful libraries for C++ and Qt Creator is the default development environment (IDE) for Qt.

This list provides some useful links and tips for programming with Qt:

  • Double click the RoboDK-API-Cpp-Sample.pro file to open the example project using Qt Creator.
  • Use Qt signal/slots mechanism for action/button callbacks (http://doc.qt.io/qt-5/signalsandslots.html). Signals and slots are thread safe.
  • Wrap your strings using tr("your string") or QObject::tr("your string") to allow translation using Qt Linguist. For more information: http://doc.qt.io/qt-5/qtlinguist-index.html.
  • If you experience strange build issues it may be useful to delete the build folder that is automatically created to force a new build.
  • If you experience strange plugin load issues in RoboDK it is recommended to delete the libraries and create the plugin library with a new build.
  • More information about Qt: https://www.qt.io/.

Useful Links

Useful links involving the RoboDK API: