Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Implementation of the real-time MPC based on iLQR in Carla simulator
| Date | Stars |
|---|---|
| 2026-07-24 | 316 |
| 2026-07-25 | 316 |
| 2026-07-28 | 316 |
| 2026-07-30 | 316 |
| 2026-08-06 | 316 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
# Real-time MPC with iLQR for Self-Driving in Carla
> This project is an extension of my course project in [ES 202: Estimation and Control of Dynamical System](https://nali.seas.harvard.edu/classes/es-202-estimation-and-control-dynamical-system).
I really appreciate the collaboration of my teammates: [En-Yu Yang](https://github.com/danielyang2055) and [Feicheng Wang](https://statistics.fas.harvard.edu/people/feicheng-want).
The majority of self-driving implementations in Carla are model-free RL. To achieve higher sample efficiency, a model-based algorithm will be preferred, eg. iLQR. However, Carla doesn't provide a set of equations for the dynamical model, so the first step here is to collect data and fit a differentiable model. The next step is to incorporate the model into iLQR framework. Before running iLQR, we're required to define the cost function, eg. distance to the reference path, and constraints. Luckily, Carla has an API for planning routes represented by waypoints, and the range of control input is written in Carla document. The final MPC-iLQR algorithm will be run at 10Hz.
Table of contents
=================
<!--ts-->
* [1. Video Demonstration](#Video-Demonstration)
* [2. Implementation Details](#Implementation-Details)
* [2.1 System Identification](#System-Identification)
* [2.1.1 Data Collection](#Data-Collection)
* [2.1.2 Model Choice](#model-choice)
* [2.1.3 Test](#test)
* [2.2 iLQR](#ilqr)
* [2.2.1 Why JAX: Choice of Automatic Differentiation Framework](#Why-JAX-Choice-of-Automatic-Differentiation-Framework)
* [2.2.2 Input Constraint](#input-constraint)
* [2.2.3 First Task: Pure Pursuit](#first-task-pure-pursuit)
* [2.2.4 Advanced Task: Route Following](#Advanced-Task-Route-Following)
* [2.3 MPC](#MPC)
* [3. To Do List](#to-do-list)
<!--te-->
## Video-Demonstration
[](https://www.youtube.com/watch?v=AEuxxsT1zcI)
## Implementation-Details
### System-Identification
#### Data-Collection
To simplify the problem, the model data were collected manually through pressing `WASD` in `pygame` interface. Check files: `model_data_collection_preparation.py` and `model_data_collection_main.py`. The crux is to cover a wider range of states, as uniform as possible, and disturb the motion occasionally.
#### Model-Choice
One pitfall here is to use end-to-end model, i.e. fully connected neural network with no prior of the dynamics. There will be no guarantee of the long-term stability and symmetry. Instead, my final version is based on the bicycle model.
<p align="center">
<img src="https://i.imgur.com/WuE3eh4.png" width="350">
</p>
*(Image credit to [`Robust Model Predictive Control for Autonomous Vehicles/Self Driving Cars`](https://www.semanticscholar.org/paper/Robust-Model-Predictive-Control-for-Autonomous-Cars-Law-Dalal/cb2caa552a7c758042e1aada089c4d133fceb8d2))*
However, we couldn't directly apply the kinematic bicycle model. The relationship between acceleration and throttle, and the one between  and , are unknown. Besides, the length parameters,  and , remain to be identified. Therefore, part of the dynamical model is a black box, and could be represented by a nerual network (NN).
My final model has the following form:
<p align="center">
<img src="https://i.imgur.com/KQvNkDY.jpg" width="400">
</p>
, where  and  are the two outputs of a NN.
There're several tricks to increase the accuracy of the dynamical model.
* The first is the invariant of model to poExcerpt of 17,635 characters
Read on GitHubWould you bet a product on this? Bounded 0–100 and slow moving.
matched fp:d3b8d89f5d8f386a, topic:jax, readme:automatic differentiation
matched fp:d3b8d89f5d8f386a, topic:self-driving-car, readme:self-driving