Toyota: don't apply PCM compensation in the stopping state (#1264)

check inside so we ramp down smoothly not cut out compensation
This commit is contained in:
Shane Smiskol 2024-09-20 20:46:59 -07:00 committed by GitHub
parent 4b7c90dada
commit 0b7648ad2c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 1 deletions

View File

@ -10,6 +10,7 @@ from opendbc.car.toyota.values import CAR, STATIC_DSU_MSGS, NO_STOP_TIMER_CAR, T
UNSUPPORTED_DSU_CAR
from opendbc.can.packer import CANPacker
LongCtrlState = structs.CarControl.Actuators.LongControlState
SteerControlType = structs.CarParams.SteerControlType
VisualAlert = structs.CarControl.HUDControl.VisualAlert
@ -111,7 +112,10 @@ class CarController(CarControllerBase):
accel_due_to_pitch = math.sin(CS.slope_angle) * ACCELERATION_DUE_TO_GRAVITY
net_acceleration_request = actuators.accel + accel_due_to_pitch
pcm_accel_compensation = 2.0 * (CS.pcm_accel_net - net_acceleration_request)
# let PCM handle stopping for now
pcm_accel_compensation = 0.0
if actuators.longControlState != LongCtrlState.stopping:
pcm_accel_compensation = 2.0 * (CS.pcm_accel_net - net_acceleration_request)
# prevent compensation windup
pcm_accel_compensation = clip(pcm_accel_compensation, actuators.accel - self.params.ACCEL_MAX,