RoboDK API

repository·master·Indexed 43 days ago

https://github.com/robodk/robodk-api

A multi-language interface for industrial robot simulation and offline programming. The API allows developers to control robots, create complex robotic cells, and automate manufacturing using TypeScript, JavaScript, C#, C++, and ANSI C instead of vendor-specific code. It supports a wide range of robot controllers including ABB, Fanuc, KUKA, Staubli, Universal Robots, and Denso.

Tokens
14.8K
Snippets
26
Records
54
Agent score
55%

What's inside RoboDK

  1. Overview of the RoboDK API

    master

    The RoboDK API allows you to program industrial robot arms, create simulations, and generate vendor-specific programs using various programming languages. It serves as a universal alternative to vendor-specific programming languages, enabling offline programming and complex simulations (e.g., machining, 3D printing, pick and place) in a high-level language.

    Supported languages include:

    • Python
    • JavaScript/TypeScript (Node.js)
    • C#
    • Matlab
    • C++
    • Visual Basic

    Note: The RoboDK API is distinct from the RoboDK Plug-In interface.

  2. Overview of RoboDK Python modules

    master

    The robodk package is organized into several specialized modules:

    • robolink: The core link between RoboDK and Python. Used to retrieve items from the RoboDK item tree (robots, reference frames, tools, objects, etc.) as Item objects.
    • robomath: A robotics toolbox for matrix operations, projections, timers, and other mathematical operations.
    • robodialogs: A toolbox for UI dialogs, such as file open/save dialogs and message prompts.
    • robofileio: A toolbox for file operations, including file properties, CSV handling, and FTP.
    • roboapps: A toolbox for RoboDK Apps, allowing you to create and load custom applications.
  3. Access RoboDK items using the IItem interface

    master
    Every entity in the RoboDK station tree (such as robots, reference frames, tools, or objects) is represented by an IItem object. You can retrieve any item from the RoboDK tree and interact with it through this interface.
  4. Use the Mat class for 4x4 matrices (poses)

    master

    The Mat class represents a 4x4 matrix, which is used to define a pose in RoboDK. It is a subclass of QMatrix4x4. You can use it to perform transformations such as rotation and translation, and to extract Euler angles.

    // Example of creating a pose relative to an existing one
    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);
    
    // Extracting Euler angles (X, Y, Z, W, P, R)
    double xyzwpr[6];
    pose_i.ToXYZRPW(xyzwpr);
  5. Understanding the RoboDK ANSI C API patterns

    master

    The C API implements a subset of the full RoboDK API. It follows these structural patterns compared to the C++ API:

    1. Method Naming: Class methods are prefixed with the class name in uppercase, followed by an underscore and the function name (e.g., RoboDK_getItem() instead of RoboDK::getItem()).
    2. Data Members: Class data members are accessed via structs rather than class properties.
    3. First Parameter: Every API function call requires the first parameter to be a pointer to the structure representing the data for that specific class (e.g., a pointer to RoboDK_t or Item_t).
    4. Memory Management: For the main connection structure RoboDK_t, the pointer must remain valid for the entire duration of the API usage, as all items created by the API maintain a copy of its location.
  6. Core classes: Robolink and RobolinkItem

    master

    The API is built around two primary classes that mirror the Python API structure:

    • Robolink: The main interface class used to connect to RoboDK. You use an instance of this class to retrieve items from the RoboDK Station Tree.
    • RobolinkItem: Represents a specific object (robot, tool, target, frame, etc.) within the RoboDK Station Tree. Once you have a RobolinkItem, you can perform operations on it, such as moving the robot, setting poses, or retrieving child items.

    For detailed documentation within MATLAB, use the doc command:

    • doc Robolink
    • doc RobolinkItem
  7. Use Post Processors for Offline Programming

    master

    The same scripts used for simulation can be used for offline programming. By using Post Processors, the API automatically generates a program compatible with specific robot controllers to reproduce the simulated movements on the actual hardware.

    RoboDK supports a wide range of controllers, including:

    • ABB (RAPID IRC5, RAPID S4C)
    • Fanuc (R30iA, R30iA_Arc, RJ3)
    • KUKA (KRC2, KRC4, IIWA)
    • Universal Robots (UR, URP, MoveP)
    • Staubli (VAL3, S6)
    • Motoman/Yaskawa (Inform II/III)
    • ...and many others.
  8. Use the Mat class for matrix and pose operations

    master

    The Mat class is a standalone, dependency-free implementation of a 4x4 homogeneous pose matrix (backed by double[][]). It is used for all spatial transformations in the API.

    Key Capabilities

    • Construction: Create identity/zero matrices, 4x4 poses from 12/16 values, 3x3 rotation matrices, column vectors, and point lists.
    • Pose Builders: transl, rotX/rotY/rotZ, fromXyzRpw, fromTxyzRxyz, fromUR, fromPointNormal.
    • Pose Decomposition: toXyzRpw, toTxyzRxyz, toUR, pos/setPos, vx/vy/vz, rot3x3, translationPose, rotationPose.
    • Matrix Algebra: add, subtract, multiply (matrix-matrix, matrix-scalar, matrix-vector), negate, transpose, invert, concatenateHorizontal/concatenateVertical.
    • Vector Helpers: norm, normalize, cross, dot, angle.
    • Transformations: relTool, offset.
    • Persistence: saveCsv, saveMat.
  9. Use RoboDK Macros in projects

    master

    Macros (found in the Macros folder) are Python-based examples that typically require adjustments to integrate with your specific project. You can use them in two ways:

    1. Add to RoboDK Station: Run them directly within the RoboDK interface to automate tasks or demonstrate patterns.
    2. External Python Environment: Import and adapt the logic into your own standalone Python applications.
  10. Core Modules of the RoboDK API

    master

    The API is organized into several key modules that provide the interface to the RoboDK software and robotics capabilities:

    • robolink module: Acts as the primary link to the RoboDK software instance.
    • Item module: Provides access to any item in the RoboDK item tree. Items are represented by the Item object and can include robots, reference frames, tools, objects, or specific projects.
    • robodk module: A robotics toolbox for pose operations, inspired by Peter Corke's Robotics Toolbox.
  11. Debug the RoboDK Java API in IntelliJ IDEA

    master

    To enable stepping into the API source code (rather than stepping into a decompiled JAR), you must open the parent Java folder in IntelliJ IDEA, not just the Example folder.

    Setup Steps:

    1. Open Parent Project: Go to File > Open... and select the Java folder containing the parent pom.xml.
    2. Import Maven: If prompted, allow IntelliJ to import the project. If not automatic, right-click pom.xml and select Add as Maven Project.
    3. Verify Module Dependency: IntelliJ should create a module dependency from robodk-api-example to robodk-api. This allows the debugger to resolve classes to the actual source files in API/src/main/java.
    4. Run Debugger: Open Example/src/main/java/com/robodk/example/BasicExample.java, set a breakpoint (e.g., on robodk.connect()), and select Debug.

    Important: Ensure RoboDK is running before starting the debug session, otherwise BasicExample will fail to connect.