From 5ce6ce6c00ae9cc851c04e7226d482ae2f3b960f Mon Sep 17 00:00:00 2001 From: Arne Schwarck Date: Mon, 7 Sep 2020 15:03:35 +0200 Subject: [PATCH] Fix for cars having higher / lower set speeds this is to avoid a crash in the code --- selfdrive/car/toyota/carstate.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/selfdrive/car/toyota/carstate.py b/selfdrive/car/toyota/carstate.py index cd12f3da96d574..bb1e799b01a073 100644 --- a/selfdrive/car/toyota/carstate.py +++ b/selfdrive/car/toyota/carstate.py @@ -202,7 +202,6 @@ def update(self, cp, cp_cam, frame): else: self.low_speed_lockout = cp.vl["PCM_CRUISE_2"]['LOW_SPEED_LOCKOUT'] == 2 ret.cruiseState.available = self.main_on - v_cruise_pcm_max = ret.cruiseState.speed if self.CP.carFingerprint in TSS2_CAR: minimum_set_speed = 27.0 elif self.CP.carFingerprint == CAR.RAV4: @@ -212,6 +211,11 @@ def update(self, cp, cp_cam, frame): maximum_set_speed = 169.0 if self.CP.carFingerprint == CAR.LEXUS_RXH: maximum_set_speed = 177.0 + v_cruise_pcm_max = ret.cruiseState.speed + if v_cruise_pcm_max < minimum_set_speed: + minimum_set_speed = v_cruise_pcm_max + if v_cruise_pcm_max > maximum_set_speed: + maximum_set_speed = v_cruise_pcm_max speed_range = maximum_set_speed-minimum_set_speed if bool(cp.vl["PCM_CRUISE"]['CRUISE_ACTIVE']) and not self.pcm_acc_active and self.v_cruise_pcmlast != ret.cruiseState.speed: if ret.vEgo < 12.5: