mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-12-02 01:53:40 +08:00
subaru: enable Legacy 2025 HUD, LKAS toggle, chimes, and manumatic parity on 2025 Impreza/Crosstrek
This commit is contained in:
@@ -199,15 +199,22 @@ class CarController(CarControllerBase):
|
||||
angle_target = float(np.clip(angle_target, -200., 200.))
|
||||
max_mads_angle = 210. if self.angle_was_active else 200.
|
||||
aol_motion_ok = CC.enabled or (CS.out.vEgoRaw > 0.44704 and abs(CS.out.steeringAngleDeg) <= max_mads_angle)
|
||||
gear_ok = CS.out.gearShifter in (structs.CarState.GearShifter.drive, structs.CarState.GearShifter.manumatic)
|
||||
else:
|
||||
# Preserve large-turn admission; active Jacobw ports retain their native angle envelope.
|
||||
angle_continuation = (self.angle_was_active and self.angle_filter is not None and
|
||||
abs(CS.out.steeringAngleDeg) < JACOBW_MAX_ANGLE)
|
||||
aol_motion_ok = CC.enabled or (CS.out.vEgoRaw > 0.44704 and
|
||||
(abs(CS.out.steeringAngleDeg) < 120. or angle_continuation))
|
||||
gear_ok = CS.out.gearShifter == structs.CarState.GearShifter.drive
|
||||
legacy_lateral_off = self._legacy_2025_effective_lateral_off(CS, CC) if self.CP.carFingerprint == CAR.SUBARU_LEGACY_2025 else False
|
||||
gear_ok = (
|
||||
CS.out.gearShifter in (structs.CarState.GearShifter.drive, structs.CarState.GearShifter.manumatic)
|
||||
if self.CP.carFingerprint in FROGGER_ANGLE_SIBLINGS | {CAR.SUBARU_LEGACY_2025}
|
||||
else CS.out.gearShifter == structs.CarState.GearShifter.drive
|
||||
)
|
||||
legacy_lateral_off = (
|
||||
self._legacy_2025_effective_lateral_off(CS, CC)
|
||||
if self.CP.carFingerprint in FROGGER_ANGLE_SIBLINGS | {CAR.SUBARU_LEGACY_2025}
|
||||
else False
|
||||
)
|
||||
angle_available = (CC.latActive and aol_motion_ok and CS.out.cruiseState.available and
|
||||
(independent_lateral or (CC.enabled and CS.out.cruiseState.enabled and not CS.out.brakePressed)) and
|
||||
gear_ok and
|
||||
@@ -308,14 +315,15 @@ class CarController(CarControllerBase):
|
||||
|
||||
# *** alerts and pcm cancel ***
|
||||
frogger_hud = self.CP.carFingerprint in FROGGER_ANGLE_SIBLINGS | {CAR.SUBARU_LEGACY_2025}
|
||||
enabled_for_dash_2025 = self.angle_was_active
|
||||
if self.CP.carFingerprint == CAR.SUBARU_LEGACY_2025:
|
||||
enabled_for_dash_2025 = self._legacy_2025_aol_dash_green(
|
||||
enabled_for_dash_2025 = (
|
||||
self._legacy_2025_aol_dash_green(
|
||||
hud_control,
|
||||
CS,
|
||||
bool(CS.out.cruiseState.available),
|
||||
self._legacy_2025_effective_lateral_off(CS, CC),
|
||||
)
|
||||
if frogger_hud else self.angle_was_active
|
||||
)
|
||||
lkas_alert_msg = self._ascent_lkas_alert(CC, CS)
|
||||
if lkas_alert_msg is not None:
|
||||
can_sends.append(lkas_alert_msg)
|
||||
@@ -351,9 +359,7 @@ class CarController(CarControllerBase):
|
||||
if self.CP.carFingerprint in FROGGER_ANGLE_SIBLINGS:
|
||||
aol_enabled = aol_enabled and subaru_aol_qualified(self.CP, marked_only=True)
|
||||
wheel_ready = bool(cruise_available and aol_enabled)
|
||||
lanes_visible = hud_control.lanesVisible or (
|
||||
self.CP.carFingerprint in FROGGER_ANGLE_SIBLINGS and self.angle_was_active)
|
||||
if not (in_drive and cruise_available) or lateral_off or not lanes_visible:
|
||||
if not (in_drive and cruise_available) or lateral_off or not hud_control.lanesVisible:
|
||||
left_line = 0
|
||||
right_line = 0
|
||||
left_depart = False
|
||||
@@ -404,7 +410,7 @@ class CarController(CarControllerBase):
|
||||
self.CP.openpilotLongitudinalControl, cruise_brake > 0, cruise_throttle))
|
||||
else:
|
||||
cancel_frame_ready = True
|
||||
if self.CP.carFingerprint in (CAR.SUBARU_ASCENT_2023, CAR.SUBARU_LEGACY_2025):
|
||||
if self.CP.carFingerprint in FROGGER_ANGLE_SIBLINGS | {CAR.SUBARU_ASCENT_2023, CAR.SUBARU_LEGACY_2025}:
|
||||
stock_counter = CS.es_distance_msg["COUNTER"]
|
||||
cancel_frame_ready = stock_counter != self.ascent_es_distance_counter_last
|
||||
self.ascent_es_distance_counter_last = stock_counter
|
||||
|
||||
@@ -3,7 +3,7 @@ from opendbc.can import CANDefine, CANParser
|
||||
from opendbc.car import Bus, structs, create_button_events
|
||||
from opendbc.car.common.conversions import Conversions as CV
|
||||
from opendbc.car.interfaces import CarStateBase
|
||||
from opendbc.car.subaru.values import CAR, DBC, CanBus, SubaruFlags
|
||||
from opendbc.car.subaru.values import CAR, DBC, CanBus, FROGGER_ANGLE_SIBLINGS, SubaruFlags
|
||||
from opendbc.car import CanSignalRateCalculator
|
||||
|
||||
# 8-speed Lineartronic CVT simulated paddle-shift ratios 1..8 on 0x48 Transmission.Gear
|
||||
@@ -108,11 +108,11 @@ class CarState(CarStateBase):
|
||||
|
||||
cp_transmission = cp_alt if self.CP.flags & SubaruFlags.HYBRID else cp
|
||||
can_gear = int(cp_transmission.vl["Transmission"]["Gear"])
|
||||
if self.CP.carFingerprint == CAR.SUBARU_LEGACY_2025 and can_gear in SUBARU_CVT_MANUAL_GEARS:
|
||||
if self.CP.carFingerprint in FROGGER_ANGLE_SIBLINGS | {CAR.SUBARU_LEGACY_2025} and can_gear in SUBARU_CVT_MANUAL_GEARS:
|
||||
ret.gearShifter = structs.CarState.GearShifter.manumatic
|
||||
elif self.CP.carFingerprint == CAR.SUBARU_IMPREZA_2020 and self.shifter_values.get(can_gear) in ("1", "2", "3", "4", "5", "6"):
|
||||
ret.gearShifter = structs.CarState.GearShifter.manumatic
|
||||
elif self.CP.carFingerprint == CAR.SUBARU_LEGACY_2025 and can_gear == 0:
|
||||
elif self.CP.carFingerprint in FROGGER_ANGLE_SIBLINGS | {CAR.SUBARU_LEGACY_2025} and can_gear == 0:
|
||||
ret.gearShifter = structs.CarState.GearShifter.neutral
|
||||
else:
|
||||
ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(can_gear, None))
|
||||
@@ -140,7 +140,7 @@ class CarState(CarStateBase):
|
||||
cp_cruise = cp_alt if self.CP.flags & SubaruFlags.GLOBAL_GEN2 else cp
|
||||
cp_es_brake = cp_alt if self.CP.flags & SubaruFlags.GLOBAL_GEN2 else cp_cam
|
||||
soft_disable = False
|
||||
if self.CP.carFingerprint == CAR.SUBARU_LEGACY_2025:
|
||||
if self.CP.carFingerprint in FROGGER_ANGLE_SIBLINGS | {CAR.SUBARU_LEGACY_2025}:
|
||||
soft_disable = cp_cam.vl["ES_DashStatus"].get("Cruise_Soft_Disable", 0) != 0
|
||||
|
||||
if self.CP.carFingerprint in (CAR.SUBARU_CROSSTREK_2025, CAR.SUBARU_IMPREZA_2025, CAR.SUBARU_LEGACY_2025,
|
||||
@@ -188,7 +188,7 @@ class CarState(CarStateBase):
|
||||
self.es_lkas_state_msg = copy.copy(cp_cam.vl["ES_LKAS_State"])
|
||||
self.es_brake_msg = copy.copy(cp_es_brake.vl["ES_Brake"])
|
||||
|
||||
if self.CP.carFingerprint == CAR.SUBARU_LEGACY_2025:
|
||||
if self.CP.carFingerprint in FROGGER_ANGLE_SIBLINGS | {CAR.SUBARU_LEGACY_2025}:
|
||||
cam_lkas_toggle = int(self.es_lkas_state_msg.get("LKAS_Dash_State", 0)) > 0
|
||||
steer_fault = bool(ret.steerFaultTemporary or ret.steerFaultPermanent)
|
||||
lkas_pressed = False
|
||||
|
||||
@@ -69,7 +69,7 @@ def qualified(cp, *, marked_only=False):
|
||||
def temporary_restriction(cp, state):
|
||||
allowed_gears = (
|
||||
(structs.CarState.GearShifter.drive, structs.CarState.GearShifter.manumatic)
|
||||
if cp is not None and cp.carFingerprint == CAR.SUBARU_LEGACY_2025 else
|
||||
if cp is not None and cp.carFingerprint in FROGGER_ANGLE_SIBLINGS | {CAR.SUBARU_LEGACY_2025} else
|
||||
(structs.CarState.GearShifter.drive,)
|
||||
)
|
||||
return bool(state is not None and qualified(cp, marked_only=True) and state.canValid and not state.canTimeout and
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import unittest
|
||||
|
||||
from opendbc.car.subaru.tests.test_ascent_angle import setup_controller, step
|
||||
from opendbc.car.subaru.values import CAR
|
||||
from opendbc.car.subaru.values import CAR, FROGGER_ANGLE_SIBLINGS
|
||||
from opendbc.car import structs
|
||||
|
||||
|
||||
@@ -244,3 +244,20 @@ class TestJacobwAngleContinuation(unittest.TestCase):
|
||||
for _ in range(2):
|
||||
_, decoded = step(controller, command, state)
|
||||
self.assertFalse(decoded['LKAS_Request'])
|
||||
|
||||
def test_frogger_gen2_siblings_keep_native_limits_while_allowing_manumatic(self):
|
||||
for car in sorted(FROGGER_ANGLE_SIBLINGS | {CAR.SUBARU_LEGACY_2025}):
|
||||
with self.subTest(car=car):
|
||||
cp, controller, command, state = setup_controller(car)
|
||||
cp.alternativeExperience = 32
|
||||
command.enabled = False
|
||||
command.latActive = True
|
||||
command.actuators.steeringAngleDeg = 8.0
|
||||
state.out.cruiseState.available = True
|
||||
state.out.cruiseState.enabled = False
|
||||
state.out.gearShifter = structs.CarState.GearShifter.manumatic
|
||||
state.out.vEgoRaw = state.out.vEgo = 5.0
|
||||
state.out.standstill = False
|
||||
state.out.steeringTorque = state.out.steeringRateDeg = 0.0
|
||||
_, decoded = step(controller, command, state)
|
||||
self.assertEqual(decoded['LKAS_Request'], 1)
|
||||
|
||||
@@ -6,7 +6,7 @@ from opendbc.car import Bus, structs
|
||||
from opendbc.car.subaru.carcontroller import CarController
|
||||
from opendbc.car.subaru.carstate import CarState
|
||||
from opendbc.car.subaru.interface import CarInterface
|
||||
from opendbc.car.subaru.values import CAR, DBC, SubaruFlags, SubaruSafetyFlags
|
||||
from opendbc.car.subaru.values import CAR, DBC, FROGGER_ANGLE_SIBLINGS, SubaruFlags, SubaruSafetyFlags
|
||||
from opendbc.safety.tests import test_subaru_gen2_angle_pair as pair
|
||||
|
||||
|
||||
@@ -211,7 +211,7 @@ class TestSubaruAscentController(unittest.TestCase):
|
||||
for tick in range(5):
|
||||
_, sends = controller.update(command.as_reader(), state, 1_000_000_000 + tick * 10_000_000)
|
||||
distance.extend(frame for frame in sends if frame[0] == 0x221)
|
||||
self.assertEqual(len(distance), 1 if car in (CAR.SUBARU_ASCENT_2023, CAR.SUBARU_LEGACY_2025) else 5)
|
||||
self.assertEqual(len(distance), 1 if car in FROGGER_ANGLE_SIBLINGS | {CAR.SUBARU_ASCENT_2023, CAR.SUBARU_LEGACY_2025} else 5)
|
||||
self.assertEqual(len(set(distance)), 1)
|
||||
self.assertEqual(distance[0][2], 1 if cp.flags & SubaruFlags.GLOBAL_GEN2 else 0)
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ from opendbc.car.subaru.carcontroller import CarController
|
||||
from opendbc.car.subaru.carstate import CarState
|
||||
from opendbc.car.subaru.interface import CarInterface
|
||||
from opendbc.car.subaru.tests.test_ascent_angle import setup_controller, step
|
||||
from opendbc.car.subaru.values import CAR, CanBus, DBC
|
||||
from opendbc.car.subaru.values import CAR, FROGGER_ANGLE_SIBLINGS, CanBus, DBC
|
||||
from opendbc.safety.tests import test_subaru_gen2_angle_pair as pair
|
||||
|
||||
|
||||
@@ -23,94 +23,98 @@ def _step_to_hud(controller, command, state):
|
||||
|
||||
class TestLegacy2025Aol(unittest.TestCase):
|
||||
def test_lkas_dash_state_toggle_emits_button_event_and_toggles_aol(self):
|
||||
cp = CarInterface.get_params(CAR.SUBARU_LEGACY_2025, {0: {}, 1: {}, 2: {}}, [], False, False, False)
|
||||
_, frames = pair.TestSubaruGen2AnglePair.sources(CAR.SUBARU_LEGACY_2025)
|
||||
packer = CANPacker(DBC[CAR.SUBARU_LEGACY_2025][Bus.pt])
|
||||
state = CarState(cp)
|
||||
self.assertTrue(state.aol_enabled)
|
||||
parsers = state.get_can_parsers(cp)
|
||||
state.update(parsers)
|
||||
for parser in parsers.values():
|
||||
parser.update([(1_000_000_000, frames)])
|
||||
ret = state.update(parsers)
|
||||
self.assertTrue(ret.cruiseState.available)
|
||||
self.assertFalse(state.lateral_off)
|
||||
self.assertEqual(len(ret.buttonEvents), 0)
|
||||
for candidate in sorted(FROGGER_ANGLE_SIBLINGS | {CAR.SUBARU_LEGACY_2025}):
|
||||
with self.subTest(candidate=candidate):
|
||||
cp = CarInterface.get_params(candidate, {0: {}, 1: {}, 2: {}}, [], False, False, False)
|
||||
_, frames = pair.TestSubaruGen2AnglePair.sources(candidate)
|
||||
packer = CANPacker(DBC[candidate][Bus.pt])
|
||||
state = CarState(cp)
|
||||
self.assertTrue(state.aol_enabled)
|
||||
parsers = state.get_can_parsers(cp)
|
||||
state.update(parsers)
|
||||
for parser in parsers.values():
|
||||
parser.update([(1_000_000_000, frames)])
|
||||
ret = state.update(parsers)
|
||||
self.assertTrue(ret.cruiseState.available)
|
||||
self.assertFalse(state.lateral_off)
|
||||
self.assertEqual(len(ret.buttonEvents), 0)
|
||||
|
||||
# Flip LKAS_Dash_State (0 -> 1) on bus 2: toggles AOL off once and holds Type.lkas press/release for 5 frames.
|
||||
lkas_on = packer.make_can_msg('ES_LKAS_State', CanBus.camera, {'LKAS_Dash_State': 1})
|
||||
parsers[Bus.cam].update([(1_020_000_000, [lkas_on])])
|
||||
ret = state.update(parsers)
|
||||
self.assertTrue(state.lateral_off)
|
||||
lkas_events = [be for be in ret.buttonEvents if be.type == structs.CarState.ButtonEvent.Type.lkas]
|
||||
self.assertEqual([be.pressed for be in lkas_events], [True, False])
|
||||
for idx in range(4):
|
||||
ret = state.update(parsers)
|
||||
self.assertTrue(state.lateral_off)
|
||||
lkas_events = [be for be in ret.buttonEvents if be.type == structs.CarState.ButtonEvent.Type.lkas]
|
||||
self.assertEqual([be.pressed for be in lkas_events], [True, False], f"hold frame {idx + 2}")
|
||||
ret = state.update(parsers)
|
||||
self.assertTrue(state.lateral_off)
|
||||
self.assertEqual([be for be in ret.buttonEvents if be.type == structs.CarState.ButtonEvent.Type.lkas], [])
|
||||
# Flip LKAS_Dash_State (0 -> 1) on bus 2: toggles AOL off once and holds Type.lkas press/release for 5 frames.
|
||||
lkas_on = packer.make_can_msg('ES_LKAS_State', CanBus.camera, {'LKAS_Dash_State': 1})
|
||||
parsers[Bus.cam].update([(1_020_000_000, [lkas_on])])
|
||||
ret = state.update(parsers)
|
||||
self.assertTrue(state.lateral_off)
|
||||
lkas_events = [be for be in ret.buttonEvents if be.type == structs.CarState.ButtonEvent.Type.lkas]
|
||||
self.assertEqual([be.pressed for be in lkas_events], [True, False])
|
||||
for idx in range(4):
|
||||
ret = state.update(parsers)
|
||||
self.assertTrue(state.lateral_off)
|
||||
lkas_events = [be for be in ret.buttonEvents if be.type == structs.CarState.ButtonEvent.Type.lkas]
|
||||
self.assertEqual([be.pressed for be in lkas_events], [True, False], f"hold frame {idx + 2}")
|
||||
ret = state.update(parsers)
|
||||
self.assertTrue(state.lateral_off)
|
||||
self.assertEqual([be for be in ret.buttonEvents if be.type == structs.CarState.ButtonEvent.Type.lkas], [])
|
||||
|
||||
# Flip LKAS_Dash_State (1 -> 0): restores AOL active cleanly.
|
||||
lkas_off = packer.make_can_msg('ES_LKAS_State', CanBus.camera, {'LKAS_Dash_State': 0})
|
||||
parsers[Bus.cam].update([(1_040_000_000, [lkas_off])])
|
||||
ret = state.update(parsers)
|
||||
self.assertFalse(state.lateral_off)
|
||||
# Flip LKAS_Dash_State (1 -> 0): restores AOL active cleanly.
|
||||
lkas_off = packer.make_can_msg('ES_LKAS_State', CanBus.camera, {'LKAS_Dash_State': 0})
|
||||
parsers[Bus.cam].update([(1_040_000_000, [lkas_off])])
|
||||
ret = state.update(parsers)
|
||||
self.assertFalse(state.lateral_off)
|
||||
|
||||
# Toggle off, then drop Cruise_On -> lateral_off resets to False when AOL is enabled.
|
||||
parsers[Bus.cam].update([(1_060_000_000, [lkas_on])])
|
||||
state.update(parsers)
|
||||
self.assertTrue(state.lateral_off)
|
||||
dash_off = packer.make_can_msg('ES_DashStatus', CanBus.camera, {'Cruise_On': 0})
|
||||
parsers[Bus.cam].update([(1_080_000_000, [dash_off])])
|
||||
state.update(parsers)
|
||||
self.assertFalse(state.lateral_off)
|
||||
# Toggle off, then drop Cruise_On -> lateral_off resets to False when AOL is enabled.
|
||||
parsers[Bus.cam].update([(1_060_000_000, [lkas_on])])
|
||||
state.update(parsers)
|
||||
self.assertTrue(state.lateral_off)
|
||||
dash_off = packer.make_can_msg('ES_DashStatus', CanBus.camera, {'Cruise_On': 0})
|
||||
parsers[Bus.cam].update([(1_080_000_000, [dash_off])])
|
||||
state.update(parsers)
|
||||
self.assertFalse(state.lateral_off)
|
||||
|
||||
def test_aol_mode_transitions_and_lkas_button_behavior(self):
|
||||
cp = CarInterface.get_params(CAR.SUBARU_LEGACY_2025, {0: {}, 1: {}, 2: {}}, [], False, False, False)
|
||||
_, frames = pair.TestSubaruGen2AnglePair.sources(CAR.SUBARU_LEGACY_2025)
|
||||
packer = CANPacker(DBC[CAR.SUBARU_LEGACY_2025][Bus.pt])
|
||||
for candidate in sorted(FROGGER_ANGLE_SIBLINGS | {CAR.SUBARU_LEGACY_2025}):
|
||||
with self.subTest(candidate=candidate):
|
||||
cp = CarInterface.get_params(candidate, {0: {}, 1: {}, 2: {}}, [], False, False, False)
|
||||
_, frames = pair.TestSubaruGen2AnglePair.sources(candidate)
|
||||
packer = CANPacker(DBC[candidate][Bus.pt])
|
||||
|
||||
def init_state(aol_enabled: bool):
|
||||
state = CarState(cp)
|
||||
state.aol_enabled = aol_enabled
|
||||
parsers = state.get_can_parsers(cp)
|
||||
state.update(parsers)
|
||||
for parser in parsers.values():
|
||||
parser.update([(1_000_000_000, frames)])
|
||||
state.update(parsers)
|
||||
return state, parsers
|
||||
def init_state(aol_enabled: bool):
|
||||
state = CarState(cp)
|
||||
state.aol_enabled = aol_enabled
|
||||
parsers = state.get_can_parsers(cp)
|
||||
state.update(parsers)
|
||||
for parser in parsers.values():
|
||||
parser.update([(1_000_000_000, frames)])
|
||||
state.update(parsers)
|
||||
return state, parsers
|
||||
|
||||
def press_lkas(state, parsers, ts_ns: int, dash_state: int):
|
||||
msg = packer.make_can_msg('ES_LKAS_State', CanBus.camera, {'LKAS_Dash_State': dash_state})
|
||||
parsers[Bus.cam].update([(ts_ns, [msg])])
|
||||
return state.update(parsers)
|
||||
def press_lkas(state, parsers, ts_ns: int, dash_state: int):
|
||||
msg = packer.make_can_msg('ES_LKAS_State', CanBus.camera, {'LKAS_Dash_State': dash_state})
|
||||
parsers[Bus.cam].update([(ts_ns, [msg])])
|
||||
return state.update(parsers)
|
||||
|
||||
# 1. AOL ON: AOL Active <-> AOL Off.
|
||||
state, parsers = init_state(True)
|
||||
self.assertFalse(state.lateral_off)
|
||||
press_lkas(state, parsers, 1_020_000_000, 1)
|
||||
self.assertTrue(state.lateral_off)
|
||||
press_lkas(state, parsers, 1_040_000_000, 0)
|
||||
self.assertFalse(state.lateral_off)
|
||||
# 1. AOL ON: AOL Active <-> AOL Off.
|
||||
state, parsers = init_state(True)
|
||||
self.assertFalse(state.lateral_off)
|
||||
press_lkas(state, parsers, 1_020_000_000, 1)
|
||||
self.assertTrue(state.lateral_off)
|
||||
press_lkas(state, parsers, 1_040_000_000, 0)
|
||||
self.assertFalse(state.lateral_off)
|
||||
|
||||
# 2. AOL OFF: forced Off even after LKAS presses.
|
||||
state, parsers = init_state(False)
|
||||
self.assertTrue(state.lateral_off)
|
||||
press_lkas(state, parsers, 1_020_000_000, 1)
|
||||
self.assertTrue(state.lateral_off)
|
||||
# 2. AOL OFF: forced Off even after LKAS presses.
|
||||
state, parsers = init_state(False)
|
||||
self.assertTrue(state.lateral_off)
|
||||
press_lkas(state, parsers, 1_020_000_000, 1)
|
||||
self.assertTrue(state.lateral_off)
|
||||
|
||||
# 3. Dynamic transitions across AOL settings changes.
|
||||
state, parsers = init_state(True)
|
||||
self.assertFalse(state.lateral_off)
|
||||
state.aol_enabled = False
|
||||
state.update(parsers)
|
||||
self.assertTrue(state.lateral_off)
|
||||
state.aol_enabled = True
|
||||
state.update(parsers)
|
||||
self.assertFalse(state.lateral_off)
|
||||
# 3. Dynamic transitions across AOL settings changes.
|
||||
state, parsers = init_state(True)
|
||||
self.assertFalse(state.lateral_off)
|
||||
state.aol_enabled = False
|
||||
state.update(parsers)
|
||||
self.assertTrue(state.lateral_off)
|
||||
state.aol_enabled = True
|
||||
state.update(parsers)
|
||||
self.assertFalse(state.lateral_off)
|
||||
|
||||
def test_carcontroller_dash_state_and_steering_across_lateral_modes(self):
|
||||
_, controller, command, state = setup_controller(CAR.SUBARU_LEGACY_2025)
|
||||
@@ -366,53 +370,57 @@ class TestLegacy2025Aol(unittest.TestCase):
|
||||
self.assertEqual(info_parser.vl['ES_Infotainment']['LKAS_State_Infotainment'], 3)
|
||||
|
||||
def test_carcontroller_aol_manumatic_and_unauthorized_gate(self):
|
||||
cp, _, command, state = setup_controller(CAR.SUBARU_LEGACY_2025)
|
||||
cp.alternativeExperience = 32
|
||||
controller = CarController(DBC[CAR.SUBARU_LEGACY_2025], cp)
|
||||
state.out.gearShifter = structs.CarState.GearShifter.manumatic
|
||||
state.lateral_off = False
|
||||
state.out.steeringAngleDeg = 0.0
|
||||
state.out.steeringRateDeg = 0.0
|
||||
state.out.steeringTorque = 0.0
|
||||
for candidate in sorted(FROGGER_ANGLE_SIBLINGS | {CAR.SUBARU_LEGACY_2025}):
|
||||
with self.subTest(candidate=candidate):
|
||||
cp, _, command, state = setup_controller(candidate)
|
||||
cp.alternativeExperience = 32
|
||||
controller = CarController(DBC[candidate], cp)
|
||||
state.out.gearShifter = structs.CarState.GearShifter.manumatic
|
||||
state.lateral_off = False
|
||||
state.out.steeringAngleDeg = 0.0
|
||||
state.out.steeringRateDeg = 0.0
|
||||
state.out.steeringTorque = 0.0
|
||||
|
||||
# Active AOL in manumatic: angle requested, green wheel icon (2), visible left line (1).
|
||||
command.enabled = False
|
||||
command.latActive = True
|
||||
command.hudControl.lanesVisible = True
|
||||
command.hudControl.leftLaneVisible = True
|
||||
command.hudControl.rightLaneVisible = False
|
||||
command.actuators.steeringAngleDeg = -8.0
|
||||
_, decoded = step(controller, command, state)
|
||||
self.assertEqual(decoded['LKAS_Request'], 1)
|
||||
self.assertLess(decoded['LKAS_Output'], 0.0)
|
||||
hud = _step_to_hud(controller, command, state)
|
||||
self.assertEqual(hud['LKAS_Dash_State'], 2)
|
||||
self.assertEqual(hud['LKAS_Left_Line_Visible'], 1)
|
||||
# Active AOL in manumatic: angle requested, green wheel icon (2), visible left line (1).
|
||||
command.enabled = False
|
||||
command.latActive = True
|
||||
command.hudControl.lanesVisible = True
|
||||
command.hudControl.leftLaneVisible = True
|
||||
command.hudControl.rightLaneVisible = False
|
||||
command.actuators.steeringAngleDeg = -8.0
|
||||
_, decoded = step(controller, command, state)
|
||||
self.assertEqual(decoded['LKAS_Request'], 1)
|
||||
self.assertLess(decoded['LKAS_Output'], 0.0)
|
||||
hud = _step_to_hud(controller, command, state)
|
||||
self.assertEqual(hud['LKAS_Dash_State'], 2)
|
||||
self.assertEqual(hud['LKAS_Left_Line_Visible'], 1)
|
||||
|
||||
# Unauthorized gate: when controlsd keeps latActive=False, CarController must never request 0x124 torque/angle.
|
||||
command.latActive = False
|
||||
_, decoded = step(controller, command, state)
|
||||
self.assertEqual(decoded['LKAS_Request'], 0)
|
||||
_, decoded = step(controller, command, state)
|
||||
self.assertEqual(decoded['LKAS_Request'], 0)
|
||||
# Unauthorized gate: when controlsd keeps latActive=False, CarController must never request 0x124 torque/angle.
|
||||
command.latActive = False
|
||||
_, decoded = step(controller, command, state)
|
||||
self.assertEqual(decoded['LKAS_Request'], 0)
|
||||
_, decoded = step(controller, command, state)
|
||||
self.assertEqual(decoded['LKAS_Request'], 0)
|
||||
|
||||
def test_legacy_2025_manumatic_transition_and_between_detent_gears(self):
|
||||
cp = CarInterface.get_params(CAR.SUBARU_LEGACY_2025, {0: {}, 1: {}, 2: {}}, [], False, False, False)
|
||||
_, frames = pair.TestSubaruGen2AnglePair.sources(CAR.SUBARU_LEGACY_2025)
|
||||
packer = CANPacker(DBC[CAR.SUBARU_LEGACY_2025][Bus.pt])
|
||||
state = CarState(cp)
|
||||
parsers = state.get_can_parsers(cp)
|
||||
state.update(parsers)
|
||||
for parser in parsers.values():
|
||||
parser.update([(1_000_000_000, frames)])
|
||||
state.update(parsers)
|
||||
for candidate in sorted(FROGGER_ANGLE_SIBLINGS | {CAR.SUBARU_LEGACY_2025}):
|
||||
with self.subTest(candidate=candidate):
|
||||
cp = CarInterface.get_params(candidate, {0: {}, 1: {}, 2: {}}, [], False, False, False)
|
||||
_, frames = pair.TestSubaruGen2AnglePair.sources(candidate)
|
||||
packer = CANPacker(DBC[candidate][Bus.pt])
|
||||
state = CarState(cp)
|
||||
parsers = state.get_can_parsers(cp)
|
||||
state.update(parsers)
|
||||
for parser in parsers.values():
|
||||
parser.update([(1_000_000_000, frames)])
|
||||
state.update(parsers)
|
||||
|
||||
Gear = structs.CarState.GearShifter
|
||||
for can_gear, expected_gear in ((121, Gear.drive), (129, Gear.manumatic), (177, Gear.manumatic), (0, Gear.neutral), (4, Gear.park)):
|
||||
msg = packer.make_can_msg('Transmission', 0, {'Gear': can_gear})
|
||||
parsers[Bus.pt].update([(1_020_000_000, [msg])])
|
||||
ret = state.update(parsers)
|
||||
self.assertEqual(ret.gearShifter, expected_gear, f'can_gear={can_gear}')
|
||||
Gear = structs.CarState.GearShifter
|
||||
for can_gear, expected_gear in ((121, Gear.drive), (129, Gear.manumatic), (177, Gear.manumatic), (0, Gear.neutral), (4, Gear.park)):
|
||||
msg = packer.make_can_msg('Transmission', 0, {'Gear': can_gear})
|
||||
parsers[Bus.pt].update([(1_020_000_000, [msg])])
|
||||
ret = state.update(parsers)
|
||||
self.assertEqual(ret.gearShifter, expected_gear, f'{candidate} can_gear={can_gear}')
|
||||
|
||||
def test_legacy_2025_acc_lead_led_preserved_and_aol_line_visibility_passthrough(self):
|
||||
_, _, command, state = setup_controller(CAR.SUBARU_LEGACY_2025)
|
||||
@@ -493,47 +501,51 @@ class TestLegacy2025Aol(unittest.TestCase):
|
||||
self.assertEqual(hud['LKAS_Left_Line_Visible'], 1)
|
||||
|
||||
def test_aol_wheel_icon_park_reverse_neutral_and_shift_debounce(self):
|
||||
_, controller, command, state = setup_controller(CAR.SUBARU_LEGACY_2025)
|
||||
state.out.cruiseState.available = True
|
||||
state.out.vEgo = 0.0
|
||||
state.out.vEgoRaw = 0.0
|
||||
state.out.standstill = True
|
||||
state.aol_enabled = True
|
||||
state.lateral_off = False
|
||||
command.enabled = False
|
||||
command.latActive = False
|
||||
command.hudControl.lanesVisible = True
|
||||
for candidate in sorted(FROGGER_ANGLE_SIBLINGS | {CAR.SUBARU_LEGACY_2025}):
|
||||
with self.subTest(candidate=candidate):
|
||||
cp, _, command, state = setup_controller(candidate)
|
||||
cp.alternativeExperience = 32
|
||||
controller = CarController(DBC[candidate], cp)
|
||||
state.out.cruiseState.available = True
|
||||
state.out.vEgo = 0.0
|
||||
state.out.vEgoRaw = 0.0
|
||||
state.out.standstill = True
|
||||
state.aol_enabled = True
|
||||
state.lateral_off = False
|
||||
command.enabled = False
|
||||
command.latActive = False
|
||||
command.hudControl.lanesVisible = True
|
||||
|
||||
# In Park: stays solid green even if steering wheel is moved slightly.
|
||||
state.out.gearShifter = structs.CarState.GearShifter.park
|
||||
state.out.steeringPressed = True
|
||||
self.assertEqual(_step_to_hud(controller, command, state)['LKAS_Dash_State'], 2)
|
||||
|
||||
# Fast Park -> Reverse -> Neutral -> Drive shift (< 0.8s) holds green without flashing white.
|
||||
state.out.steeringPressed = False
|
||||
for gear, steps in (
|
||||
(structs.CarState.GearShifter.reverse, 3),
|
||||
(structs.CarState.GearShifter.neutral, 3),
|
||||
):
|
||||
state.out.gearShifter = gear
|
||||
for _ in range(steps):
|
||||
# In Park: stays solid green even if steering wheel is moved slightly.
|
||||
state.out.gearShifter = structs.CarState.GearShifter.park
|
||||
state.out.steeringPressed = True
|
||||
self.assertEqual(_step_to_hud(controller, command, state)['LKAS_Dash_State'], 2)
|
||||
state.out.gearShifter = structs.CarState.GearShifter.drive
|
||||
self.assertEqual(_step_to_hud(controller, command, state)['LKAS_Dash_State'], 2)
|
||||
|
||||
# Settling in Reverse (>= 0.8s) switches to solid white regardless of steering input.
|
||||
state.out.gearShifter = structs.CarState.GearShifter.reverse
|
||||
for _ in range(9):
|
||||
hud = _step_to_hud(controller, command, state)
|
||||
self.assertEqual(hud['LKAS_Dash_State'], 1)
|
||||
state.out.steeringPressed = True
|
||||
self.assertEqual(_step_to_hud(controller, command, state)['LKAS_Dash_State'], 1)
|
||||
state.out.gearShifter = structs.CarState.GearShifter.neutral
|
||||
self.assertEqual(_step_to_hud(controller, command, state)['LKAS_Dash_State'], 1)
|
||||
# Fast Park -> Reverse -> Neutral -> Drive shift (< 0.8s) holds green without flashing white.
|
||||
state.out.steeringPressed = False
|
||||
for gear, steps in (
|
||||
(structs.CarState.GearShifter.reverse, 3),
|
||||
(structs.CarState.GearShifter.neutral, 3),
|
||||
):
|
||||
state.out.gearShifter = gear
|
||||
for _ in range(steps):
|
||||
self.assertEqual(_step_to_hud(controller, command, state)['LKAS_Dash_State'], 2)
|
||||
state.out.gearShifter = structs.CarState.GearShifter.drive
|
||||
self.assertEqual(_step_to_hud(controller, command, state)['LKAS_Dash_State'], 2)
|
||||
|
||||
# Returning to Park restores solid green cleanly.
|
||||
state.out.gearShifter = structs.CarState.GearShifter.park
|
||||
self.assertEqual(_step_to_hud(controller, command, state)['LKAS_Dash_State'], 2)
|
||||
# Settling in Reverse (>= 0.8s) switches to solid white regardless of steering input.
|
||||
state.out.gearShifter = structs.CarState.GearShifter.reverse
|
||||
for _ in range(9):
|
||||
hud = _step_to_hud(controller, command, state)
|
||||
self.assertEqual(hud['LKAS_Dash_State'], 1)
|
||||
state.out.steeringPressed = True
|
||||
self.assertEqual(_step_to_hud(controller, command, state)['LKAS_Dash_State'], 1)
|
||||
state.out.gearShifter = structs.CarState.GearShifter.neutral
|
||||
self.assertEqual(_step_to_hud(controller, command, state)['LKAS_Dash_State'], 1)
|
||||
|
||||
# Returning to Park restores solid green cleanly.
|
||||
state.out.gearShifter = structs.CarState.GearShifter.park
|
||||
self.assertEqual(_step_to_hud(controller, command, state)['LKAS_Dash_State'], 2)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -421,7 +421,7 @@ static safety_config subaru_init(uint16_t raw_param) {
|
||||
subaru_aol_reset();
|
||||
subaru_aol_gear_bus = (uint8_t)(subaru_d_platform ? SUBARU_ALT_BUS : SUBARU_MAIN_BUS);
|
||||
const bool legacy_2025 = (base_param == 145U);
|
||||
subaru_aol_legacy_2025 = legacy_2025;
|
||||
subaru_aol_legacy_2025 = legacy_2025 || (base_param == 17U) || sibling_hud;
|
||||
subaru_aol_enabled = ((unsigned int)alternative_experience == 32U) &&
|
||||
((param == 209U) || (param == 465U) || (param == 16U) || (param == 0U) || (param == 1U) || (param == 17U) || (param == 145U) ||
|
||||
avh || sibling_hud || (param == 177U) || (param == 401U) || (param == 8U) || (param == 520U) || (param == 512U) || (param == 2225U));
|
||||
|
||||
@@ -122,24 +122,29 @@ def test_legacy_2025_cvt_manual_gears():
|
||||
item = stock_module.TestSubaruStockAol(methodName='runTest')
|
||||
item.setUp()
|
||||
try:
|
||||
item.configure(145)
|
||||
neutral(item)
|
||||
assert item.feed() == 1
|
||||
for gear in (137, 145, 153, 161, 169, 177, 185, 193):
|
||||
assert item.feed(gear=gear) == 1
|
||||
assert item.feed(gear=3) == 0
|
||||
assert item.feed(gear=145) == 1
|
||||
for param in (145, 17, 1041, 2065, 3089):
|
||||
item.configure(param)
|
||||
neutral(item)
|
||||
assert item.feed() == 1
|
||||
for gear in (137, 145, 153, 161, 169, 177, 185, 193):
|
||||
assert item.feed(gear=gear) == 1
|
||||
assert item.feed(gear=3) == 0
|
||||
assert item.feed(gear=145) == 1
|
||||
|
||||
# Pressing MAIN while in Park (gear=4) then shifting to Drive grants permission.
|
||||
assert item.feed(main=False, gear=4, speed=0) == 0
|
||||
assert item.feed(main=True, gear=4, speed=0) == 0
|
||||
assert item.feed(main=True, gear=3, speed=0) == 0
|
||||
assert item.feed(main=True, gear=121, speed=54) == 1
|
||||
# Pressing MAIN while in Park (gear=4) then shifting to Drive grants permission.
|
||||
assert item.feed(main=False, gear=4, speed=0) == 0
|
||||
assert item.feed(main=True, gear=4, speed=0) == 0
|
||||
assert item.feed(main=True, gear=3, speed=0) == 0
|
||||
assert item.feed(main=True, gear=121, speed=54) == 1
|
||||
|
||||
item.configure(17)
|
||||
neutral(item)
|
||||
assert item.feed() == 1
|
||||
assert item.feed(gear=137) == 0
|
||||
for non_sibling_param in (209, 4096):
|
||||
item.configure(non_sibling_param)
|
||||
neutral(item)
|
||||
assert item.feed() == 1
|
||||
assert item.feed(gear=137) == 0
|
||||
assert item.feed(main=False, gear=4, speed=0) == 0
|
||||
assert item.feed(main=True, gear=4, speed=0) == 0
|
||||
assert item.feed(main=True, gear=121, speed=54) == 0
|
||||
finally:
|
||||
item.tearDown()
|
||||
|
||||
|
||||
@@ -47,9 +47,9 @@ class TestSubaruStockAol(unittest.TestCase):
|
||||
('ES_Status', {'Cruise_Activated': int(cruise)}, 2 if self.param == 16 else 1),
|
||||
('ES_DashStatus', {'Cruise_On': int(main)}, 2),
|
||||
]
|
||||
if not omit_distance and self.param in (17, 145, 209, 401, 465, 1169, 1425, 4096, 4104, 4608, 4616, 8192, 8200):
|
||||
if not omit_distance and self.param in (17, 145, 209, 401, 465, 1041, 1169, 1425, 2065, 3089, 4096, 4104, 4608, 4616, 8192, 8200):
|
||||
frames.append(('ES_Distance', {'Cruise_Fault': int(acc_fault)},
|
||||
1 if self.param in (17, 145, 209, 401, 465, 1169, 1425) else 2))
|
||||
1 if self.param in (17, 145, 209, 401, 465, 1041, 1169, 1425, 2065, 3089) else 2))
|
||||
if not omit_gear:
|
||||
frames.append(('Transmission', {'Gear': gear}, gear_bus))
|
||||
for name, fields, bus in frames:
|
||||
|
||||
@@ -17,6 +17,7 @@ from openpilot.common.swaglog import cloudlog
|
||||
|
||||
from opendbc.car.car_helpers import interfaces
|
||||
from opendbc.car.honda.values import CAR as HONDA_CAR, accord_angle_steer_ratio
|
||||
from opendbc.car.subaru.values import CAR as SUBARU_CAR, FROGGER_ANGLE_SIBLINGS
|
||||
from opendbc.car.vehicle_model import VehicleModel
|
||||
from openpilot.selfdrive.controls.lib.drive_helpers import clip_curvature
|
||||
from openpilot.selfdrive.controls.lib.highway_correction_gain import HighwayCorrectionGain, predicted_lateral_accels, read_gain
|
||||
@@ -170,7 +171,7 @@ class Controls:
|
||||
self._prev_cruise_available = False
|
||||
self._prev_aol_enabled: bool | None = None
|
||||
self._prev_lkas_button_pressed = False
|
||||
if self.CP.carFingerprint == "SUBARU_LEGACY_2025":
|
||||
if self.CP.carFingerprint in FROGGER_ANGLE_SIBLINGS | {SUBARU_CAR.SUBARU_LEGACY_2025}:
|
||||
self._refresh_subaru_aol_setting(0, force=True)
|
||||
self.lane_centering_controller = (
|
||||
LaneCenteringController(body=interface_dimensions(self.CI, self.CP), body_required=True) if predict_lane_clearance else LaneCenteringController()
|
||||
@@ -516,7 +517,7 @@ class Controls:
|
||||
|
||||
if cycle_timing is not None:
|
||||
cycle_timing.mark()
|
||||
legacy_2025 = self.CP.carFingerprint == "SUBARU_LEGACY_2025"
|
||||
legacy_2025 = self.CP.carFingerprint in FROGGER_ANGLE_SIBLINGS | {SUBARU_CAR.SUBARU_LEGACY_2025}
|
||||
if legacy_2025:
|
||||
mode_now_ns = int(self.sm.logMonoTime['carState']) if os.getenv('REPLAY') == '1' else time.monotonic_ns()
|
||||
self._refresh_subaru_aol_setting(mode_now_ns)
|
||||
@@ -629,7 +630,7 @@ class Controls:
|
||||
elif getattr(self, 'model_turn_assist', None) is not None:
|
||||
self.model_turn_assist.reset()
|
||||
self.model_turn_assist.twitch_guard_armed = update_twitch_guard(False, CS.vEgo, CS.standstill)
|
||||
if not assist_ready and self.CP.carFingerprint == "SUBARU_LEGACY_2025":
|
||||
if not assist_ready and self.CP.carFingerprint in FROGGER_ANGLE_SIBLINGS | {SUBARU_CAR.SUBARU_LEGACY_2025}:
|
||||
subaru_gear_ok = CS.gearShifter in (car.CarState.GearShifter.drive, car.CarState.GearShifter.low, car.CarState.GearShifter.manumatic)
|
||||
if self.sm.all_checks(['modelV2']) and not CS.steerFaultTemporary and not CS.steerFaultPermanent and subaru_gear_ok:
|
||||
self.subaru_twitch_guard_armed = update_twitch_guard(self.subaru_twitch_guard_armed, CS.vEgo, CS.standstill)
|
||||
@@ -891,7 +892,7 @@ class Controls:
|
||||
hudControl.leadDistanceBars = self.sm['selfdriveState'].personality.raw + 1
|
||||
hudControl.visualAlert = self.sm['selfdriveState'].alertHudVisual
|
||||
|
||||
if self.CP.carFingerprint == "SUBARU_LEGACY_2025":
|
||||
if self.CP.carFingerprint in FROGGER_ANGLE_SIBLINGS | {SUBARU_CAR.SUBARU_LEGACY_2025}:
|
||||
lines_allowed = bool(
|
||||
CS.cruiseState.available and (
|
||||
(self.aol_enabled_setting and not self.lateral_off) or
|
||||
|
||||
@@ -17,8 +17,9 @@ def _read_allow_manumatic(params: Params) -> bool | None:
|
||||
if not cp_bytes:
|
||||
return None
|
||||
from opendbc.car.structs import car
|
||||
from opendbc.car.subaru.values import CAR, FROGGER_ANGLE_SIBLINGS
|
||||
with car.CarParams.from_bytes(cp_bytes) as cp:
|
||||
return cp.carFingerprint == "SUBARU_LEGACY_2025"
|
||||
return cp.carFingerprint in FROGGER_ANGLE_SIBLINGS | {CAR.SUBARU_LEGACY_2025}
|
||||
|
||||
|
||||
def dmonitoringd_thread():
|
||||
|
||||
@@ -43,6 +43,7 @@ from opendbc.car.gm.steering_authority import monitored_profile
|
||||
from openpilot.starpilot.car.gm.steering_companion import SteeringCompanion
|
||||
from openpilot.starpilot.car.hyundai.aol import qualified_ioniq6
|
||||
from opendbc.car.gm.values import CAR as GM_CAR
|
||||
from opendbc.car.subaru.values import CAR as SUBARU_CAR, FROGGER_ANGLE_SIBLINGS
|
||||
from opendbc.car.gm.values import (GMFlags, bolt_pedal_in_drive_requires_low, is_bolt_euv_longitudinal, is_ordinary_ascm_profile,
|
||||
is_ordinary_camera_profile, is_ordinary_sdgm_profile, is_volt_ascm_longitudinal, malibu_hybrid_profile)
|
||||
from openpilot.starpilot.aol.intent import read_settings
|
||||
@@ -1011,7 +1012,8 @@ class SelfdriveD:
|
||||
qualified_gm(self.CP) and not sample.cruiseState.available or
|
||||
(sample.gearShifter not in (car.CarState.GearShifter.drive, car.CarState.GearShifter.sport,
|
||||
car.CarState.GearShifter.low, car.CarState.GearShifter.brake) and
|
||||
not (self.CP.carFingerprint == "SUBARU_LEGACY_2025" and sample.gearShifter == car.CarState.GearShifter.manumatic))
|
||||
not (self.CP.carFingerprint in FROGGER_ANGLE_SIBLINGS | {SUBARU_CAR.SUBARU_LEGACY_2025} and
|
||||
sample.gearShifter == car.CarState.GearShifter.manumatic))
|
||||
for sample, valid in samples):
|
||||
return 0
|
||||
native = current_native(self.sm, self.CP, now_ns=now_ns, axis_session_id=session)
|
||||
@@ -1317,7 +1319,7 @@ class SelfdriveD:
|
||||
# Saturation is already ignored during override; retire its held presentation too.
|
||||
alerts = [alert for alert in alerts if alert.alert_type != 'steerSaturated/warning']
|
||||
self.AM.alerts.pop('steerSaturated/warning', None)
|
||||
if self.CP.carFingerprint == "SUBARU_LEGACY_2025":
|
||||
if self.CP.carFingerprint in FROGGER_ANGLE_SIBLINGS | {SUBARU_CAR.SUBARU_LEGACY_2025}:
|
||||
alerts = [alert for alert in alerts if alert.alert_type not in ("pcmEnable/enable", "pcmDisable/userDisable")]
|
||||
self.AM.alerts.pop("pcmEnable/enable", None)
|
||||
self.AM.alerts.pop("pcmDisable/userDisable", None)
|
||||
|
||||
@@ -163,8 +163,9 @@ class Soundd:
|
||||
cp_bytes = None
|
||||
if cp_bytes:
|
||||
from opendbc.car.structs import car
|
||||
from opendbc.car.subaru.values import CAR, FROGGER_ANGLE_SIBLINGS
|
||||
with car.CarParams.from_bytes(cp_bytes) as cp:
|
||||
self.axis_alerts.suppress_lateral = (cp.carFingerprint == "SUBARU_LEGACY_2025")
|
||||
self.axis_alerts.suppress_lateral = cp.carFingerprint in FROGGER_ANGLE_SIBLINGS | {CAR.SUBARU_LEGACY_2025}
|
||||
self._cp_checked = True
|
||||
|
||||
def refresh_saved_volumes(self, now: float) -> None:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
def armed_lateral_current(cp, cs, intent, native, *, source_ns, now_ns, axis_session_id) -> bool:
|
||||
"""Retain only a current deliberately armed native-permitted lateral owner."""
|
||||
from opendbc.car.structs import car
|
||||
from opendbc.car.subaru.values import CAR as SUBARU_CAR, FROGGER_ANGLE_SIBLINGS
|
||||
from openpilot.starpilot.aol.vehicle import policy_for
|
||||
from openpilot.starpilot.aol.runtime import AXIS_MAX_AGE_NS, SAFETY_MAX_AGE_NS, native_inventory_matches_cp
|
||||
try:
|
||||
@@ -9,7 +10,8 @@ def armed_lateral_current(cp, cs, intent, native, *, source_ns, now_ns, axis_ses
|
||||
not cs.steerFaultTemporary and not cs.steerFaultPermanent and cs.cruiseState.available and
|
||||
(cs.gearShifter in (car.CarState.GearShifter.drive, car.CarState.GearShifter.low,
|
||||
car.CarState.GearShifter.sport, car.CarState.GearShifter.brake) or
|
||||
cp.carFingerprint == 'SUBARU_LEGACY_2025' and cs.gearShifter == car.CarState.GearShifter.manumatic) and
|
||||
cp.carFingerprint in FROGGER_ANGLE_SIBLINGS | {SUBARU_CAR.SUBARU_LEGACY_2025} and
|
||||
cs.gearShifter == car.CarState.GearShifter.manumatic) and
|
||||
intent is not None and intent.settingsQualified and intent.allowedLatch and intent.lateralArmed and
|
||||
intent.producerSessionId and intent.carStateLogMonoTime == source_ns and
|
||||
0 < source_ns <= intent.observedMonoTime <= now_ns <= intent.validUntilMonoTime and
|
||||
|
||||
@@ -2,12 +2,14 @@ def seatbelt_lateral_soft_event_allowed(cp, cs, intent, native, event, *, source
|
||||
pending_lateral_request=False, gear_pause=False) -> bool:
|
||||
"""Keep the belt a LONG lock while qualified pauses retain armed LAT intent."""
|
||||
from opendbc.car.structs import car
|
||||
from opendbc.car.subaru.values import CAR as SUBARU_CAR, FROGGER_ANGLE_SIBLINGS
|
||||
from openpilot.starpilot.aol.vehicle import policy_for
|
||||
from openpilot.cereal import log
|
||||
from openpilot.starpilot.aol.runtime import AXIS_MAX_AGE_NS, SAFETY_MAX_AGE_NS, native_inventory_matches_cp
|
||||
try:
|
||||
gears = car.CarState.GearShifter
|
||||
legacy_manumatic = cp.carFingerprint == 'SUBARU_LEGACY_2025' and cs.gearShifter == gears.manumatic
|
||||
legacy_manumatic = (cp.carFingerprint in FROGGER_ANGLE_SIBLINGS | {SUBARU_CAR.SUBARU_LEGACY_2025} and
|
||||
cs.gearShifter == gears.manumatic)
|
||||
paused_gear = bool(gear_pause is True and (cs.gearShifter in
|
||||
(gears.drive, gears.low, gears.sport, gears.brake, gears.neutral, gears.reverse) or
|
||||
legacy_manumatic))
|
||||
|
||||
@@ -14,9 +14,10 @@ AlertLevel = log.DriverMonitoringState.AlertLevel
|
||||
|
||||
|
||||
def _forward_gear_allowed(cp, gear) -> bool:
|
||||
from opendbc.car.subaru.values import CAR as SUBARU_CAR, FROGGER_ANGLE_SIBLINGS
|
||||
gears = car.CarState.GearShifter
|
||||
return gear in (gears.drive, gears.sport, gears.low, gears.brake) or (
|
||||
cp.carFingerprint == 'SUBARU_LEGACY_2025' and gear == gears.manumatic)
|
||||
cp.carFingerprint in FROGGER_ANGLE_SIBLINGS | {SUBARU_CAR.SUBARU_LEGACY_2025} and gear == gears.manumatic)
|
||||
|
||||
|
||||
def stock_lateral_role(self, CS, native, intent=None, *, allow_independent_cancel=False, allow_independent_brake=False,
|
||||
@@ -61,6 +62,7 @@ def stock_lateral_role(self, CS, native, intent=None, *, allow_independent_cance
|
||||
previous = getattr(self, 'aol_axis_decision', None)
|
||||
from opendbc.car.gm.aol import qualified_gm
|
||||
from opendbc.car.subaru.stock_aol import qualified as subaru_qualified
|
||||
from opendbc.car.subaru.values import CAR as SUBARU_CAR, FROGGER_ANGLE_SIBLINGS
|
||||
|
||||
gas_role = bool((self.CP.brand == 'hyundai' and len(self.CP.safetyConfigs) == 1 and
|
||||
(stock_canfd_qualified(self.CP, marked_only=True) or hkg_stock) or self.CP.brand == 'gm' and qualified_gm(self.CP) and self.CP.pcmCruise and
|
||||
@@ -72,7 +74,8 @@ def stock_lateral_role(self, CS, native, intent=None, *, allow_independent_cance
|
||||
(previous.native_acknowledged or allow_expired_source) and not previous.longitudinal_active and
|
||||
(CS.gearShifter == car.CarState.GearShifter.drive or self.CP.brand == 'gm' and
|
||||
CS.gearShifter == car.CarState.GearShifter.low or
|
||||
self.CP.carFingerprint == 'SUBARU_LEGACY_2025' and CS.gearShifter == car.CarState.GearShifter.manumatic) and isfinite(CS.vEgoRaw) and isfinite(CS.vEgo))
|
||||
self.CP.carFingerprint in FROGGER_ANGLE_SIBLINGS | {SUBARU_CAR.SUBARU_LEGACY_2025} and
|
||||
CS.gearShifter == car.CarState.GearShifter.manumatic) and isfinite(CS.vEgoRaw) and isfinite(CS.vEgo))
|
||||
rules = self.events.event_rules
|
||||
stock_user = stock_lateral_user_event(self.CP)
|
||||
users = [name for name in self.events.names if ET.USER_DISABLE in rules.get(name, {})]
|
||||
|
||||
@@ -160,6 +160,7 @@ def temporary_steering_intent_current(self, sm, cp, cs, axis, stamp, now_ns, *,
|
||||
all(not event.userDisable or event.name == log.OnroadEvent.EventName.pcmDisable and
|
||||
not event.softDisable and not event.immediateDisable for event in events))
|
||||
from opendbc.car.subaru.stock_aol import temporary_restriction as subaru_temporary_restriction
|
||||
from opendbc.car.subaru.values import CAR as SUBARU_CAR, FROGGER_ANGLE_SIBLINGS
|
||||
subaru_predecessor = bool(previous is not None and
|
||||
0 < previous[8] <= previous[2] <= now_ns <= previous[4] and
|
||||
now_ns - previous[8] <= AXIS_MAX_AGE_NS and
|
||||
@@ -167,7 +168,8 @@ def temporary_steering_intent_current(self, sm, cp, cs, axis, stamp, now_ns, *,
|
||||
self.temporary_eps_event_ns and previous[6] == self.temporary_eps_event_ns))
|
||||
stock_subaru_eps = bool(subaru_temporary_restriction(cp, cs) and subaru_predecessor and
|
||||
(cs.gearShifter == structs.CarState.GearShifter.drive or
|
||||
cp.carFingerprint == 'SUBARU_LEGACY_2025' and cs.gearShifter == structs.CarState.GearShifter.manumatic) and not cs.doorOpen and
|
||||
cp.carFingerprint in FROGGER_ANGLE_SIBLINGS | {SUBARU_CAR.SUBARU_LEGACY_2025} and
|
||||
cs.gearShifter == structs.CarState.GearShifter.manumatic) and not cs.doorOpen and
|
||||
not cs.vehicleSensorsInvalid and not cs.steeringDisengage and not cs.buttonEvents and
|
||||
all(not event.userDisable or event.name == log.OnroadEvent.EventName.pcmDisable and
|
||||
not event.softDisable and not event.immediateDisable for event in events))
|
||||
|
||||
@@ -55,13 +55,16 @@ def stock_lateral_off(cp, cs, native, *, allow_independent_cancel=False, allow_i
|
||||
|
||||
def forward_gear_allowed(cp, gear) -> bool:
|
||||
from opendbc.car import structs
|
||||
from opendbc.car.subaru.values import CAR as SUBARU_CAR, FROGGER_ANGLE_SIBLINGS
|
||||
gears = structs.CarState.GearShifter
|
||||
return gear in (gears.drive, gears.sport, gears.low, gears.brake) or (
|
||||
cp.carFingerprint == 'SUBARU_LEGACY_2025' and gear == gears.manumatic)
|
||||
cp.carFingerprint in FROGGER_ANGLE_SIBLINGS | {SUBARU_CAR.SUBARU_LEGACY_2025} and gear == gears.manumatic)
|
||||
|
||||
|
||||
def subaru_stop_drive_gear(cp, gear, subaru_stop: bool) -> bool:
|
||||
from opendbc.car import structs
|
||||
from opendbc.car.subaru.values import CAR as SUBARU_CAR, FROGGER_ANGLE_SIBLINGS
|
||||
gears = structs.CarState.GearShifter
|
||||
return gear == gears.drive or (
|
||||
subaru_stop and cp.carFingerprint == 'SUBARU_LEGACY_2025' and gear == gears.manumatic)
|
||||
subaru_stop and cp.carFingerprint in FROGGER_ANGLE_SIBLINGS | {SUBARU_CAR.SUBARU_LEGACY_2025} and
|
||||
gear == gears.manumatic)
|
||||
|
||||
@@ -14,6 +14,6 @@ def unsupported_gear(cp, gear) -> bool:
|
||||
return gm_unsupported(cp, gear)
|
||||
if cp.brand == "subaru":
|
||||
from opendbc.car.structs import car
|
||||
from opendbc.car.subaru.values import CAR
|
||||
return cp.carFingerprint != CAR.SUBARU_LEGACY_2025 and gear == car.CarState.GearShifter.manumatic
|
||||
from opendbc.car.subaru.values import CAR, FROGGER_ANGLE_SIBLINGS
|
||||
return cp.carFingerprint not in FROGGER_ANGLE_SIBLINGS | {CAR.SUBARU_LEGACY_2025} and gear == car.CarState.GearShifter.manumatic
|
||||
return False
|
||||
|
||||
@@ -17,7 +17,7 @@ def known_paddle_pause(cp, state, samples=()):
|
||||
|
||||
|
||||
def _drive_gear(cp, state):
|
||||
if cp is not None and cp.carFingerprint == CAR.SUBARU_LEGACY_2025:
|
||||
if cp is not None and cp.carFingerprint in FROGGER_ANGLE_SIBLINGS | {CAR.SUBARU_LEGACY_2025}:
|
||||
return state.gearShifter in (structs.CarState.GearShifter.drive, structs.CarState.GearShifter.manumatic)
|
||||
return state.gearShifter == structs.CarState.GearShifter.drive
|
||||
|
||||
@@ -139,13 +139,14 @@ def create_intent(cp, settings):
|
||||
main_arm = (cp.carFingerprint in (CAR.SUBARU_CROSSTREK_2025, CAR.SUBARU_IMPREZA_2025) or
|
||||
(cp.carFingerprint in EARLY_GLOBAL_TORQUE_CARS | {CAR.SUBARU_IMPREZA_2020, CAR.SUBARU_LEGACY_2025, CAR.SUBARU_OUTBACK_2023} and qualified(cp)))
|
||||
return SubaruStockCardIntent(settings, main_arm=main_arm,
|
||||
allow_manumatic=(cp.carFingerprint == CAR.SUBARU_LEGACY_2025))
|
||||
allow_manumatic=(cp.carFingerprint in FROGGER_ANGLE_SIBLINGS | {CAR.SUBARU_LEGACY_2025}))
|
||||
|
||||
|
||||
def sng_standstill_lateral_inhibit(cp, state, *, initial_wait: bool = False):
|
||||
# All stock Subaru native profiles require movement (and Legacy 2025 waits for !brake_pressed before initial grant).
|
||||
# All stock Subaru native profiles require movement (and Legacy/siblings wait for !brake_pressed before initial grant).
|
||||
# Withdraw the request before its expected denial, preserving ordinary stock ACC without granting either axis.
|
||||
legacy_brake_wait = bool(cp.carFingerprint == CAR.SUBARU_LEGACY_2025 and initial_wait and state.brakePressed)
|
||||
legacy_brake_wait = bool(cp.carFingerprint in FROGGER_ANGLE_SIBLINGS | {CAR.SUBARU_LEGACY_2025} and
|
||||
initial_wait and state.brakePressed)
|
||||
return bool(qualified(cp, marked_only=True) and (state.standstill or legacy_brake_wait))
|
||||
|
||||
|
||||
@@ -164,7 +165,8 @@ def retain_braked_main_intent(feedback, sm, cp, state, axis, now_ns, *, arm_ns,
|
||||
from openpilot.starpilot.aol.transport_pause import _configured_transport_native
|
||||
pending = feedback.subaru_braked_main
|
||||
epoch = int(axis.intentIntegrityEpoch)
|
||||
if (cp.carFingerprint not in (CAR.SUBARU_IMPREZA_2020, CAR.SUBARU_IMPREZA_2025, CAR.SUBARU_LEGACY_2025) or not qualified(cp, marked_only=True) or
|
||||
if (cp.carFingerprint not in FROGGER_ANGLE_SIBLINGS | {CAR.SUBARU_IMPREZA_2020, CAR.SUBARU_LEGACY_2025} or
|
||||
not qualified(cp, marked_only=True) or
|
||||
feedback.failed or feedback.paused or feedback.pending_event or arm_ns <= feedback.subaru_lateral_grant_ns or
|
||||
not producer or axis.intentProducerSessionId != producer or
|
||||
not 0 < arm_ns <= axis.sourceCarStateMonoTime <= now_ns or
|
||||
@@ -207,7 +209,8 @@ def retain_stopped_intent(feedback, sm, cp, state, axis, now_ns, *, latched, pro
|
||||
from openpilot.starpilot.aol.transport_pause import _healthy_transport_native, cp_identity
|
||||
|
||||
previous = feedback.signature
|
||||
if (cp.carFingerprint not in (CAR.SUBARU_IMPREZA_2020, CAR.SUBARU_LEGACY_2025) or not qualified(cp, marked_only=True) or
|
||||
if (cp.carFingerprint not in FROGGER_ANGLE_SIBLINGS | {CAR.SUBARU_IMPREZA_2020, CAR.SUBARU_LEGACY_2025} or
|
||||
not qualified(cp, marked_only=True) or
|
||||
not latched or not feedback.ever_lateral_active or feedback.failed or feedback.paused or
|
||||
feedback.pending_event or feedback.retention_started_ns or feedback.source_retention_started_ns or
|
||||
not feedback.session or cp_identity(cp) != feedback.cp or previous is None or signature != previous or
|
||||
@@ -241,7 +244,7 @@ def retain_stopped_intent(feedback, sm, cp, state, axis, now_ns, *, latched, pro
|
||||
|
||||
|
||||
def sync_legacy_card_lateral(card, cs, cc) -> None:
|
||||
if (card.CP.carFingerprint == CAR.SUBARU_LEGACY_2025 and cs.cruiseState.available and
|
||||
if (card.CP.carFingerprint in FROGGER_ANGLE_SIBLINGS | {CAR.SUBARU_LEGACY_2025} and cs.cruiseState.available and
|
||||
getattr(card.CI.CS, "_lkas_mode_settle_frames", 0) == 0):
|
||||
card.CI.CS.lateral_off = not bool(cc.hudControl.lanesVisible)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ from math import isfinite
|
||||
|
||||
from opendbc.car import structs
|
||||
from opendbc.car.subaru.stock_aol import qualified
|
||||
from opendbc.car.subaru.values import CAR
|
||||
from opendbc.car.subaru.values import CAR, FROGGER_ANGLE_SIBLINGS
|
||||
from openpilot.cereal import log
|
||||
from openpilot.starpilot.aol.runtime import AXIS_MAX_AGE_NS, SAFETY_MAX_AGE_NS
|
||||
from openpilot.starpilot.aol.wire import IntentState, SafetyState
|
||||
@@ -207,7 +207,8 @@ def retain_paused_restriction(feedback, sm, cp, state, axis, stamp, now_ns, *, l
|
||||
state.accFaulted or state.doorOpen or state.seatbeltUnlatched or state.vehicleSensorsInvalid or
|
||||
state.steeringDisengage or state.buttonEvents or state.gasPressed or state.regenBraking or
|
||||
(state.gearShifter != structs.CarState.GearShifter.drive and
|
||||
not (cp.carFingerprint == CAR.SUBARU_LEGACY_2025 and state.gearShifter == structs.CarState.GearShifter.manumatic)) or
|
||||
not (cp.carFingerprint in FROGGER_ANGLE_SIBLINGS | {CAR.SUBARU_LEGACY_2025} and
|
||||
state.gearShifter == structs.CarState.GearShifter.manumatic)) or
|
||||
not state.cruiseState.available or state.cruiseState.enabled or
|
||||
not 0 < feedback.healthy_feedback_ns <= now_ns or not feedback.healthy_inventory):
|
||||
return False
|
||||
@@ -274,7 +275,8 @@ def retain_pending_restriction_recovery(feedback, sm, cp, state, axis, stamp, no
|
||||
state.accFaulted or state.doorOpen or state.seatbeltUnlatched or state.vehicleSensorsInvalid or
|
||||
state.steeringDisengage or state.buttonEvents or state.regenBraking or
|
||||
(state.gearShifter != structs.CarState.GearShifter.drive and
|
||||
not (cp.carFingerprint == CAR.SUBARU_LEGACY_2025 and state.gearShifter == structs.CarState.GearShifter.manumatic)) or
|
||||
not (cp.carFingerprint in FROGGER_ANGLE_SIBLINGS | {CAR.SUBARU_LEGACY_2025} and
|
||||
state.gearShifter == structs.CarState.GearShifter.manumatic)) or
|
||||
not state.cruiseState.available or state.cruiseState.enabled):
|
||||
return False
|
||||
event_ns = int(sm.logMonoTime['onroadEvents'])
|
||||
|
||||
@@ -199,7 +199,7 @@ def test_actual_startup_factory_card_controls_native(enabled, combined, aol, sub
|
||||
expected = ci.CC.angle_was_active if steering_name == 'ES_LKAS_ANGLE' else card.sm['carControl'].latActive
|
||||
if sibling or candidate == CAR.SUBARU_LEGACY_2025:
|
||||
assert bool(dash['LKAS_ACTIVE']), (candidate, tick, expected, dash)
|
||||
dash_green = ci.CC.aol_dash_green_last if candidate == CAR.SUBARU_LEGACY_2025 else expected
|
||||
dash_green = ci.CC.aol_dash_green_last
|
||||
if not cs.cruiseState.available or cs.steerFaultTemporary or cs.steerFaultPermanent:
|
||||
assert not ci.CC.aol_dash_green_last, (candidate, tick, dash)
|
||||
if expected:
|
||||
|
||||
@@ -102,7 +102,7 @@ def test_impreza_main_setting_is_exact_and_preserves_stock_assist_selection():
|
||||
|
||||
def test_outback_main_intent_uses_only_existing_exact_native_profiles():
|
||||
from opendbc.car.subaru.interface import CarInterface
|
||||
from opendbc.car.subaru.values import CAR, SubaruFlags
|
||||
from opendbc.car.subaru.values import CAR, FROGGER_ANGLE_SIBLINGS, SubaruFlags
|
||||
from opendbc.car.subaru.stock_aol import qualified
|
||||
from openpilot.starpilot.car.subaru.aol import create_intent
|
||||
|
||||
@@ -117,33 +117,34 @@ def test_outback_main_intent_uses_only_existing_exact_native_profiles():
|
||||
assert qualified(cp, marked_only=True)
|
||||
cp.safetyConfigs[0].safetyParam |= 2
|
||||
assert not qualified(cp) and not create_intent(cp, owner().settings).main_arm
|
||||
legacy = CarInterface.get_non_essential_params(CAR.SUBARU_LEGACY_2025)
|
||||
legacy.alternativeExperience = 32
|
||||
legacy_intent = create_intent(legacy, owner().settings)
|
||||
assert qualified(legacy) and legacy_intent.main_arm and legacy_intent.allow_manumatic
|
||||
legacy_cs = state()
|
||||
legacy_cs.gearShifter = structs.CarState.GearShifter.manumatic
|
||||
observe(legacy_intent, legacy_cs, 1_000_000, 1_000_000, False)
|
||||
legacy_cs.cruiseState.available = True
|
||||
observe(legacy_intent, legacy_cs, 10_000_000, 1_000_000, False)
|
||||
observe(legacy_intent, legacy_cs, 20_000_000, 10_000_000, False)
|
||||
assert legacy_intent.allowed_latch
|
||||
for candidate in sorted(FROGGER_ANGLE_SIBLINGS | {CAR.SUBARU_LEGACY_2025}):
|
||||
legacy = CarInterface.get_non_essential_params(candidate)
|
||||
legacy.alternativeExperience = 32
|
||||
legacy_intent = create_intent(legacy, owner().settings)
|
||||
assert qualified(legacy) and legacy_intent.main_arm and legacy_intent.allow_manumatic
|
||||
legacy_cs = state()
|
||||
legacy_cs.gearShifter = structs.CarState.GearShifter.manumatic
|
||||
observe(legacy_intent, legacy_cs, 1_000_000, 1_000_000, False)
|
||||
legacy_cs.cruiseState.available = True
|
||||
observe(legacy_intent, legacy_cs, 10_000_000, 1_000_000, False)
|
||||
observe(legacy_intent, legacy_cs, 20_000_000, 10_000_000, False)
|
||||
assert legacy_intent.allowed_latch
|
||||
|
||||
# Pressing MAIN while still in Park, passing through Reverse, then shifting to Drive arms AOL.
|
||||
park_intent = create_intent(legacy, owner().settings)
|
||||
park_cs = state()
|
||||
park_cs.gearShifter = structs.CarState.GearShifter.park
|
||||
observe(park_intent, park_cs, 1_000_000, 1_000_000, False)
|
||||
park_cs.cruiseState.available = True
|
||||
observe(park_intent, park_cs, 10_000_000, 1_000_000, False)
|
||||
assert not park_intent.allowed_latch
|
||||
park_cs.gearShifter = structs.CarState.GearShifter.reverse
|
||||
observe(park_intent, park_cs, 20_000_000, 10_000_000, False)
|
||||
assert not park_intent.allowed_latch
|
||||
park_cs.gearShifter = structs.CarState.GearShifter.drive
|
||||
observe(park_intent, park_cs, 30_000_000, 20_000_000, False)
|
||||
observe(park_intent, park_cs, 40_000_000, 30_000_000, False)
|
||||
assert park_intent.allowed_latch
|
||||
# Pressing MAIN while still in Park, passing through Reverse, then shifting to Drive arms AOL.
|
||||
park_intent = create_intent(legacy, owner().settings)
|
||||
park_cs = state()
|
||||
park_cs.gearShifter = structs.CarState.GearShifter.park
|
||||
observe(park_intent, park_cs, 1_000_000, 1_000_000, False)
|
||||
park_cs.cruiseState.available = True
|
||||
observe(park_intent, park_cs, 10_000_000, 1_000_000, False)
|
||||
assert not park_intent.allowed_latch
|
||||
park_cs.gearShifter = structs.CarState.GearShifter.reverse
|
||||
observe(park_intent, park_cs, 20_000_000, 10_000_000, False)
|
||||
assert not park_intent.allowed_latch
|
||||
park_cs.gearShifter = structs.CarState.GearShifter.drive
|
||||
observe(park_intent, park_cs, 30_000_000, 20_000_000, False)
|
||||
observe(park_intent, park_cs, 40_000_000, 30_000_000, False)
|
||||
assert park_intent.allowed_latch
|
||||
|
||||
outback = CarInterface.get_non_essential_params(CAR.SUBARU_OUTBACK)
|
||||
outback.alternativeExperience = 32
|
||||
@@ -153,7 +154,7 @@ def test_outback_main_intent_uses_only_existing_exact_native_profiles():
|
||||
def test_legacy_2025_manumatic_and_aol_intent():
|
||||
from opendbc.car.subaru.interface import CarInterface
|
||||
from opendbc.car.subaru.stock_aol import qualified
|
||||
from opendbc.car.subaru.values import CAR
|
||||
from opendbc.car.subaru.values import CAR, FROGGER_ANGLE_SIBLINGS
|
||||
from openpilot.starpilot.aol.intent import independent_axis_requested
|
||||
from openpilot.starpilot.car.events import unsupported_gear
|
||||
from openpilot.starpilot.car.subaru.aol import create_intent
|
||||
@@ -164,11 +165,8 @@ def test_legacy_2025_manumatic_and_aol_intent():
|
||||
|
||||
assert Gear.manumatic in CarInterface.DRIVABLE_GEARS
|
||||
|
||||
legacy = CarInterface.get_non_essential_params(CAR.SUBARU_LEGACY_2025)
|
||||
legacy.alternativeExperience = 32
|
||||
outback_2023 = CarInterface.get_non_essential_params(CAR.SUBARU_OUTBACK_2023)
|
||||
ascent_2023 = CarInterface.get_non_essential_params(CAR.SUBARU_ASCENT_2023)
|
||||
assert not unsupported_gear(legacy, Gear.manumatic)
|
||||
assert unsupported_gear(outback_2023, Gear.manumatic)
|
||||
assert unsupported_gear(ascent_2023, Gear.manumatic)
|
||||
|
||||
@@ -177,28 +175,32 @@ def test_legacy_2025_manumatic_and_aol_intent():
|
||||
assert independent_axis_requested(aol_settings)
|
||||
assert not independent_axis_requested(disabled_settings)
|
||||
|
||||
legacy_intent = create_intent(legacy, aol_settings)
|
||||
assert qualified(legacy) and legacy_intent.main_arm and legacy_intent.allow_manumatic
|
||||
for candidate in sorted(FROGGER_ANGLE_SIBLINGS | {CAR.SUBARU_LEGACY_2025}):
|
||||
legacy = CarInterface.get_non_essential_params(candidate)
|
||||
legacy.alternativeExperience = 32
|
||||
assert not unsupported_gear(legacy, Gear.manumatic)
|
||||
legacy_intent = create_intent(legacy, aol_settings)
|
||||
assert qualified(legacy) and legacy_intent.main_arm and legacy_intent.allow_manumatic
|
||||
|
||||
legacy_cs = state()
|
||||
legacy_cs.gearShifter = Gear.drive
|
||||
observe(legacy_intent, legacy_cs, 1_000_000, 1_000_000, False)
|
||||
legacy_cs.cruiseState.available = True
|
||||
observe(legacy_intent, legacy_cs, 10_000_000, 1_000_000, False)
|
||||
observe(legacy_intent, legacy_cs, 20_000_000, 10_000_000, False)
|
||||
assert legacy_intent.allowed_latch
|
||||
legacy_cs = state()
|
||||
legacy_cs.gearShifter = Gear.drive
|
||||
observe(legacy_intent, legacy_cs, 1_000_000, 1_000_000, False)
|
||||
legacy_cs.cruiseState.available = True
|
||||
observe(legacy_intent, legacy_cs, 10_000_000, 1_000_000, False)
|
||||
observe(legacy_intent, legacy_cs, 20_000_000, 10_000_000, False)
|
||||
assert legacy_intent.allowed_latch
|
||||
|
||||
legacy_cs.gearShifter = Gear.manumatic
|
||||
legacy_cs.buttonEvents = [
|
||||
ButtonEvent.new_message(type=ButtonType.lkas, pressed=True),
|
||||
ButtonEvent.new_message(type=ButtonType.lkas, pressed=False),
|
||||
]
|
||||
observe(legacy_intent, legacy_cs, 30_000_000, 20_000_000, False)
|
||||
assert legacy_intent.allowed_latch
|
||||
legacy_cs.gearShifter = Gear.manumatic
|
||||
legacy_cs.buttonEvents = [
|
||||
ButtonEvent.new_message(type=ButtonType.lkas, pressed=True),
|
||||
ButtonEvent.new_message(type=ButtonType.lkas, pressed=False),
|
||||
]
|
||||
observe(legacy_intent, legacy_cs, 30_000_000, 20_000_000, False)
|
||||
assert legacy_intent.allowed_latch
|
||||
|
||||
legacy_cs.buttonEvents = []
|
||||
observe(legacy_intent, legacy_cs, 40_000_000, 30_000_000, False)
|
||||
assert legacy_intent.allowed_latch
|
||||
legacy_cs.buttonEvents = []
|
||||
observe(legacy_intent, legacy_cs, 40_000_000, 30_000_000, False)
|
||||
assert legacy_intent.allowed_latch
|
||||
|
||||
|
||||
def test_legacy_2025_line_visibility_and_passive_dashcam_chimes():
|
||||
@@ -244,12 +246,10 @@ def test_legacy_2025_line_visibility_and_passive_dashcam_chimes():
|
||||
return data[key]
|
||||
|
||||
drive = SelfdriveD.__new__(SelfdriveD)
|
||||
drive.CP = structs.CarParams(carFingerprint="SUBARU_LEGACY_2025", passive=True)
|
||||
drive.enabled = False
|
||||
drive.personality = log.LongitudinalPersonality.standard
|
||||
drive.is_metric = False
|
||||
drive.events = Events()
|
||||
drive.AM = AlertManager()
|
||||
drive.params = Params()
|
||||
drive.switchback_capable = False
|
||||
drive.switchback_setting_ns = now
|
||||
@@ -258,22 +258,26 @@ def test_legacy_2025_line_visibility_and_passive_dashcam_chimes():
|
||||
drive.aol_axis_decision = AxisDecision()
|
||||
drive.aol_fault_reason = 'none'
|
||||
drive.radar_recovery_enabled = False
|
||||
drive.legacy_2025_green_wheel_active = True
|
||||
vars(drive)['state_machine'] = SimpleNamespace(current_alert_types=[], soft_disable_timer=0)
|
||||
vars(drive)['sm'] = _Sm()
|
||||
for fingerprint in ("SUBARU_LEGACY_2025", "SUBARU_IMPREZA_2025", "SUBARU_CROSSTREK_2025"):
|
||||
drive.CP = structs.CarParams(carFingerprint=fingerprint, passive=True)
|
||||
drive.AM = AlertManager()
|
||||
drive.legacy_2025_green_wheel_active = True
|
||||
drive.sm.frame += 1
|
||||
|
||||
cs = structs.CarState(canValid=True, canTimeout=False)
|
||||
cs.cruiseState.available = True
|
||||
cs = structs.CarState(canValid=True, canTimeout=False)
|
||||
cs.cruiseState.available = True
|
||||
|
||||
drive.update_alerts(cs)
|
||||
assert not drive.legacy_2025_green_wheel_active
|
||||
assert drive.AM.current_alert.alert_type == ""
|
||||
drive.update_alerts(cs)
|
||||
assert not drive.legacy_2025_green_wheel_active
|
||||
assert drive.AM.current_alert.alert_type == ""
|
||||
|
||||
drive.CP.passive = False
|
||||
drive.sm.frame += 1
|
||||
drive.update_alerts(cs)
|
||||
assert drive.legacy_2025_green_wheel_active
|
||||
assert drive.AM.current_alert.alert_type == "legacy2025AolEngage/enable"
|
||||
drive.CP.passive = False
|
||||
drive.sm.frame += 1
|
||||
drive.update_alerts(cs)
|
||||
assert drive.legacy_2025_green_wheel_active
|
||||
assert drive.AM.current_alert.alert_type == "legacy2025AolEngage/enable"
|
||||
|
||||
|
||||
def test_legacy_2025_manumatic_driver_monitoring_isolation(tmp_path):
|
||||
@@ -285,7 +289,8 @@ def test_legacy_2025_manumatic_driver_monitoring_isolation(tmp_path):
|
||||
|
||||
params = Params(str(tmp_path))
|
||||
assert _read_allow_manumatic(params) is None
|
||||
for fingerprint, expected in (("SUBARU_OUTBACK_2023", False), ("SUBARU_LEGACY_2025", True)):
|
||||
for fingerprint, expected in (("SUBARU_OUTBACK_2023", False), ("SUBARU_LEGACY_2025", True),
|
||||
("SUBARU_IMPREZA_2025", True), ("SUBARU_CROSSTREK_2025", True)):
|
||||
params.put("CarParams", structs.CarParams(carFingerprint=fingerprint).to_bytes(), block=True)
|
||||
assert _read_allow_manumatic(params) is expected
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ from opendbc.car.subaru.interface import CarInterface
|
||||
from opendbc.car.subaru.sng import StopAndGo, SUPPORTED, prepare, selected
|
||||
from opendbc.car.subaru.sng_sender import replacement
|
||||
from opendbc.car.subaru.software_cruise import prepare as prepare_software, selected as software_selected
|
||||
from opendbc.car.subaru.values import CAR
|
||||
from opendbc.car.subaru.values import CAR, FROGGER_ANGLE_SIBLINGS
|
||||
|
||||
|
||||
@pytest.mark.parametrize('candidate', list(CAR))
|
||||
@@ -145,13 +145,15 @@ def test_sng_standstill_request_withdrawal_is_exact_and_does_not_grant_axis():
|
||||
# Non-Legacy Subarus keep upstream standstill-only inhibit even with initial_wait=True.
|
||||
stopped.brakePressed = True
|
||||
assert not sng_standstill_lateral_inhibit(cp, stopped, initial_wait=True)
|
||||
# Legacy 2025 rolling with foot lightly on brake waits before Panda's initial !brake_pressed grant, then releases once brake lifts.
|
||||
legacy_cp = CarInterface.get_params(CAR.SUBARU_LEGACY_2025, gen_empty_fingerprint(), [], False, False, False)
|
||||
legacy_cp.alternativeExperience = 32
|
||||
assert sng_standstill_lateral_inhibit(legacy_cp, stopped, initial_wait=True)
|
||||
assert not sng_standstill_lateral_inhibit(legacy_cp, stopped, initial_wait=False)
|
||||
stopped.brakePressed = False
|
||||
assert not sng_standstill_lateral_inhibit(legacy_cp, stopped, initial_wait=True)
|
||||
# Legacy 2025 + siblings rolling with foot lightly on brake wait before Panda's initial !brake_pressed grant, then release once brake lifts.
|
||||
for car_id in sorted(FROGGER_ANGLE_SIBLINGS | {CAR.SUBARU_LEGACY_2025}):
|
||||
stopped.brakePressed = True
|
||||
legacy_cp = CarInterface.get_params(car_id, gen_empty_fingerprint(), [], False, False, False)
|
||||
legacy_cp.alternativeExperience = 32
|
||||
assert sng_standstill_lateral_inhibit(legacy_cp, stopped, initial_wait=True)
|
||||
assert not sng_standstill_lateral_inhibit(legacy_cp, stopped, initial_wait=False)
|
||||
stopped.brakePressed = False
|
||||
assert not sng_standstill_lateral_inhibit(legacy_cp, stopped, initial_wait=True)
|
||||
cp.openpilotLongitudinalControl = True
|
||||
stopped.standstill = True
|
||||
assert not sng_standstill_lateral_inhibit(cp, stopped)
|
||||
|
||||
@@ -363,7 +363,7 @@ def test_actual_full_engage_brake_reverse_temporary_recovery_mainoff(candidate,
|
||||
expected = ci.CC.angle_was_active if steering_name == 'ES_LKAS_ANGLE' else card.sm['carControl'].latActive
|
||||
if candidate in FROGGER_ANGLE_SIBLINGS | {CAR.SUBARU_LEGACY_2025}:
|
||||
assert bool(dash['LKAS_ACTIVE']), (candidate, tick, expected, dash)
|
||||
dash_green = ci.CC.aol_dash_green_last if candidate == CAR.SUBARU_LEGACY_2025 else expected
|
||||
dash_green = ci.CC.aol_dash_green_last
|
||||
if not cs.cruiseState.available or cs.steerFaultTemporary or cs.steerFaultPermanent:
|
||||
assert not ci.CC.aol_dash_green_last, (candidate, tick, dash)
|
||||
if expected:
|
||||
|
||||
@@ -40,6 +40,7 @@ from openpilot.cereal import log
|
||||
from openpilot.cereal.services import SERVICE_LIST
|
||||
from openpilot.tools.replay.display_clock import BOOT_TIME_SERVICES
|
||||
from opendbc.car.gm.values import bolt_pedal_in_drive_requires_low
|
||||
from opendbc.car.subaru.values import CAR as SUBARU_CAR, FROGGER_ANGLE_SIBLINGS
|
||||
from opendbc.car.structs import car as car_schema
|
||||
from openpilot.starpilot.ui.device_state import DeviceRequest, DeviceState
|
||||
from openpilot.starpilot.ui.home_state import DriveStatsData, HomeMode, HomeState
|
||||
@@ -694,7 +695,7 @@ class RuntimeSnapshotAdapter:
|
||||
display_message(sm, "vehicleParameters", now_ns, after_frame=after) if started else None, cp,
|
||||
)
|
||||
legacy_2025_lateral_off = bool(
|
||||
cp is not None and getattr(cp, 'carFingerprint', '') == 'SUBARU_LEGACY_2025' and
|
||||
cp is not None and getattr(cp, 'carFingerprint', '') in FROGGER_ANGLE_SIBLINGS | {SUBARU_CAR.SUBARU_LEGACY_2025} and
|
||||
display_control is not None and not getattr(getattr(display_control, 'hudControl', None), 'lanesVisible', True)
|
||||
)
|
||||
display_lat_active = bool(display_control.latActive) if (display_control is not None and not legacy_2025_lateral_off) else False
|
||||
@@ -765,7 +766,7 @@ class RuntimeSnapshotAdapter:
|
||||
car_valid=display_car_valid,
|
||||
system_long=bool(cp is not None and getattr(cp, "openpilotLongitudinalControl", False) and not getattr(cp, "passive", False)),
|
||||
)
|
||||
if cp is not None and getattr(cp, 'carFingerprint', '') == 'SUBARU_LEGACY_2025':
|
||||
if cp is not None and getattr(cp, 'carFingerprint', '') in FROGGER_ANGLE_SIBLINGS | {SUBARU_CAR.SUBARU_LEGACY_2025}:
|
||||
armed_at_stop = False
|
||||
if (aol_latched and display_car_valid and
|
||||
str(getattr(display_car, 'gearShifter', '')) in ('drive', 'manumatic') and
|
||||
|
||||
@@ -115,21 +115,22 @@ class TestOnroadAxes(unittest.TestCase):
|
||||
def test_legacy_2025_armed_stop_covers_creep_threshold_and_manumatic(self):
|
||||
self.ui.aol_runtime = True
|
||||
self.ui.CP.brand = 'subaru'
|
||||
self.ui.CP.carFingerprint = 'SUBARU_LEGACY_2025'
|
||||
self.ui.CP.minSteerSpeed = 0.0
|
||||
car = self.ui.sm['carState']
|
||||
car.steerFaultTemporary = car.steerFaultPermanent = car.accFaulted = False
|
||||
self.publish_latch()
|
||||
for gear in ('drive', 'manumatic'):
|
||||
car.gearShifter = gear
|
||||
car.standstill = False
|
||||
for speed, expected_stop in ((0.0, True), (0.2, True), (0.3, True), (0.35, False)):
|
||||
car.vEgo = speed
|
||||
with self.subTest(gear=gear, speed=speed):
|
||||
st = self.state(False, False)
|
||||
self.assertEqual(st.aol_armed_at_stop, expected_stop)
|
||||
expected_color = (10, 100, 98, 255) if expected_stop else (18, 40, 57, 255)
|
||||
self.assertEqual(rgba(axis_status_color(st)), expected_color)
|
||||
for fingerprint in ('SUBARU_LEGACY_2025', 'SUBARU_IMPREZA_2025', 'SUBARU_CROSSTREK_2025'):
|
||||
self.ui.CP.carFingerprint = fingerprint
|
||||
for gear in ('drive', 'manumatic'):
|
||||
car.gearShifter = gear
|
||||
car.standstill = False
|
||||
for speed, expected_stop in ((0.0, True), (0.2, True), (0.3, True), (0.35, False)):
|
||||
car.vEgo = speed
|
||||
with self.subTest(fingerprint=fingerprint, gear=gear, speed=speed):
|
||||
st = self.state(False, False)
|
||||
self.assertEqual(st.aol_armed_at_stop, expected_stop)
|
||||
expected_color = (10, 100, 98, 255) if expected_stop else (18, 40, 57, 255)
|
||||
self.assertEqual(rgba(axis_status_color(st)), expected_color)
|
||||
|
||||
self.ui.CP.carFingerprint = 'SUBARU_OUTBACK_2023'
|
||||
for gear, standstill, speed, expected_stop in (
|
||||
|
||||
Reference in New Issue
Block a user