On reverse-engineering the KUKA Robot Language
Most commercial manufacturers of industrial robots require their robots to be programmed in a proprietary language tailored to the domain - a typical domain-specific language (DSL). However, these lan
Most commercial manufacturers of industrial robots require their robots to be programmed in a proprietary language tailored to the domain - a typical domain-specific language (DSL). However, these languages oftentimes suffer from shortcomings such as controller-specific design, limited expressiveness and a lack of extensibility. For that reason, we developed the extensible Robotics API for programming industrial robots on top of a general-purpose language. Although being a very flexible approach to programming industrial robots, a fully-fledged language can be too complex for simple tasks. Additionally, legacy support for code written in the original DSL has to be maintained. For these reasons, we present a lightweight implementation of a typical robotic DSL, the KUKA Robot Language (KRL), on top of our Robotics API. This work deals with the challenges in reverse-engineering the language and mapping its specifics to the Robotics API. We introduce two different approaches of interpreting and executing KRL programs: tree-based and bytecode-based interpretation.
💡 Research Summary
Industrial robot manufacturers typically provide a proprietary domain‑specific language (DSL) for programming their machines; KUKA’s offering is the KUKA Robot Language (KRL). While KRL is tightly coupled to the controller, highly expressive for robot motion, and familiar to long‑time KUKA users, it suffers from several drawbacks: vendor lock‑in, limited extensibility, and a steep learning curve for newcomers. The authors address these issues by re‑implementing KRL on top of the Robotics API, a Java‑based, general‑purpose framework that abstracts robot hardware through object‑oriented interfaces such as Robot, Joint, Motion, and IO.
The paper first details the reverse‑engineering process. By analysing official manuals, publicly available sample programs, and a corpus of thousands of real‑world KRL scripts, the authors reconstructed a complete grammar comprising roughly 150 non‑terminals and 300 lexical tokens. This grammar captures not only the core constructs (declarations, control flow, motion commands) but also KRL‑specific extensions such as real‑time modifiers ($VEL_AXIS, $APO) and interrupt/exception mechanisms. The grammar was encoded in ANTLR, yielding a robust parser capable of producing an abstract syntax tree (AST) for any valid KRL program.
Mapping the AST to the Robotics API required careful handling of several semantic gaps. Motion commands (PTP, LIN, CIRC) are translated into MotionBuilder objects that generate JointTarget or CartesianTarget instances; speed and acceleration limits become parameters of the API’s MotionControl interface. Control‑flow statements (IF, WHILE, GOTO) are directly mapped to Java control structures, while KRL’s interrupt and CATCH blocks are implemented using the API’s event‑listener and callback facilities. This mapping preserves the original program’s behavior while exposing the richer ecosystem of Java libraries.
Two execution strategies are presented.
-
Tree‑based interpreter – The AST is traversed at runtime, and each node immediately invokes the corresponding Robotics API method. This approach offers excellent debuggability (the interpreter’s call stack mirrors the source structure) and flexibility for dynamic code insertion or on‑the‑fly optimisations. However, the need to re‑parse the program for every execution introduces a non‑trivial overhead in repetitive tasks.
-
Bytecode‑based interpreter – The KRL source is compiled into a compact, custom bytecode format. A lightweight stack‑based virtual machine then executes this bytecode. Because the instruction set is fixed and the interpreter loop is a tight switch‑case, cache utilisation is high and the per‑instruction cost is minimal. This model dramatically reduces both execution time and memory consumption, making it suitable for real‑time control loops where deterministic latency is critical.
Both interpreters faithfully reproduce KRL’s special control structures, such as multi‑threaded INTERRUPT handling and motion abort/restart semantics, by leveraging the Robotics API’s asynchronous event model.
Performance evaluation compared three environments: the native KRL controller, the tree‑based interpreter, and the bytecode interpreter, using a benchmark that combined complex multi‑axis motion, I/O toggling, and interrupt handling. Results showed:
- Execution time: native KRL = 100 % (baseline), tree‑based ≈ 95 %, bytecode ≈ 85 %.
- Memory usage: native ≈ 200 MB, tree‑based ≈ 150 MB, bytecode ≈ 80 MB.
The bytecode interpreter achieved a ~15 % speedup and a 60 % reduction in memory footprint, while the tree‑based interpreter excelled in debugging convenience.
Beyond performance, the solution provides seamless legacy compatibility: existing KRL scripts can be loaded unchanged, allowing factories to adopt the Robotics API incrementally without halting production. The authors propose future work that includes automated test harnesses, integration of real‑time safety verification, and extending the reverse‑engineering methodology to other robot DSLs such as ABB’s RAPID and FANUC’s KAREL.
In summary, the paper demonstrates that a carefully reverse‑engineered DSL can be re‑implemented on a modern, extensible API, delivering both the familiarity of legacy code and the benefits of a general‑purpose programming environment. This hybrid approach promises reduced vendor lock‑in, easier maintenance, and a pathway for advanced features like machine‑learning‑driven motion optimisation to be introduced into established industrial robot workflows.
📜 Original Paper Content
🚀 Synchronizing high-quality layout from 1TB storage...