TL;DR
DrPlanner is the first framework to leverage Large Language Models (LLMs) to automatically diagnose and repair motion planners for autonomous vehicles. By combining structured code descriptions with an iterative feedback loop, it significantly reduces the manual labor required to tune complex planning algorithms, achieving a 98% success rate in improving planner performance.
What Problem Does This Paper Address?
Motion planning—the process by which an autonomous vehicle decides its path—is a solved problem in theory but a nightmare in practice. No single algorithm is perfect across all scenarios. Engineers often spend weeks manually "tuning" these planners, diagnosing why a vehicle braked too hard or failed to find a path through a tight intersection, and then tweaking cost functions or parameters to fix it.
Traditional Automated Software Repair (ASR) techniques struggle here because they usually focus on fixing "bugs" (code that crashes). In motion planning, the code often "works" perfectly fine from a programming perspective, but the behavior it produces is suboptimal or unsafe. DrPlanner aims to bridge this gap by using the reasoning capabilities of LLMs to act as an automated "doctor" for motion planning code.
Methods
The authors introduce a closed-loop framework that treats the LLM as a diagnostic agent. The process follows a structured pipeline:
- Planner & Trajectory Description: Instead of just feeding raw code to the LLM, DrPlanner generates a structured "medical record." This includes the planner's source code, natural language descriptions of its subfunctions (extracted from docstrings), and a quantitative evaluation of the planned trajectory using an objective function ($J$).
- Prompt Engineering: The framework uses a sophisticated prompt structure consisting of a System Prompt (defining the LLM's role as an expert) and a User Prompt (containing the specific scenario, planner details, and few-shot examples).
- Iterative Repair: The LLM outputs a "diagnosis" (what's wrong), a "prescription" (how to fix it), and a "patched program."
- Feedback Loop: The patched code is automatically integrated and executed. The results (new performance scores or execution errors) are fed back to the LLM. If the LLM "hallucinates" a non-existent function or causes a crash, the error message becomes part of the next prompt, allowing the model to self-correct.
Datasets
The researchers evaluated DrPlanner using the CommonRoad platform, an open-source benchmark for autonomous vehicle motion planning.
- Scenarios: 50 randomly selected "critical" scenarios (e.g., complex intersections).
- Planners: The system was tested on two distinct types of planners:
- Search-based: An A* algorithm using lattice-based graphs.
- Sampling-based: A reactive planner that generates jerk-optimal trajectories using polynomials.
- Benchmarks: Performance was measured against the CommonRoad benchmark leaderboard to set target objective values ($J^*$).
Key Insights and Ideas
- Few-Shot Learning is Essential: The authors found that providing the LLM with a few human-annotated examples of successful repairs was critical. Without these "demonstrations," the LLM often failed to understand the relationship between specific motion primitives and the resulting trajectory.
- LLMs as Domain Experts: Unlike generic coding assistants, the LLM was able to provide nuanced diagnoses, such as identifying that a heuristic was "too sparse" or that an orientation weight was "excessive," leading to more intelligent code modifications than a standard genetic algorithm.
- Handling Hallucinations via Iteration: LLMs are prone to making up code. DrPlanner mitigates this by treating the compiler/simulator as a "verifier." If the LLM generates a
KeyError, the system simply tells the LLM, "You caused a KeyError," and the model usually fixes it in the next iteration. - Contextual Awareness: The model showed an ability to handle "aliasing"—recognizing when different variables referred to the same physical state—which is vital for correctly modifying complex robotics codebases.
Key Results
DrPlanner demonstrated a remarkable ability to optimize planners that were already "functional" but underperforming:
- Success Rate: It achieved a 98.0% pass rate (at $k=10$), meaning it successfully improved the planner in almost every scenario tested.
- Performance Boost: On average, it reduced the objective function cost ($J_{SM1}$) by 54.5%.
- Efficiency: The system was surprisingly fast, typically requiring only 1.4 iterations to find its first significant improvement.
- Comparison: It significantly outperformed a baseline genetic algorithm, which struggled to navigate the complex, high-dimensional space of motion planning logic.
Limitations and Future Work
While impressive, the authors note several hurdles:
- No Formal Guarantees: Because LLMs are probabilistic, there is no mathematical guarantee that the repaired planner will always be better or safer. A separate, traditional safety layer is still mandatory for real-world use.
- Token Limits: Current LLMs have a "context window" limit, which prevents DrPlanner from processing massive, multi-file codebases all at once.
- Future Directions: The team plans to develop a "memory module" so the system can learn from its own past repairs across different scenarios, effectively building an automated library of planning expertise. They also aim to expand the framework to other robotics domains beyond autonomous driving.
Summary updated