mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-08-06 00:15:39 +08:00
handle non drive gear events
This commit is contained in:
@@ -135,6 +135,7 @@ struct OnroadEvent @0xc4fa6047f024e718 {
|
||||
silentLkasEnable @98;
|
||||
silentBrakeHold @99;
|
||||
silentWrongGear @100;
|
||||
silentReverseGear @101;
|
||||
|
||||
soundsUnavailableDEPRECATED @47;
|
||||
}
|
||||
|
||||
@@ -1015,7 +1015,7 @@ EVENTS: dict[int, dict[str, Alert | AlertCallbackType]] = {
|
||||
},
|
||||
|
||||
EventName.silentWrongGear: {
|
||||
ET.SOFT_DISABLE: Alert(
|
||||
ET.USER_DISABLE: Alert(
|
||||
"Gear not D",
|
||||
"openpilot Unavailable",
|
||||
AlertStatus.normal, AlertSize.mid,
|
||||
@@ -1027,6 +1027,20 @@ EVENTS: dict[int, dict[str, Alert | AlertCallbackType]] = {
|
||||
Priority.LOW, VisualAlert.none, AudibleAlert.none, 0., 3.),
|
||||
},
|
||||
|
||||
EventName.silentReverseGear: {
|
||||
ET.PERMANENT: Alert(
|
||||
"Reverse\nGear",
|
||||
"",
|
||||
AlertStatus.normal, AlertSize.full,
|
||||
Priority.LOWEST, VisualAlert.none, AudibleAlert.none, .2, creation_delay=0.5),
|
||||
ET.USER_DISABLE: Alert(
|
||||
"Reverse\nGear",
|
||||
"",
|
||||
AlertStatus.normal, AlertSize.full,
|
||||
Priority.LOWEST, VisualAlert.none, AudibleAlert.none, .2, creation_delay=0.5),
|
||||
ET.NO_ENTRY: NoEntryAlert("Reverse Gear"),
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -31,14 +31,15 @@ class ModifiedAssistDrivingSystem:
|
||||
self.unified_engagement_mode = mads_params.read_param("MadsUnifiedEngagementMode", self.selfdrive.params)
|
||||
|
||||
def update_events(self, CS: car.CarState):
|
||||
if self.selfdrive.enabled_prev:
|
||||
if self.selfdrive.events.has(EventName.wrongGear) and CS.vEgo < 5:
|
||||
self.selfdrive.events.add(EventName.silentWrongGear)
|
||||
self.selfdrive.events.remove(EventName.wrongGear)
|
||||
|
||||
else:
|
||||
if not self.selfdrive.enabled:
|
||||
self.selfdrive.events.remove(EventName.wrongCruiseMode)
|
||||
self.selfdrive.events.remove(EventName.wrongCarMode)
|
||||
if self.selfdrive.events.has(EventName.wrongGear) and not self.selfdrive.events.has(EventName.reverseGear):
|
||||
self.selfdrive.events.remove(EventName.wrongGear)
|
||||
self.selfdrive.events.add(EventName.silentWrongGear)
|
||||
if self.selfdrive.events.has(EventName.reverseGear) and CS.vEgo < 5:
|
||||
self.selfdrive.events.remove(EventName.reverseGear)
|
||||
self.selfdrive.events.add(EventName.silentReverseGear)
|
||||
|
||||
if self.disengage_lateral_on_brake_toggle:
|
||||
if self.selfdrive.events.has(EventName.brakeHold):
|
||||
|
||||
@@ -31,7 +31,8 @@ class StateMachine:
|
||||
if self.state != State.disabled:
|
||||
# user and immediate disable always have priority in a non-disabled state
|
||||
if events.contains(ET.USER_DISABLE):
|
||||
if events.has(EventName.silentPedalPressed) or events.has(EventName.silentBrakeHold):
|
||||
if events.has(EventName.silentPedalPressed) or events.has(EventName.silentBrakeHold) or \
|
||||
events.has(EventName.silentWrongGear) or events.has(EventName.silentReverseGear):
|
||||
self.state = State.paused
|
||||
else:
|
||||
self.state = State.disabled
|
||||
|
||||
Reference in New Issue
Block a user