{"id":19973210,"url":"https://github.com/commonroad/drplanner","last_synced_at":"2025-05-04T01:31:03.105Z","repository":{"id":225971398,"uuid":"765154038","full_name":"CommonRoad/drplanner","owner":"CommonRoad","description":"🩺 : Elevate Your Planner, Perfect Your Motion 🌠","archived":false,"fork":false,"pushed_at":"2024-11-25T16:42:15.000Z","size":526429,"stargazers_count":30,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-08T01:34:22.271Z","etag":null,"topics":["diagnosis-tool","llm","llm-inference","motion-planning","repairer"],"latest_commit_sha":null,"homepage":"https://commonroad.github.io/drplanner/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CommonRoad.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-29T11:36:20.000Z","updated_at":"2025-03-08T14:09:51.000Z","dependencies_parsed_at":"2024-07-27T13:48:45.215Z","dependency_job_id":null,"html_url":"https://github.com/CommonRoad/drplanner","commit_stats":null,"previous_names":["commonroad/drplanner"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CommonRoad%2Fdrplanner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CommonRoad%2Fdrplanner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CommonRoad%2Fdrplanner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CommonRoad%2Fdrplanner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CommonRoad","download_url":"https://codeload.github.com/CommonRoad/drplanner/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252276955,"owners_count":21722447,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["diagnosis-tool","llm","llm-inference","motion-planning","repairer"],"created_at":"2024-11-13T03:10:39.265Z","updated_at":"2025-05-04T01:31:03.096Z","avatar_url":"https://github.com/CommonRoad.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DrPlanner 🩺: Diagnosis and Repair of Motion Planners for Automated Vehicles Using Large Language Models\n\n[![Static Badge](https://img.shields.io/badge/Arxiv-pdf-8A2BE2?logo=arxiv)](https://arxiv.org/abs/2403.07470)\n[![Custom badge](https://img.shields.io/badge/Project%20Page-white?logo=GitHub\u0026color=yellow)](https://commonroad.github.io/drplanner/)\n[![GitHub issues](https://img.shields.io/github/issues/CommonRoad/drplanner)](https://github.com/CommonRoad/drplanner/issues)\n## 🔍 Framework Overview\n\n\u003cimg src=\"./docs/figures/framework.png\" width=92%\u003e\n\n**DrPlanner**: the first framework to autonomously **d**iagnose and **r**epair motion **planner**s 📍, harnessing the power of LLMs that improve as they scale.\n\n\n## 🌟 Highlights\n- **`2024-07-22`** Exciting news! **DrPlanner is accepted by RA-L 2024 🎉🎉!**\n- **`2024-03-13`** Our paper is available on [Arxiv](https://arxiv.org/abs/2403.07470)📄!\n\n\u003ctable style=\"border-collapse: collapse; border: none;\"\u003e\n  \u003ctr style=\"border: none;\"\u003e\n    \u003ctd align=\"center\"\u003e\u003cimg src=\"./docs/figures/DEU_Guetersloh-15_2_T-1_itr0.gif\" alt=\"First GIF\" width=\"300\"/\u003e\u003cbr\u003eInitial Planner\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003cimg src=\"./docs/figures/DEU_Guetersloh-15_2_T-1_itr1.gif\" alt=\"Second GIF\" width=\"300\"/\u003e\u003cbr\u003eFirst Iteration\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003cimg src=\"./docs/figures/DEU_Guetersloh-15_2_T-1_itr3.gif\" alt=\"Third GIF\" width=\"300\"/\u003e\u003cbr\u003eThird Iteration\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n## 🚀 Getting Started\n### 1. Requirements 📦\nFor diagnosing your motion planner, we recommend using [Anaconda](https://www.anaconda.com/) to manage your environment \nso that even if you mess something up, you can always have a safe and clean restart. A guide for managing python \nenvironments with Anaconda can be found [here](https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html).\n\n#### Clone the repository\n```git\ngit clone \u003cthis-repository\u003e\ncd \u003cpath-to-this-repo\u003e\ngit submodule init\ngit submodule update\n```\n\n#### Install the package\n```bash\nconda create -n drplanner python=3.10 -y\nconda activate drplanner\npip install . # or poetry install\n```\n\n### 2. Configuration ⚙️ \n\nAll configurable parameters are located in `drplanner/utils/config.py`.\n\nBefore running DrPlanner, set up your `OpenAI API keys`.\n\nConfigure as below:\n```\napi_key: # 'sk-xxxxxx'\ngpt_version: # \"gpt4-xxx\"\ntoken_limit: 8000\n```\n\n### 3. Running DrPlanner 🩺\nWe use the search-based motion planner, i.e., [commonroad-search](https://gitlab.lrz.de/tum-cps/commonroad-search), to demonstrate the advantages of our framework.\nIf you wish to replicate this, please consult its README for the installation steps and place your own planner within `drplanner/planners/`. To facilitate a smoother start, we offer the planner used in the paper in this repository.\nAfter this, running DrPlanner is straightforward:\n```bash\npython run_drplanner.py\n```\n\nThe default settings include the iterative prompting, which you can deactivate in `config.yaml`.\n\n### 4. Example Prompt 🌠\n\u003cdetails\u003e\n\n\u003e You are an expert in diagnosing motion planners for automated vehicles. Your task is to identify diagnoses and recommend \nprescriptions for the motion planner, with the objective of enhancing its performance.\n\n\u003eBefore you start, it is important to understand and adhere to the instructions:\n\u003e- Ensure that the improved code is free from errors and that all modifications positively impact the final outcome.\n\u003e- Be cautious when adjusting weights or constants, particularly when setting them to zero.\n\u003e- When modifying 'if', 'elif', and 'else' constructs, consider that changes may yield variable outcomes across different \nsituations.\n\u003e- The diagnosis should concisely pinpoint each issue, using only a few words for clarity and brevity. For each \nprescription, provide a detailed, step-by-step action plan.\n\u003e- Adhere strictly to all specified instructions. In case of a contradiction with your knowledge, offer a thorough\n explanation.\n\n\u003eThe A* search algorithm is employed in trajectory planning to navigate from an initial state to a designated goal \nregion by linking motion primitives.This is the code of the heuristic function: \n\u003e```python\n\u003edef heuristic_function(self, node_current: PriorityNode) -\u003e float:\n\u003e        path_last = node_current.list_paths[-1]\n\u003e\n\u003e        angleToGoal = self.calc_angle_to_goal(path_last[-1])\n\u003e\n\u003e        orientationToGoalDiff = self.calc_orientation_diff(angleToGoal, path_last[-1].orientation)\n\u003e\n\u003e        cost_time = self.calc_time_cost(path_last)\n\u003e\n\u003e        if self.reached_goal(node_current.list_paths[-1]):\n\u003e            heur_time = 0.0\n\u003e\n\u003e        if self.position_desired is None:\n\u003e            heur_time = self.time_desired.start - node_current.list_paths[-1][-1].time_step\n\u003e\n\u003e        else:\n\u003e            velocity = node_current.list_paths[-1][-1].velocity\n\u003e\n\u003e            if np.isclose(velocity, 0):\n\u003e                heur_time = np.inf\n\u003e\n\u003e            else:\n\u003e                heur_time = self.calc_euclidean_distance(current_node=node_current) / velocity\n\u003e\n\u003e        cost = 20 * orientationToGoalDiff + 0.5 * cost_time + heur_time\n\u003e        if cost \u003c 0:\n\u003e            cost = 0\n\u003e        return cost\n\u003e```\n\u003e In the current heuristic function of the A* search algorithm, the following functions are called: \n\u003e\"calc_angle_to_goal\" returns the orientation of the goal (angle in radian, counter-clockwise defined) with respect to \n\u003ethe position of the state. \"calc_orientation_diff\" returns the orientation difference between 2 orientations in \n\u003eradians. \"calc_euclidean_distance\" cCalculates the euclidean distance of the vehicle center to the desired goal \n\u003eposition. \"calc_time_cost\" Returns time cost (number of time steps) to perform the given path. \n\u003e\"reached_goal\" returns the goal reaching every state of the path and returns true if one of the state satisfies all \n\u003e conditions for the goal region: position, orientation, velocity, time. \n\n\u003e  Motion primitives are short trajectories that are drivable by a given vehicle model. By concatenating the primitives,\n\u003e a drivable trajectory can be constructed that leads the vehicle from the initial state to the goal state. Generating \n\u003e too sparse primitives (low branching factor) may restrict the search space such that no feasible solution can be \n\u003e found. On the other hand, generating too dense primitives (high branching factor) may dramatically increase the time \n\u003e of search. The currently used motion primitives are named as \"V_0.0_20.0_Vstep_4.0_SA_-1.066_1.066_SAstep_0.18_T_0.5_\n\u003e Model_BMW_320i.xml\",adhering to the format `V_{velocity_min}_{velocity_max}_Vstep_{velocity_step_size}_SA_{steering_angle_min}_{steering_angle_max}_SAstep_{steering_angle_step_size}_T_{time_durantion}_Model_{vehicle_model}`. \n\u003e This name implies the setup of the motion primitives: The velocity range is set from 0.0m/s to 20.0m/s with incremental\n\u003e steps of 4.0m/s. The steering angle varies from -1.066 rad to 1.066 rad with a step size of 0.18rad. The motion\n\u003e primitives have a fixed duration of 5.0 time steps.\n\n\u003e The objective is to adjust the total cost of the planned trajectory to closely align with the desired value 0.16. \n\u003e The current total cost is calculated to be 4606.93, includes squared sum of acceleration, valued at 91.73 with a \n\u003e weight of 50.0; squared sum of steering angle, valued at 0.09 with a weight of 50.0; squared sum of steering velocity,\n\u003e valued at 0.25 with a weight of 50.0; sum of the path length, valued at 0.32 with a weight of 1.0; squared sum of \n\u003e the deviation to the desired velocity, valued at 0.00 with a weight of 20.0; squared sum of the deviation to the \n\u003e desired orientation, valued at 0.06 with a weight of 50.0.\n\n\u003e There are also some pre-defined helper functions can be directly called in the heuristic function:\n\u003e```\n\u003edef calc_acceleration_cost(self, path: List[KSState]) -\u003e float:\n\u003e        \"\"\"Returns the acceleration costs.\"\"\"\n\u003e```\n\u003e```\n\u003edef calc_path_efficiency(self, path: List[KSState]) -\u003e float:\n\u003e        \"\"\"Returns the path efficiency = travelled_distance / time_cost.\"\"\"\n\u003e```\n\u003e```\n\u003edef calc_steering_angle_cost(self, path: List[KSState]) -\u003e float:\n\u003e        \"\"\"Returns steering angle cost of the given path.\"\"\"\n\u003e```\n\u003e```\n\u003edef calc_steering_velocity_cost(self, path: List[KSState]) -\u003e float:\"\"\"\n\u003e        \"\"\"Returns steering velocity cost of the given path.\"\"\"\n\u003e```\n\u003e\n\u003eExample:\n\u003e```\n\u003e    def heuristic_function(self, node_current: PriorityNode) -\u003e float:\n\u003e\n\u003e        if self.reached_goal(path_last):\n\u003e            return 0\n\u003e        if self.position_desired is None:\n\u003e            return ...\n\u003e        else:\n\u003e            ...\n\u003e        # total cost\n\u003e        cost = path_efficiency\n\u003e        if cost \u003c 0:\n\u003e            cost = 0\n\u003e        return cost\n\u003e```\n\u003eImproved result:\u003cbr\u003e\n\u003eDiagnosis: the acceleration is not considered \u003cbr\u003e\n\u003ePrescription: add acceleration cost to the heuristic function\u003cbr\u003e\n\u003eDiagnosis: the heuristic should not return 0 when reaching goal region\u003cbr\u003e\n\u003ePrescription: set a certain heuristic when reaching the goal\u003cbr\u003e\n\u003e```\n\u003e    def heuristic_function(self, node_current: PriorityNode) -\u003e float:\n\u003e        acceleration_cost = self.calc_acceleration_cost(path_last)\n\u003e        if self.reached_goal(path_last):\n\u003e            return path_efficiency + acceleration_cost + ...\n\u003e        if self.position_desired is None:\n\u003e            return ...\n\u003e        else:\n\u003e            ...\n\u003e        cost = path_efficiency + acceleration_cost\n\u003e        if cost \u003c 0:\n\u003e            cost = 0\n\u003e        return cost\n\u003e```\n\n\u003eFeasible motion primitives with the same name format that you can directly use, pls be careful about the name:\n\u003e'V_0.0_20.0_Vstep_1.0_SA_-1.066_1.066_SAstep_0.27_T_0.5_Model_BMW_320i.xml',\n\u003e'V_0.0_20.0_Vstep_1.0_SA_-1.066_1.066_SAstep_2.13_T_0.5_Model_BMW_320i.xml',\n\u003e'V_0.0_20.0_Vstep_2.0_SA_-1.066_1.066_SAstep_0.18_T_0.5_Model_BMW_320i.xml',\n\u003e'V_0.0_20.0_Vstep_2.22_SA_-1.066_1.066_SAstep_0.18_T_0.5_Model_BMW_320i.xml',\n\u003e'V_0.0_20.0_Vstep_2.86_SA_-1.066_1.066_SAstep_0.18_T_0.5_Model_BMW_320i.xml',\n\u003e'V_0.0_20.0_Vstep_3.33_SA_-1.066_1.066_SAstep_0.18_T_0.5_Model_BMW_320i.xml',\n\u003e'V_0.0_20.0_Vstep_4.0_SA_-1.066_1.066_SAstep_0.18_T_0.5_Model_BMW_320i.xml'\n \n\u003c/details\u003e\n\n## 🔖 Citation\nIf you find our paper and codes useful, we highly encourage you to cite our paper:\n\n```bibtex\n@article{DrPlanner,\n  title = {{DrPlanner}: Diagnosis and Repair of Motion Planners for Autonomous Vehicles Using Large Language Models},\n  author = {Yuanfei Lin and Chenran Li and Mingyu Ding and Masayoshi Tomizuka and Wei Zhan and Matthias Althoff},\n  journal = {IEEE Robotics and Automation Letters},\n  volume = {9},\n  number = {10},\n  pages = {8218-8225},\n  year = {2024}}\n```\n\n## 📝 License\nBSD 3-Clause License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommonroad%2Fdrplanner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcommonroad%2Fdrplanner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommonroad%2Fdrplanner/lists"}