DrPlanner: Diagnosis and Repair of Motion Planners for Automated Vehicles Using Large Language Models

Yuanfei Lin, Chenran Li, Mingyu Ding, Masayoshi Tomizuka, Wei Zhan, Matthias Althoff

DrPlanner: Diagnosis and Repair of Motion Planners for Automated Vehicles Using Large Language Models

TL;DR

Tuning motion planners for autonomous vehicles is notoriously tedious, requiring deep domain expertise to manually diagnose and fix edge-case failures. This paper introduces DrPlanner, a novel framework that leverages Large Language Models (LLMs) to automatically diagnose and repair underperforming motion planning code. By combining structured prompts, few-shot examples, and an iterative execution feedback loop, DrPlanner successfully patches complex planning algorithms and significantly improves their trajectory optimization.

The Challenge of Motion Planning

Motion planners are the algorithmic brains responsible for navigating autonomous vehicles safely and comfortably from point A to point B. They must balance complex objective functions—like minimizing travel time, passenger discomfort, and fuel use—while strictly adhering to safety rules and physical constraints.

A complex traffic scenario from the CommonRoad benchmark, illustrating the challenges motion planners face with obstacles and dynamic agents.

However, no motion planner is perfect out of the box. Tuning them is a highly labor-intensive process. When a vehicle behaves suboptimally in a simulation (e.g., braking too hard or steering erratically), human engineers must manually trace the high-level behavioral failure back to specific lines of code, heuristic weights, or sampling parameters. The authors tackle this bottleneck by asking: Can we use the reasoning and code-generation capabilities of LLMs to automate the diagnosis and repair of these intricate algorithms?

Methodology: The DrPlanner Framework

The authors propose DrPlanner, an automated software repair framework tailored specifically for motion planners. Instead of just finding syntax bugs, DrPlanner aims to improve the actual algorithmic performance.

The DrPlanner framework: taking a critical scenario and an imperfect motion planner as input, an LLM generates a diagnosis, prescription, and repaired code.

The pipeline works as follows:

  1. Structured Prompting: DrPlanner translates the state of the motion planner into a structured prompt. This includes system instructions, a description of the planner (algorithm type, key components, and Python code snippets), and an evaluation of the current planned trajectory (e.g., a breakdown of the cost function).
  2. Few-Shot Context: Because an LLM cannot see the entire codebase, the prompt includes a list of available helper functions, docstrings, and valid parameters (like offline-generated motion primitive IDs) to ground the LLM's suggestions in reality.
  3. Iterative Feedback Loop: The LLM (GPT-4-Turbo) outputs a diagnosis, a prescription, and a patched code snippet. DrPlanner automatically injects this patch into the codebase and runs the simulation.
  4. If the code crashes, the error trace is fed back to the LLM.
  5. If it runs, the new trajectory cost is compared to the old one, and this performance delta is fed back.
  6. The LLM refines its patch iteratively until a target performance is met or a token limit is reached.

Experimental Evaluation

The framework is evaluated using the CommonRoad platform, a widely used open-source benchmark for motion planning in Python.

  • Evaluation Set: The authors tested DrPlanner on 50 randomly selected critical traffic scenarios from CommonRoad, evaluating 50 A* search-based motion planners in various configurations. They also tested it qualitatively on a sampling-based planner.
  • In-Context Learning: No new training datasets were introduced, as the approach relies entirely on the in-context learning (zero-shot/few-shot prompting) capabilities of off-the-shelf LLMs rather than fine-tuning.

Key Insights and Results

  • LLMs as Expert Debuggers: LLMs demonstrate a surprising ability to map physical trajectory flaws directly to algorithmic deficiencies and write the exact code to fix it.
  • Execution Feedback is Non-Negotiable: Zero-shot code repair often fails due to syntax errors. By feeding Python errors or worsening objective scores back into the prompt, the LLM successfully self-corrects, mimicking a human developer's trial-and-error workflow.
  • High Success Rate: DrPlanner achieved a 98.0% pass rate (pass@10) in successfully repairing planners to improve their objective function, vastly outperforming a traditional genetic algorithm baseline (7.7%).
  • Massive Performance Boost: Repaired planners saw an average reduction of 54.5% in their objective function cost, meaning the resulting driving trajectories were significantly smoother, safer, and more efficient.

Limitations and Future Work

The authors acknowledge that DrPlanner cannot strictly guarantee an improvement, as LLMs are inherently prone to hallucinations and inaccurate diagnoses. Consequently, any LLM-patched planner would still require a rigorous safety verification layer before being deployed on real roads. Future work includes testing across more application domains and adding a "memory module" to the LLM agent to leverage experiential learning from past debugging sessions.

Summary updated

BibTeX
@article{lin2024drplanner,
  author = {Yuanfei Lin and Chenran Li and Mingyu Ding and Masayoshi Tomizuka and Wei Zhan and Matthias Althoff},
  title = {{DrPlanner: Diagnosis and Repair of Motion Planners for Automated Vehicles Using Large Language Models}},
  journal = {IEEE Robotics Autom. Lett.},
  year = {2024},
  doi = {10.1109/lra.2024.3441493},
}
Figure