Kaironetic

The issue§

My school recently acquired a KUKA ready2_educate training cell. It's a very capable platform and closely resembles real-world industrial robots; however, it's not very easy to use.

The robot ships with a touchscreen tablet (the "teach pendant"), which you are expected to use to write software for the robot. You have to manually move the robot into each position that you'd like it to visit, save the coordinates, and repeat—this process can take hours for a complicated path.

A couple days after we started working with the robot, I realized that you could import and export programs to USB media, and I was inspired to start writing a library that would allow us to interact with the KUKA Robotics Language (KRL). The benefits of being able to create programs without using the teach pendant were many:

  • Repetitive tasks could be automated quickly
  • Precise positioning could be achieved
  • Interesting applications such as drawing or music playback could be created

How does Kaironetic work?§

The most integral part of Kaironetic is the KRL superclass. It represents any language construct that implements compileKRL and can therefore be translated into a string of KRL; for example, an object of type KRL::LIN becomes LIN {X 365.000000,Y -130.000000} while an object of type KRL::ENDSPLINE simply becomes the command ENDSPLINE.

Also available are the KRL::Frame, which represents any combination of positional and rotational information, and the KRL::Group, which is not a feature of the KUKA Robotics Language itself, but rather a collection of other commands that are recursively compiled.

Other library features include application-specific submodules, such as the Canvas module, which allows one to draw shapes on a two-dimensional surface, or the Piano module, which lets you play a keyboard. My goal is to create submodules for the most common applications, exposing the facilities to either build upon them and create user-facing applications or to add your own.

// Setup the output stream and the group that will store our program
std::fstream outputFile;
KRL::Group program;

// Create a 50mm x 50mm canvas at the specified location (including the arm rotation)
KRL::Frame canvasOrigin(200, -100, 400, 120, 30, 180);
Draw2D::Canvas *canvas = new Draw2D::Canvas(canvasOrigin, 50, 50);

// Draw evenly spaced paths (lines) on the canvas
for (int i = 0; i < 10; i++) {
  canvas->commands.emplace_back(
    new Draw2D::Path({Draw2D::Point(0, (canvas->height / 10) * i),
    Draw2D::Point(canvas->width, (canvas->height / 10) * i)})
  );
}

// Add the canvas to the program; this will also include all of its contained paths
program.commands.emplace_back(canvas);

// Write the program to a file
outputFile.open("draw_evenly_spaced_lines.src", std::fstream::out);
outputFile << program.compileKRL();
outputFile.close();

How can you use Kaironetic?§

Kaironetic is available under the MIT license, which generally entitles you to use it for any purpose as long as you include the copyright notice and license. You can find the source code on GitHub. You can also review the documentation and examples, though please note that they are currently under construction. If you have any questions or comments, please let me know!