|
|
|
@ -5,7 +5,7 @@ from selfdrive.car.toyota.toyotacan import create_steer_command, create_ui_comma |
|
|
|
|
create_accel_command, create_acc_cancel_command, \ |
|
|
|
|
create_fcw_command, create_lta_steer_command |
|
|
|
|
from selfdrive.car.toyota.values import CAR, STATIC_DSU_MSGS, NO_STOP_TIMER_CAR, TSS2_CAR, \ |
|
|
|
|
MIN_ACC_SPEED, PEDAL_HYST_GAP, CarControllerParams |
|
|
|
|
MIN_ACC_SPEED, PEDAL_HYST_GAP, PEDAL_SCALE, CarControllerParams |
|
|
|
|
from opendbc.can.packer import CANPacker |
|
|
|
|
VisualAlert = car.CarControl.HUDControl.VisualAlert |
|
|
|
|
|
|
|
|
@ -44,9 +44,7 @@ class CarController(): |
|
|
|
|
|
|
|
|
|
# gas and brake |
|
|
|
|
interceptor_gas_cmd = 0. |
|
|
|
|
# TODO this is needed to preserve behavior, but doesn't make sense |
|
|
|
|
# This can all be cleaned up |
|
|
|
|
pcm_accel_cmd = actuators.accel / CarControllerParams.ACCEL_SCALE |
|
|
|
|
pcm_accel_cmd = actuators.accel |
|
|
|
|
|
|
|
|
|
if CS.CP.enableGasInterceptor: |
|
|
|
|
# handle hysteresis when around the minimum acc speed |
|
|
|
@ -57,13 +55,13 @@ class CarController(): |
|
|
|
|
|
|
|
|
|
if self.use_interceptor and enabled: |
|
|
|
|
# only send negative accel when using interceptor. gas handles acceleration |
|
|
|
|
# +0.06 offset to reduce ABS pump usage when OP is engaged |
|
|
|
|
# +0.18 m/s^2 offset to reduce ABS pump usage when OP is engaged |
|
|
|
|
MAX_INTERCEPTOR_GAS = interp(CS.out.vEgo, [0.0, MIN_ACC_SPEED], [0.2, 0.5]) |
|
|
|
|
interceptor_gas_cmd = clip(actuators.accel/CarControllerParams.ACCEL_SCALE, 0., MAX_INTERCEPTOR_GAS) |
|
|
|
|
pcm_accel_cmd = 0.06 - clip(-actuators.accel/CarControllerParams.ACCEL_SCALE, 0., 1.) |
|
|
|
|
interceptor_gas_cmd = clip(actuators.accel / PEDAL_SCALE, 0., MAX_INTERCEPTOR_GAS) |
|
|
|
|
pcm_accel_cmd = 0.18 - max(0, -actuators.accel) |
|
|
|
|
|
|
|
|
|
pcm_accel_cmd, self.accel_steady = accel_hysteresis(pcm_accel_cmd, self.accel_steady, enabled) |
|
|
|
|
pcm_accel_cmd = clip(pcm_accel_cmd * CarControllerParams.ACCEL_SCALE, CarControllerParams.ACCEL_MIN, CarControllerParams.ACCEL_MAX) |
|
|
|
|
pcm_accel_cmd = clip(pcm_accel_cmd, CarControllerParams.ACCEL_MIN, CarControllerParams.ACCEL_MAX) |
|
|
|
|
|
|
|
|
|
# steer torque |
|
|
|
|
new_steer = int(round(actuators.steer * CarControllerParams.STEER_MAX)) |
|
|
|
|