mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-12-03 23:53:40 +08:00
Retain Hyundai classic AOL intent through stock cruise off lag
This commit is contained in:
@@ -360,3 +360,48 @@ def test_missing_or_malformed_vehicle_policy_grants_no_intent_capability(cp):
|
||||
elif cp == 'malformed_registered_brand':
|
||||
cp = SimpleNamespace(brand='hyundai')
|
||||
assert not policy_for(cp).intent_supported
|
||||
|
||||
|
||||
@pytest.mark.parametrize('gas', [False, True])
|
||||
def test_classic_hyundai_main_off_lag_retains_independent_lateral_intent(gas):
|
||||
from opendbc.car import gen_empty_fingerprint
|
||||
from opendbc.car.hyundai.interface import CarInterface
|
||||
from opendbc.car.hyundai.values import CAR
|
||||
from opendbc.car.hyundai.classic_scc_aol import aol_word
|
||||
from openpilot.cereal import messaging
|
||||
|
||||
fingerprint = gen_empty_fingerprint()
|
||||
fingerprint[0].update({0x391: 8, 0x38d: 8})
|
||||
fingerprint[2][0x485] = 4
|
||||
fingerprint[1][0x500] = 8
|
||||
cp = CarInterface.get_params(CAR.HYUNDAI_SONATA_HYBRID, fingerprint, [], False, False, False)
|
||||
cp.safetyConfigs[0].safetyParam = aol_word(cp)
|
||||
cp.alternativeExperience = 32
|
||||
case = fixture.IoniqAvailabilityTests(methodName='runTest')
|
||||
with ExitStack() as cleanup:
|
||||
cleanup.callback(case.doCleanups)
|
||||
cleanup.enter_context(OpenpilotPrefix())
|
||||
sd, _, drive, card, receive = case._ioniq_availability_callers(full_op=False, cp=cp)
|
||||
state = fixture.car_state()
|
||||
state.cruiseState.available = False
|
||||
state.cruiseState.enabled = False
|
||||
state.gasPressed = gas
|
||||
|
||||
def state_event(tick):
|
||||
message = messaging.new_message('carState', valid=True, logMonoTime=10_000_000_000 + tick * 10_000_000)
|
||||
message.carState = state
|
||||
return message
|
||||
|
||||
axis, _, command = drive(2, car_state_message=state_event(2), native_request_long=False)
|
||||
assert axis.lateralActive and command.latActive
|
||||
assert receive(10_020_000_000, axis=sd.pm.messages['aolAxisState'], event=sd.pm.messages['onroadEvents'],
|
||||
state=state, preserve_cruise_state=True)
|
||||
with mock.patch.object(type(sd.rk), 'lagging', new_callable=mock.PropertyMock, return_value=True):
|
||||
axis, alerts, command = drive(3, car_state_message=state_event(3), native_request_long=False)
|
||||
assert alerts.alertType == 'selfdrivedLagging/softDisable'
|
||||
assert not axis.lateralActive and not axis.longitudinalActive and not axis.nativeAcknowledged
|
||||
assert not command.latActive and not command.longActive
|
||||
events = sd.pm.messages['onroadEvents']
|
||||
assert any(event.name == 'wrongCarMode' and event.userDisable for event in events.onroadEvents)
|
||||
assert receive(10_030_000_000, axis=sd.pm.messages['aolAxisState'], event=events, state=state, preserve_cruise_state=True)
|
||||
assert card.aol_transport_feedback.ordinary_warning_qualified
|
||||
|
||||
@@ -303,6 +303,7 @@ class TransportPauseFeedback:
|
||||
return native
|
||||
|
||||
def _ordinary_warning_intent_current(self, sm, cp, cs, axis, stamp, now_ns, *, latched, producer):
|
||||
from opendbc.car.hyundai.classic_scc_aol import qualified as stock_classic_qualified
|
||||
from openpilot.starpilot.aol.vehicle import policy_for
|
||||
from openpilot.starpilot.nostalgia import physical_cancel
|
||||
|
||||
@@ -336,7 +337,14 @@ class TransportPauseFeedback:
|
||||
released_brake = bool(self.ordinary_warning_retained and not cs.brakePressed and not cs.regenBraking and
|
||||
brake_proof is not None and brake_proof[0] == event_ns and
|
||||
brake_proof[2:] == (self.session, producer, self.availability_epoch) and now_ns <= brake_proof[1])
|
||||
stock_main_off = bool(self.lateral_only_baseline and cp.brand == 'hyundai' and not policy.cruise_main_required and
|
||||
(warning or recovering or pending) and not cs.cruiseState.available and not cs.cruiseState.enabled and
|
||||
not cs.brakePressed and not cs.regenBraking and not cs.buttonEvents and
|
||||
not axis.desiredLongitudinal and not axis.longitudinalActive and
|
||||
all(not event.softDisable or event.name == log.OnroadEvent.EventName.selfdrivedLagging for event in events) and
|
||||
stock_classic_qualified(cp, marked_only=True))
|
||||
if any(event.userDisable and event.name != stock_user and not (
|
||||
event.name == log.OnroadEvent.EventName.wrongCarMode and stock_main_off and not event.softDisable or
|
||||
event.name == log.OnroadEvent.EventName.pedalPressed and (cs.brakePressed or cs.regenBraking or released_brake) or
|
||||
event.name == log.OnroadEvent.EventName.buttonCancel and (physical_cancel(cs, cp) or
|
||||
cp.brand == 'gm' and 0 < self.gm_withdrawal_ns == event_ns <= now_ns and
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"protected_inventory_sha256": "be1521810393a3fa50a01667e65461e2fa573d9267ed17259dece3b3b4bd0e1f", "schema_version": 1}
|
||||
{"protected_inventory_sha256": "9c564ccd4ce5203927879f4ea354c58fd085c0d460aab6d31d809281e9b67aa4", "schema_version": 1}
|
||||
|
||||
Reference in New Issue
Block a user