Retrieval-grounded robot program generation and simulation-based correction via Model Context Protocol
Organizations: Department of Mechanical Engineering, Chalmers University of Technology, Hörsalsvägen 7a, Gothenburg, SE-412 96, Sweden
Abstract
Flexible manufacturing requires industrial robots to be reprogrammed rapidly as product variants change. This paper presents a language-model-based workflow that generates, validates, and iteratively corrects ABB RAPID robot programs from natural language task descriptions. A dual-stream retrieval-augmented generation (RAG) pipeline grounds code generation in verified technical documentation and production templates, reducing domain-specific errors produced by ungrounded language models. A custom Model Context Protocol (MCP) server connects the language-model client directly to ABB RobotStudio for automated code upload, simulation execution, and diagnostic feedback. The evaluation combines a 30-query retrieval benchmark, scoped code-generation checks, and RobotStudio case studies in a simulated pickand- place manufacturing cell. The simulation loop exposes execution failures that static and semantic checks alone cannot catch, including suction release-height errors, unreachable placement targets, and configuration-dependent recovery motions. The results show how RAG and MCP can connect grounded code generation with executable feedback from industrial robot simulation software, while reducing but not eliminating expert setup and final supervision.
Figures & tables
| Evidence item | Unit | Role in the paper |
|---|---|---|
| Retrieval benchmark | 30 queries | Direct comparison of retrieval configurations using the same query set. |
| Pure LLM baseline | 5 modules | Small diagnostic baseline for RAPID hallucination modes; not a paired statistical baseline for all generated modules. |
| RAG generation log | 21 modules | Broader check of structural validity and functional coverage after retrieval grounding. |
| Semantic review subset | 10 modules | Subset with logged full-pipeline review outcomes before simulation. |
| Release-height case | 1 cell task | Mechanism evidence that simulation detects a suction release failure missed by text checks. |
| Pyramid variants | 2 tasks | Case evidence for product-variant reconfiguration using the same RobotStudio cell. |
| Configuration | Precision | Recall | MRR |
|---|---|---|---|
| Naive RAG (documentation only) | 0.52 | 0.41 | 0.58 |
| Dual retrieval with code templates | 0.68 | 0.57 | 0.72 |