MADS: better brake state handling - part 3

This commit is contained in:
Jason Wen
2023-02-01 17:26:30 -05:00
parent 4f35b842d2
commit bb0fad232b
10 changed files with 10 additions and 11 deletions
+1 -1
View File
@@ -113,7 +113,7 @@ class CarInterface(CarInterfaceBase):
self.CS.accEnabled = False
self.CS.accEnabled = ret.cruiseState.enabled or self.CS.accEnabled
ret, self.CS = self.get_sp_common_state(ret, self.CS, c.cruiseControl.cancel)
ret, self.CS = self.get_sp_common_state(ret, self.CS)
# CANCEL
if self.CS.out.cruiseState.enabled and not ret.cruiseState.enabled:
+1 -1
View File
@@ -243,7 +243,7 @@ class CarInterface(CarInterfaceBase):
self.CS.accEnabled = False
self.CS.accEnabled = ret.cruiseState.enabled or self.CS.accEnabled
ret, self.CS = self.get_sp_common_state(ret, self.CS, c.cruiseControl.cancel)
ret, self.CS = self.get_sp_common_state(ret, self.CS)
# MADS BUTTON
if self.CS.out.madsEnabled != self.CS.madsEnabled:
+1 -1
View File
@@ -344,7 +344,7 @@ class CarInterface(CarInterfaceBase):
self.CS.accEnabled = False
self.CS.accEnabled = ret.cruiseState.enabled or self.CS.accEnabled
ret, self.CS = self.get_sp_common_state(ret, self.CS, c.cruiseControl.cancel)
ret, self.CS = self.get_sp_common_state(ret, self.CS)
ret.buttonEvents = buttonEvents
+1 -1
View File
@@ -335,7 +335,7 @@ class CarInterface(CarInterfaceBase):
if self.get_sp_pedal_disengage(ret.brakePressed, ret.standstill):
self.CS.madsEnabled = False if not self.enable_mads else self.CS.madsEnabled
ret, self.CS = self.get_sp_common_state(ret, self.CS, c.cruiseControl.cancel)
ret, self.CS = self.get_sp_common_state(ret, self.CS)
# MADS BUTTON
if self.CS.out.madsEnabled != self.CS.madsEnabled:
+1 -2
View File
@@ -363,12 +363,11 @@ class CarInterfaceBase(ABC):
def get_sp_pedal_disengage(self, brake_pressed, standstill):
return brake_pressed and (not self.CS.out.brakePressed or not standstill)
def get_sp_common_state(self, cs_out, CS, controls_cancel, gear_allowed=True):
def get_sp_common_state(self, cs_out, CS, gear_allowed=True):
if self.CP.pcmCruise:
if not cs_out.cruiseState.enabled and CS.out.cruiseState.enabled:
CS.madsEnabled, cs_out.cruiseState.enabled = self.get_sp_cancel_cruise_state(CS.madsEnabled)
CS.accEnabled = False if controls_cancel else CS.accEnabled
cs_out.cruiseState.enabled = cs_out.cruiseState.enabled if self.CP.pcmCruise else CS.accEnabled
if not self.enable_mads:
if cs_out.cruiseState.enabled and not CS.out.cruiseState.enabled:
+1 -1
View File
@@ -83,7 +83,7 @@ class CarInterface(CarInterfaceBase):
self.get_sp_pedal_disengage(ret.brakePressed, ret.standstill):
self.CS.madsEnabled = False if not self.enable_mads else self.CS.madsEnabled
ret, self.CS = self.get_sp_common_state(ret, self.CS, c.cruiseControl.cancel)
ret, self.CS = self.get_sp_common_state(ret, self.CS)
# MADS BUTTON
if self.CS.out.madsEnabled != self.CS.madsEnabled:
+1 -1
View File
@@ -64,7 +64,7 @@ class CarInterface(CarInterfaceBase):
self.get_sp_pedal_disengage(ret.brakePressed, ret.standstill):
self.CS.madsEnabled = False if not self.enable_mads else self.CS.madsEnabled
ret, self.CS = self.get_sp_common_state(ret, self.CS, c.cruiseControl.cancel)
ret, self.CS = self.get_sp_common_state(ret, self.CS)
# CANCEL
if self.CS.out.cruiseState.enabled and not ret.cruiseState.enabled:
+1 -1
View File
@@ -136,7 +136,7 @@ class CarInterface(CarInterfaceBase):
if self.get_sp_pedal_disengage(ret.brakePressed, ret.standstill):
self.CS.madsEnabled = False if not self.enable_mads else self.CS.madsEnabled
ret, self.CS = self.get_sp_common_state(ret, self.CS, c.cruiseControl.cancel)
ret, self.CS = self.get_sp_common_state(ret, self.CS)
# CANCEL
if self.CS.out.cruiseState.enabled and not ret.cruiseState.enabled:
+1 -1
View File
@@ -266,7 +266,7 @@ class CarInterface(CarInterfaceBase):
self.get_sp_pedal_disengage(ret.brakePressed, ret.standstill):
self.CS.madsEnabled = False if not self.enable_mads else self.CS.madsEnabled
ret, self.CS = self.get_sp_common_state(ret, self.CS, c.cruiseControl.cancel)
ret, self.CS = self.get_sp_common_state(ret, self.CS)
# CANCEL
if self.CS.out.cruiseState.enabled and not ret.cruiseState.enabled:
+1 -1
View File
@@ -234,7 +234,7 @@ class CarInterface(CarInterfaceBase):
self.CS.accEnabled = False
self.CS.accEnabled = ret.cruiseState.enabled or self.CS.accEnabled
ret, self.CS = self.get_sp_common_state(ret, self.CS, c.cruiseControl.cancel)
ret, self.CS = self.get_sp_common_state(ret, self.CS)
# MADS BUTTON
if self.CS.out.madsEnabled != self.CS.madsEnabled: