Skip to content
Open
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Your controller should implement a new [controller](https://github.com/commaai/c
## Evaluation
Each rollout will result in 2 costs:
- `lataccel_cost`: $\dfrac{\Sigma(\mathrm{actual{\textunderscore}lat{\textunderscore}accel} - \mathrm{target{\textunderscore}lat{\textunderscore}accel})^2}{\text{steps}} * 100$
- `jerk_cost`: $\dfrac{(\Sigma( \mathrm{actual{\textunderscore}lat{\textunderscore}accel_t} - \mathrm{actual{\textunderscore}lat{\textunderscore}accel_{t-1}}) / \Delta \mathrm{t} )^{2}}{\text{steps} - 1} * 100$
- `jerk_cost`: $\dfrac{(\Sigma( \mathrm{actual{\textunderscore}lat{\textunderscore}accel_t} - \mathrm{actual{\textunderscore}lat{\textunderscore}accel_{t-1}}) / \Delta \mathrm{t} )^{2}}{\text{steps}} * 100$

It is important to minimize both costs. `total_cost`: $(\mathrm{lat{\textunderscore}accel{\textunderscore}cost} * 50) + \mathrm{jerk{\textunderscore}cost}$

Expand Down
4 changes: 2 additions & 2 deletions tinyphysics.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ def plot_data(self, ax, lines, axis_labels, title) -> None:

def compute_cost(self) -> Dict[str, float]:
target = np.array(self.target_lataccel_history)[CONTROL_START_IDX:COST_END_IDX]
pred = np.array(self.current_lataccel_history)[CONTROL_START_IDX:COST_END_IDX]
pred = np.array(self.current_lataccel_history)[CONTROL_START_IDX-1:COST_END_IDX]

lat_accel_cost = np.mean((target - pred)**2) * 100
lat_accel_cost = np.mean((target - pred[1:])**2) * 100
jerk_cost = np.mean((np.diff(pred) / DEL_T)**2) * 100
total_cost = (lat_accel_cost * LAT_ACCEL_COST_MULTIPLIER) + jerk_cost
return {'lataccel_cost': lat_accel_cost, 'jerk_cost': jerk_cost, 'total_cost': total_cost}
Expand Down
Loading