arXiv:2603.04668cs.RO2026-03被引 1

用大模型辅助生成机器人库的Python绑定,提升开发效率。

Python Bindings for a Large C++ Robotics Library: The Case of OMPL

  • 以代码结构为模板,用大模型生成绑定框架并人工审核修正。
  • 生成的绑定性能接近原生方案,关键问题如指针管理已解决。
  • 适合大型C++库向Python迁移的研究者与工程团队参考。

Python绑定是连接高性能C++库与灵活Python生态的关键桥梁,支持快速原型设计、实验复现及与仿真和学习框架集成。然而,为大型代码库生成绑定是一项繁琐任务,给少数维护者带来沉重负担。本文研究利用大语言模型(LLMs)辅助生成nanobind绑定,并保持人工专家参与。工作流程遵循C++代码结构,自动生成空绑定文件,由LLMs填充绑定定义,专家随后审查并优化以确保正确性、兼容性和性能。通过对一个大型运动规划库的案例研究,我们总结了常见失败模式,包括共享指针处理不当、函数重载冲突和中转调用(trampolines)错误,并证明上下文示例和精心设计提示可显著提升可靠性。实验表明,生成的绑定在运行时性能与原有方案相当。本研究为大规模C++项目中应用大模型进行绑定生成提供了通用实践指导。

原文摘要 · Abstract (English)

Python bindings are a critical bridge between high-performance C++ libraries and the flexibility of Python, enabling rapid prototyping, reproducible experiments, and integration with simulation and learning frameworks in robotics research. Yet, generating bindings for large codebases is a tedious process that creates a heavy burden for a small group of maintainers. In this work, we investigate the use of Large Language Models (LLMs) to assist in generating nanobind wrappers, with human experts kept in the loop. Our workflow mirrors the structure of the C++ codebase, scaffolds empty wrapper files, and employs LLMs to fill in binding definitions. Experts then review and refine the generated code to ensure correctness, compatibility, and performance. Through a case study on a large C++ motion planning library, we document common failure modes, including mismanaging shared pointers, overloads, and trampolines, and show how in-context examples and careful prompt design improve reliability. Experiments demonstrate that the resulting bindings achieve runtime performance comparable to legacy solutions. Beyond this case study, our results provide general lessons for applying LLMs to binding generation in large-scale C++ projects.

C++绑定大模型机器人学Python接口

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。