1. Introduction

This documentation presents the RoboDK API for Python. With the RoboDK API it is possible to create simulations with robots and mechanisms as well as generating brand-specific programs for robots. Whereas you can use the graphical user interface to create programs, you can extend its capabilities using a programming language such as Python. The RoboDK API for Python integrates all the offline programming features of the RoboDK simulator and allows you to deploy automated applications for a large variety of robots and mechanisms.

Brief introduction to the RoboDK API for Python:
Brief introduction to simulation and offline programming:
Sample application merged with RoboDK using the RoboDK API for C#:
The latest version of the RoboDK API is available on GitHub:

The RoboDK API for Python is divided in two modules:

With the RoboDK API it is possible to simulate and program robots for applications as simple as pick and place or as complex as synchronizing the movements of many robots. RoboDK API example using Python:

from robolink import *              # import the robolink library (bridge with RoboDK)
RDK = Robolink()                    # establish a link with the simulator
robot = RDK.Item('Robot')           # retrieve the robot
robot.setJoints([0,0,0,0,0,0])      # set all robot axes to zero

target = RDK.Item('Target')         # retrieve the Target item
robot.MoveJ(target)                 # move the robot to the target

# calculate a new approach position 100 mm along the Z axis of the tool with respect to the target
from robodk import *                # import the robodk library (robotics toolbox)
approach = target.Pose()*transl(0,0,-100)
robot.MoveL(approach)               # linear move to the approach position

The same script used for simulation can be used for offline programming, which means that the appropriate program can be generated for the robot being used. RoboDK supports a large number of robot controllers and it is easy to include compatibility for new robot controllers using Post Processors. A quick overview of RoboDK Processors is provided in the following video: https://robodk.com/help#PostProcessor

1.1. How to install

To install the robodk package for Python manually, type:

pip install robodk

More information available in the PyPi page:

RoboDK uses the Python IDLE editor by default. It is possible to change these settings to automatically use Notepad (installed with RoboDK), Visual Studio Code or Pycharm in the menu:

  • Tools-Options-Other

_images/PythonAPI-options.png
More information here:

RoboDK uses Python 3 by default. The robodk package also works with Python 2.

Download and install RoboDK if don’t have RoboDK: https://robodk.com/download Follow these steps to verify if Python is working properly:

  1. Start RoboDK

  2. Select Program-Add Python Program. A new Python item will appear called Prog1

  3. Double click the new Python program. A message should be displayed, provoked by an error raised inside the script. The message should list all items available in the station.

  4. Right click the new program and select “Edit Python script” to modify it.

_images/PythonAPI-installed.png

If a different message is displayed it means that RoboDK does not detect Python. If Python was installed properly it is possible to adjust the following settings for RoboDK to use Python properly: Tools-Options-Other

1.1.1. Windows

If you alredy installed RoboDK for Windows you should have Python 3 installed. If you didn’t install RoboDK with the Python option checked, install Python from the following link: https://www.python.org/downloads/windows/

1.1.2. Mac

RoboDK and Python must be installed separately on Mac computers. Download Python for Mac here: https://www.python.org/downloads/mac-osx/
Python 2 might be already installed on recent Mac computers. In that case it is not required to install Python.

RoboDK uses the folder /RoboDK/Python as PYTHONPATH for the robodk Module and robolink Module.

1.1.3. Linux

RoboDK and Python may have to be installed separately on Linux. Download Python for Linux here:

Python 2 is installed by default with Ubuntu. In that case it is not required to install Python.

RoboDK uses the folder /RoboDK/Python as PYTHONPATH with the corresponding robodk Module and robolink Module modules.

1.2. RoboDK API for Matlab

A Matlab version of the RoboDK API is available here:

1.3. RoboDK API for C#

A C# version of the RoboDK API is also available (based on the Nuget package). More information here:

1.4. RoboDK API for C++

A C++ version of the C++ API is available here: