From 82571806117900d8e10026ec29adc02ed70fb78b Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Mon, 23 Sep 2024 21:29:28 -0700 Subject: [PATCH] compensate for creeping force --- opendbc/car/toyota/carstate.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/opendbc/car/toyota/carstate.py b/opendbc/car/toyota/carstate.py index 4df37d1158..f0c6c1bd8a 100644 --- a/opendbc/car/toyota/carstate.py +++ b/opendbc/car/toyota/carstate.py @@ -57,8 +57,12 @@ def update(self, cp, cp_cam, *_) -> structs.CarState: # CLUTCH->ACCEL_NET is only accurate for gas, PCM_CRUISE->ACCEL_NET is only accurate for brake # These signals only have meaning when ACC is active if self.CP.flags & ToyotaFlags.RAISED_ACCEL_LIMIT: - # Sometimes ACC_BRAKING can be 1 while showing we're applying gas already self.pcm_accel_net = max(cp.vl["CLUTCH"]["ACCEL_NET"], 0.0) + + # add creeping force at low speeds, CLUTCH->ACCEL_NET already shows negative force from engine braking + self.pcm_accel_net += max(cp.vl["PCM_CRUISE"]["NEUTRAL_FORCE"] / self.CP.mass, 0.0) + + # Sometimes ACC_BRAKING can be 1 while showing we're applying gas already if cp.vl["PCM_CRUISE"]["ACC_BRAKING"]: self.pcm_accel_net += min(cp.vl["PCM_CRUISE"]["ACCEL_NET"], 0.0)