diff --git a/panda b/panda index 93aedd987b..b23543d112 160000 --- a/panda +++ b/panda @@ -1 +1 @@ -Subproject commit 93aedd987bda7e267210689b877eb87f288fc6ab +Subproject commit b23543d1127f768a843a9fb7099d1b6a52047346 diff --git a/selfdrive/car/card.py b/selfdrive/car/card.py index 62569f64f5..f8058efc97 100755 --- a/selfdrive/car/card.py +++ b/selfdrive/car/card.py @@ -24,6 +24,8 @@ from openpilot.selfdrive.car.car_specific import CarSpecificEvents, MockCarState from openpilot.selfdrive.car.helpers import convert_carControl, convert_to_capnp from openpilot.selfdrive.selfdrived.events import Events, ET +from openpilot.sunnypilot.mads.mads import ModifiedAssistDrivingSystem + REPLAY = "REPLAY" in os.environ EventName = car.OnroadEvent.EventName @@ -116,6 +118,7 @@ class Car: self.CP.alternativeExperience = 0 if not self.disengage_on_accelerator: self.CP.alternativeExperience |= ALTERNATIVE_EXPERIENCE.DISABLE_DISENGAGE_ON_GAS + self.CP.alternativeExperience |= ModifiedAssistDrivingSystem(self).set_alternative_experience() openpilot_enabled_toggle = self.params.get_bool("OpenpilotEnabledToggle") diff --git a/sunnypilot/mads/mads.py b/sunnypilot/mads/mads.py index 7149142655..b1ca55128c 100644 --- a/sunnypilot/mads/mads.py +++ b/sunnypilot/mads/mads.py @@ -1,7 +1,8 @@ from cereal import car, custom -from openpilot.sunnypilot.mads.state import Disabled, Paused, Enabled, SoftDisabling, Overriding -from openpilot.selfdrive.selfdrived.events import Events +from panda import ALTERNATIVE_EXPERIENCE + +from openpilot.sunnypilot.mads.state import Disabled, Paused, Enabled, SoftDisabling, Overriding State = custom.SelfdriveStateSP.ModifiedAssistDrivingSystem.ModifiedAssistDrivingSystemState ButtonType = car.CarState.ButtonEvent.Type @@ -25,11 +26,20 @@ class ModifiedAssistDrivingSystem: self.enabled_toggle = True # TODO-SP: Apply with toggle self.main_enabled_toggle = True # TODO-SP: Apply with toggle - self.disengage_on_brake_toggle = False # TODO-SP: Apply with toggle + self.disengage_lateral_on_brake_toggle = False # TODO-SP: Apply with toggle self.mads_enabled = False self.mads_alt_button_enabled = False + def set_alternative_experience(self, alt_experience: int = 0): + if self.enabled_toggle: + if self.disengage_lateral_on_brake_toggle: + alt_experience |= ALTERNATIVE_EXPERIENCE.ENABLE_MADS + else: + alt_experience |= ALTERNATIVE_EXPERIENCE.DISABLE_DISENGAGE_LATERAL_ON_BRAKE + + return alt_experience + def update_availability(self, CS: car.CarState, available: bool = False) -> bool: if self.main_enabled_toggle: available |= CS.cruiseState.available @@ -53,7 +63,7 @@ class ModifiedAssistDrivingSystem: self.selfdrive.events.remove(EventName.wrongCruiseMode) self.selfdrive.events.remove(EventName.wrongCarMode) - if self.disengage_on_brake_toggle: + if self.disengage_lateral_on_brake_toggle: if self.selfdrive.events.has(EventName.brakeHold): self.selfdrive.events.remove(EventName.brakeHold) self.selfdrive.events.add(EventName.silentBrakeHold)