alternative experience

This commit is contained in:
Jason Wen
2024-09-18 08:57:58 -04:00
parent 8bb6c8fc17
commit c06d8db015
3 changed files with 18 additions and 5 deletions
+1 -1
Submodule panda updated: 93aedd987b...b23543d112
+3
View File
@@ -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")
+14 -4
View File
@@ -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)