Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

Machine learning models can drive cars, paint beautiful pictures and write passable rap. But they famously suck at doing low level controls. Your goal is to write a good controller. This repo contains a model that simulates the lateral movement of a car, given steering commands. The goal is to drive this "car" well for a given desired trajectory.


## Getting Started
We'll be using a synthetic dataset based on the [comma-steering-control](https://github.com/commaai/comma-steering-control) dataset for this challenge. These are actual car and road states from [openpilot](https://github.com/commaai/openpilot) users.

Expand All @@ -26,10 +25,10 @@ We'll be using a synthetic dataset based on the [comma-steering-control](https:/
pip install -r requirements.txt

# test this works
python tinyphysics.py --model_path ./models/tinyphysics.onnx --data_path ./data/00000.csv --debug --controller pid
python tinyphysics.py --model_path ./models/tinyphysics.onnx --data_path ./data/00000.csv --debug --controller pid
```

There are some other scripts to help you get aggregate metrics:
There are some other scripts to help you get aggregate metrics:
```
# batch Metrics of a controller on lots of routes
python tinyphysics.py --model_path ./models/tinyphysics.onnx --data_path ./data --num_segs 100 --controller pid
Expand All @@ -43,22 +42,22 @@ You can also use the notebook at [`experiment.ipynb`](https://github.com/commaai
## TinyPhysics
This is a "simulated car" that has been trained to mimic a very simple physics model (bicycle model) based simulator, given realistic driving noise. It is an autoregressive model similar to [ML Controls Sim](https://blog.comma.ai/096release/#ml-controls-sim) in architecture. Its inputs are the car velocity (`v_ego`), forward acceleration (`a_ego`), lateral acceleration due to road roll (`road_lataccel`), current car lateral acceleration (`current_lataccel`), and a steer input (`steer_action`), then it predicts the resultant lateral acceleration of the car.


## Controllers
Your controller should implement a new [controller](https://github.com/commaai/controls_challenge/tree/master/controllers). This controller can be passed as an arg to run in-loop in the simulator to autoregressively predict the car's response.


## Evaluation
Each rollout will result in 2 costs:
- `lataccel_cost`: $\dfrac{\Sigma(actual\\_lat\\_accel - target\\_lat\\_accel)^2}{steps} * 100$
- `lataccel_cost`: $\dfrac{\Sigma(\mathrm{actual\_lat\_accel} - \mathrm{target\_lat\_accel})^2}{steps} * 100$

- `jerk_cost`: $\dfrac{\Sigma((actual\\_lat\\_accel\_t - actual\\_lat\\_accel\_{t-1}) / \Delta t)^2}{steps - 1} * 100$
- `jerk_cost`: $\dfrac{\Sigma((\mathrm{actual\_lat\_accel}_t - \mathrm{actual\_lat\_accel}_{t-1}) / \Delta t)^2}{steps - 1} * 100$

It is important to minimize both costs. `total_cost`: $(lataccel\\_cost * 50) + jerk\\_cost$
It is important to minimize both costs. `total_cost`: $(\mathrm{lat\_accel\_cost} * 50) + \mathrm{jerk\_cost}$

## Submission
Run the following command, then submit `report.html` and your code to [this form](https://forms.gle/US88Hg7UR6bBuW3BA).

Competitive scores (`total_cost<100`) will be added to the leaderboard

```
python eval.py --model_path ./models/tinyphysics.onnx --data_path ./data --num_segs 5000 --test_controller <insert your controller name> --baseline_controller pid
```
Expand Down
16 changes: 8 additions & 8 deletions controllers/pid.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ class Controller(BaseController):
A simple PID controller
"""
def __init__(self,):
self.p = 0.3
self.i = 0.05
self.d = -0.1
self.p = 0.195
self.i = 0.100
self.d = -0.053
self.error_integral = 0
self.prev_error = 0

def update(self, target_lataccel, current_lataccel, state, future_plan):
error = (target_lataccel - current_lataccel)
self.error_integral += error
error_diff = error - self.prev_error
self.prev_error = error
return self.p * error + self.i * self.error_integral + self.d * error_diff
error = (target_lataccel - current_lataccel)
self.error_integral += error
error_diff = error - self.prev_error
self.prev_error = error
return self.p * error + self.i * self.error_integral + self.d * error_diff
Loading