Skip to content

Commit

Permalink
Toyota safety: fixed rounding logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Commaremote committed Jun 3, 2019
1 parent 0c5b220 commit 192fd05
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions board/safety/safety_toyota.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ static void toyota_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
// scale by dbc_factor
torque_meas_new = (torque_meas_new * toyota_dbc_eps_torque_factor) / 100;

// increase torque_meas by 1 to be conservative on rounding
torque_meas_new += (torque_meas_new > 0 ? 1 : -1);

// update array of sample
update_sample(&toyota_torque_meas, torque_meas_new);

// increase torque_meas by 1 to be conservative on rounding
toyota_torque_meas.min--;
toyota_torque_meas.max++;

}

// enter controls on rising edge of ACC, exit controls on ACC off
Expand Down

0 comments on commit 192fd05

Please sign in to comment.