mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-12-02 09:03:43 +08:00
Preserve Mazda AOL intent at a complete stop
This commit is contained in:
@@ -2298,9 +2298,11 @@ class SelfdriveD:
|
||||
self.ordinary_native_long_withdrawal(
|
||||
CS, native, previous, requested, intent, source_current=source_current, now_ns=now_ns))
|
||||
from openpilot.starpilot.car.hyundai.aol import expected_stopped_lateral_denial
|
||||
from openpilot.starpilot.car.mazda.aol import expected_stopped_lateral_denial as mazda_stopped_denial
|
||||
stopped_lateral_withdrawal = bool(source_current and requested.desired_lateral and
|
||||
expected_stopped_lateral_denial(self.CP, CS, native, sm=self.sm,
|
||||
axis_session_id=self.aol_session_id, now_ns=now_ns))
|
||||
(expected_stopped_lateral_denial(self.CP, CS, native, sm=self.sm,
|
||||
axis_session_id=self.aol_session_id, now_ns=now_ns) or
|
||||
mazda_stopped_denial(self.CP, CS, native, sm=self.sm, axis_session_id=self.aol_session_id, now_ns=now_ns)))
|
||||
lost_permission = bool(lost_honda_lateral_grant or native is not None and not driver_override and (
|
||||
previous.lateral_active and requested.desired_lateral and native.requestedLateral and
|
||||
not native.lateralAllowed and not stopped_lateral_withdrawal and
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
from contextlib import ExitStack
|
||||
|
||||
import pytest
|
||||
|
||||
from opendbc.car import gen_empty_fingerprint
|
||||
from opendbc.car.mazda.interface import CarInterface
|
||||
from opendbc.car.mazda.values import CAR
|
||||
from openpilot.cereal import log
|
||||
from openpilot.common.params import Params
|
||||
from openpilot.common.prefix import OpenpilotPrefix
|
||||
from openpilot.starpilot.aol.intent import read_settings
|
||||
from openpilot.starpilot.aol.tests import test_ioniq_availability as fixture
|
||||
|
||||
|
||||
@pytest.mark.parametrize('identity', [CAR.MAZDA_CX5, CAR.MAZDA_CX5_2022, CAR.MAZDA_CX9_2021])
|
||||
@pytest.mark.parametrize('case_name', ['launch', 'moving_denial', 'panda_fault'])
|
||||
def test_mazda_intersection_aol(identity, case_name):
|
||||
with OpenpilotPrefix(), ExitStack() as cleanup:
|
||||
case = fixture.IoniqAvailabilityTests(methodName='runTest')
|
||||
cleanup.callback(case.doCleanups)
|
||||
params = Params()
|
||||
params.put('AolBrakePauseSpeedMps', 0.0, block=True)
|
||||
params.put('PauseLateralSpeed', 0.0, block=True)
|
||||
params.put_bool('PauseLateralOnSignal', False, block=True)
|
||||
cp = CarInterface.get_params(identity, gen_empty_fingerprint(), [], False, False, False)
|
||||
sd, _, step = case._authority_callers(False, cp=cp, genuine_events=True)
|
||||
sd.aol_settings = read_settings(params)
|
||||
assert sd.aol_settings.pause_brake_mps == 0.0
|
||||
state = fixture.car_state()
|
||||
state.leftBlinker = True
|
||||
state.cruiseState.enabled = True
|
||||
state.vEgo = state.vEgoRaw = 20.0
|
||||
axis, _, command = step(2, observed_state=state, native_request_long=False)
|
||||
assert axis.lateralActive and command.latActive and not command.longActive
|
||||
state.standstill = case_name != 'moving_denial'
|
||||
if state.standstill:
|
||||
state.vEgo = state.vEgoRaw = 0.0
|
||||
axis, _, command = step(3, observed_state=state, allowed=False, native_request_long=False,
|
||||
panda_fault=case_name == 'panda_fault')
|
||||
assert not axis.lateralActive and not command.latActive and not command.longActive
|
||||
if case_name != 'launch':
|
||||
assert log.OnroadEvent.EventName.controlsMismatch in sd.events.names
|
||||
return
|
||||
assert log.OnroadEvent.EventName.controlsMismatch not in sd.events.names
|
||||
assert not sd.aol_authority_lost
|
||||
state.cruiseState.enabled = False
|
||||
for tick in range(4, 30):
|
||||
state.brakePressed = tick < 27
|
||||
axis, _, command = step(tick, observed_state=state, gas=tick >= 28, allowed=False, native_request_long=False)
|
||||
assert not command.latActive and not command.longActive and not sd.aol_authority_lost
|
||||
assert sd.aol_last_intent.allowedLatch
|
||||
state.standstill = state.brakePressed = False
|
||||
state.vEgo = state.vEgoRaw = 20.0
|
||||
axis, _, command = step(30, observed_state=state, gas=True, native_request_long=False)
|
||||
assert axis.lateralActive and command.latActive and not command.longActive
|
||||
assert sd.aol_last_intent.allowedLatch and not sd.aol_authority_lost
|
||||
state.brakePressed = True
|
||||
axis, _, command = step(31, observed_state=state, native_request_long=False)
|
||||
assert axis.lateralActive and command.latActive and not command.longActive
|
||||
@@ -61,3 +61,14 @@ def physical_cancel_lateral_allowed(cp, cs, intent, native, *, settings, previou
|
||||
native.validUntilMonoTime - native.observedMonoTime <= SAFETY_MAX_AGE_NS)
|
||||
except (AttributeError, KeyError, IndexError, TypeError, ValueError, OverflowError):
|
||||
return False
|
||||
|
||||
|
||||
def expected_stopped_lateral_denial(cp, state, native, *, sm, axis_session_id, now_ns):
|
||||
from openpilot.starpilot.aol.transport_pause import _configured_transport_native
|
||||
|
||||
return bool(qualified(cp, marked_only=True) and state.canValid and not state.canTimeout and
|
||||
state.standstill and state.gearShifter == structs.CarState.GearShifter.drive and
|
||||
state.cruiseState.available and not state.steerFaultPermanent and not state.accFaulted and
|
||||
native is not None and native.pandaInventory and native.requestedLateral and not native.lateralAllowed and
|
||||
not native.requestedLongitudinal and not native.longitudinalAllowed and
|
||||
_configured_transport_native(sm, cp, axis_session_id, now_ns, native, allow_restricted_lateral=True) == native)
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"protected_inventory_sha256": "f246feb0ff07569ec85358f250cb15a4bb551061b5667029e29743f718b264a1", "schema_version": 1}
|
||||
{"protected_inventory_sha256": "703c31923ca9ac0e47c15dfead33cbf9f47ee1de2c6be833345d4b88ad2cc0ed", "schema_version": 1}
|
||||
|
||||
Reference in New Issue
Block a user