sonata hybrid

This commit is contained in:
firestar5683
2026-06-28 22:05:55 -05:00
parent f4bc8ee6b7
commit 2e53b419d1
2 changed files with 2 additions and 37 deletions
+1 -12
View File
@@ -37,7 +37,6 @@ class StarPilotCard:
getattr(self.CP, "carFingerprint", None) in (HYUNDAI_CAR.KIA_FORTE_2019_NON_SCC, HYUNDAI_CAR.KIA_FORTE_2021_NON_SCC) and
bool(hyundai_flags & HyundaiFlags.NON_SCC)
)
self.hyundai_lkas_aol_requires_engagement = getattr(self.CP, "carFingerprint", None) == HYUNDAI_CAR.HYUNDAI_SONATA_HYBRID
self.hyundai_aol_needs_engagement = self.CP.brand == "hyundai" and not (hyundai_flags & HyundaiFlags.CANFD) and not kia_forte_non_scc
self.hyundai_aol_ready = False
self.prev_active = False
@@ -114,27 +113,17 @@ class StarPilotCard:
def update(self, carState, starpilotCarState, sm, starpilot_toggles):
self.switchback_mode_enabled = self.params_memory.get_bool("SwitchbackModeEnabled")
button_event_types = [self._button_type_raw(be) for be in carState.buttonEvents]
sonata_hybrid_cruise_ready = self.hyundai_lkas_aol_requires_engagement and carState.cruiseState.available
hyundai_lkas_aol_can_toggle = (
not self.hyundai_lkas_aol_requires_engagement or
self.hyundai_aol_ready or
sm["selfdriveState"].active or
carState.cruiseState.enabled or
sonata_hybrid_cruise_ready
)
if self.hyundai_aol_needs_engagement:
if carState.gearShifter in NON_DRIVING_GEARS:
self.hyundai_aol_ready = False
self.always_on_lateral_allowed = False
elif sm["selfdriveState"].active or carState.cruiseState.enabled or sonata_hybrid_cruise_ready:
elif sm["selfdriveState"].active or carState.cruiseState.enabled:
self.hyundai_aol_ready = True
if self.CP.brand == "hyundai" or starpilot_toggles.lkas_allowed_for_aol:
for be, be_type in zip(carState.buttonEvents, button_event_types, strict=False):
if be_type == ButtonType.lkas and be.pressed and starpilot_toggles.always_on_lateral_lkas:
if not hyundai_lkas_aol_can_toggle:
continue
if self.hyundai_aol_needs_engagement:
self.hyundai_aol_ready = True
self.always_on_lateral_allowed = not self.always_on_lateral_allowed
@@ -146,7 +146,7 @@ def test_hyundai_lkas_button_can_start_aol_before_normal_engagement(monkeypatch,
assert ret.pauseLateral is False
def test_sonata_hybrid_lkas_button_does_not_start_aol_before_engagement(monkeypatch, tmp_path):
def test_sonata_hybrid_lkas_button_can_start_aol_before_normal_engagement(monkeypatch, tmp_path):
monkeypatch.setattr(spc, "Params", FakeParams)
monkeypatch.setattr(spc, "is_FrogsGoMoo", lambda: False)
monkeypatch.setattr(spc, "ERROR_LOGS_PATH", tmp_path)
@@ -163,30 +163,6 @@ def test_sonata_hybrid_lkas_button_does_not_start_aol_before_engagement(monkeypa
ret = card.update(car_state, starpilot_car_state, sm, toggles)
assert ret.alwaysOnLateralAllowed is False
assert ret.alwaysOnLateralEnabled is False
def test_sonata_hybrid_lkas_button_can_toggle_aol_after_engagement(monkeypatch, tmp_path):
monkeypatch.setattr(spc, "Params", FakeParams)
monkeypatch.setattr(spc, "is_FrogsGoMoo", lambda: False)
monkeypatch.setattr(spc, "ERROR_LOGS_PATH", tmp_path)
card = spc.StarPilotCard(
SimpleNamespace(brand="hyundai", carFingerprint=spc.HYUNDAI_CAR.HYUNDAI_SONATA_HYBRID),
SimpleNamespace(alternativeExperience=spc.ALTERNATIVE_EXPERIENCE.ALWAYS_ON_LATERAL),
)
starpilot_car_state = SimpleNamespace(distancePressed=False)
sm = make_sm()
toggles = make_toggles(always_on_lateral=True, always_on_lateral_lkas=True)
cruise_main_state = make_car_state(available=True, enabled=False)
card.update(cruise_main_state, starpilot_car_state, sm, toggles)
lkas_state = make_car_state(available=False, enabled=False, button_events=[SimpleNamespace(type=spc.ButtonType.lkas, pressed=True)])
ret = card.update(lkas_state, starpilot_car_state, sm, toggles)
assert ret.alwaysOnLateralAllowed is True
assert ret.alwaysOnLateralEnabled is True