Compare commits

...

11 Commits

Author SHA1 Message Date
firestar5683 c880136da8 Repair CI fixtures after Card and UI changes 2026-11-29 00:26:51 -06:00
firestar5683 e7b1b1626d Avoid unused Sonata Hybrid CAN receipt decoding 2026-11-29 00:09:23 -06:00
firestar5683 5261f20cfd Repair CI fixtures after Card and UI changes 2026-11-29 00:07:46 -06:00
firestar5683 70dfdfca6f Repair CI fixtures after Card and UI changes 2026-11-28 23:53:31 -06:00
firestar5683 040e367fb2 Reduce Sonata Hybrid CAN decoding work 2026-11-28 23:52:28 -06:00
firestar5683 7eae03d00e Repair CI fixtures after Card and UI changes 2026-11-28 23:37:24 -06:00
firestar5683 e05759f8f5 Preview End to End Slowdown Before Engagement 2026-11-28 23:35:38 -06:00
firestar5683 65bf82f608 Remove redundant CAN and model work in control loops 2026-11-28 23:21:38 -06:00
firestar5683 7fbe552da8 Repair CI fixtures after Card and UI changes 2026-11-28 23:20:14 -06:00
firestar5683 efaf16f95d Reuse static AOL configuration in the Card loop 2026-11-28 23:15:43 -06:00
rav4kumar c3e9f5de35 Allow Enhanced BSM with factory Prius sensors 2026-11-28 23:05:28 -06:00
89 changed files with 429 additions and 200 deletions
+2 -3
View File
@@ -90,7 +90,7 @@ class MessageState:
self.counter = cur_count
return self.counter_fail < MAX_BAD_COUNTER
def valid(self, current_nanos: int, bus_timeout: bool) -> bool:
def valid(self, current_nanos: int) -> bool:
if self.ignore_alive:
return True
if not self.timestamps:
@@ -201,13 +201,12 @@ class CANParser:
def can_valid(self) -> bool:
valid = True
counters_valid = True
bus_timeout = self.bus_timeout
invalid_messages = set()
for state in self.message_states.values():
if state.counter_fail >= MAX_BAD_COUNTER:
counters_valid = False
state.rate_limited_log(self._last_update_nanos, f"counter invalid, {state.counter_fail=} {MAX_BAD_COUNTER=}")
if not state.valid(self._last_update_nanos, bus_timeout):
if not state.valid(self._last_update_nanos):
valid = False
invalid_messages.add(state.address)
@@ -66,7 +66,7 @@ def camera_current(parser):
source = parser.message_states.get(0x2A4)
now = parser._last_update_nanos
bus_timeout = parser.bus_timeout
healthy = all(state.valid(now, bus_timeout) and state.counter_fail < MAX_BAD_COUNTER for state in parser.message_states.values())
healthy = all(state.valid(now) and state.counter_fail < MAX_BAD_COUNTER for state in parser.message_states.values())
return bool(healthy and not bus_timeout and source is not None and source.timestamps
and source.counter_fail < MAX_BAD_COUNTER and 0 < int(source.timestamps[-1]) <= now
and now - int(source.timestamps[-1]) <= source.timeout_threshold)
+25 -3
View File
@@ -375,7 +375,7 @@ class CarState(CarStateBase):
bus_timeout = cp.bus_timeout
self.ev6_aol_source_healthy = bool(
not bus_timeout and source is not None and source.timestamps
and source.valid(now, bus_timeout) and source.counter_fail < MAX_BAD_COUNTER
and source.valid(now) and source.counter_fail < MAX_BAD_COUNTER
and 0 < self.ev6_aol_sample_stamp_ns <= now
and now - self.ev6_aol_sample_stamp_ns <= source.timeout_threshold)
values = cp.vl_all['CLU11']
@@ -578,7 +578,7 @@ class CarState(CarStateBase):
bus_timeout = cp.bus_timeout
self.ev6_aol_source_healthy = bool(
not bus_timeout and source is not None and source.timestamps
and source.valid(now, bus_timeout) and source.counter_fail < MAX_BAD_COUNTER
and source.valid(now) and source.counter_fail < MAX_BAD_COUNTER
and 0 < self.ev6_aol_sample_stamp_ns <= now
and now - self.ev6_aol_sample_stamp_ns <= source.timeout_threshold)
values = cp.vl_all[self.cruise_btns_msg_canfd]
@@ -777,8 +777,30 @@ class CarState(CarStateBase):
msgs.extend((name, 0) for name in {available_msg, enabled_msg, speed_msg})
if not CP.flags & HyundaiFlags.NON_SCC_NO_FCA:
(msgs if CP.flags & HyundaiFlags.NON_SCC_RADAR_FCA else cam_msgs).append(("FCA11", math.nan))
pt_signals = None
if (CP.carFingerprint == CAR.HYUNDAI_SONATA_HYBRID and CP.pcmCruise and not CP.openpilotLongitudinalControl and
not CP.flags & (HyundaiFlags.CAMERA_SCC | HyundaiFlags.NON_SCC)):
pt_signals = {
"BCM_PO_11": ("LDA_BTN",),
"CGW1": ("CF_Gway_DrvDrSw", "CF_Gway_AstDrSw", "CF_Gway_DrvSeatBeltSw", "CF_Gway_TurnSigLh", "CF_Gway_TurnSigRh"),
"CGW2": ("CF_Gway_RLDrSw", "CF_Gway_RRDrSw"),
"CLU15": ("CF_Clu_VehicleSpeed",),
"ELECT_GEAR": ("Elect_Gear_Shifter",),
"E_EMS11": ("CR_Vcu_AccPedDep_Pos",),
"FCA11": ("CF_VSM_Warn", "CF_VSM_DecCmdAct", "FCA_CmdAct"),
"LCA11": ("CF_Lca_IndLeft", "CF_Lca_IndRight"),
"MDPS12": ("CR_Mdps_StrColTq", "CR_Mdps_OutTq", "CF_Mdps_ToiUnavail", "CF_Mdps_ToiFlt", "CF_Mdps_ToiActive"),
"SAS11": ("SAS_Angle", "SAS_Speed"),
"SCC11": ("MainMode_ACC", "SCCInfoDisplay", "VSetDis"),
"SCC12": ("ACCMode", "TakeOverReq", "CF_VSM_Warn", "CF_VSM_DecCmdAct", "AEB_CmdAct"),
"TCS11": ("TCS_PAS", "ABS_ACT"),
"TCS13": ("DriverOverride", "PBRAKE_ACT", "ACCEnable"),
"TCS15": ("AVH_LAMP",),
"WHL_SPD11": ("WHL_SPD_FL", "WHL_SPD_FR", "WHL_SPD_RL", "WHL_SPD_RR"),
}
parsers = {
Bus.pt: CANParser(DBC[CP.carFingerprint][Bus.pt], msgs, 0),
Bus.pt: CANParser(DBC[CP.carFingerprint][Bus.pt], msgs, 0, signals=pt_signals),
Bus.cam: CANParser(DBC[CP.carFingerprint][Bus.pt], cam_msgs, 2),
}
@@ -5,6 +5,18 @@ from opendbc.car.hyundai.classic_scc_aol import CLASSIC_SCC_IDS, stock_word
AOL_MARKER = 0x0400
AOL_EXPERIENCE = 32
_EXCLUDED = int(HyundaiFlags.LEGACY | HyundaiFlags.UNSUPPORTED_LONGITUDINAL | HyundaiFlags.ALT_LIMITS_2 | HyundaiFlags.CAMERA_SCC | HyundaiFlags.FCEV)
_DYNAMIC_FLAGS = int(HyundaiFlags.HAS_LDA_BUTTON | HyundaiFlags.USE_FCA | HyundaiFlags.SEND_LFA)
_IDENTITY_MASK = int(
HyundaiFlags.CANFD
| HyundaiFlags.NON_SCC
| HyundaiFlags.FCEV
| HyundaiFlags.LEGACY
| HyundaiFlags.EV
| HyundaiFlags.HYBRID
| HyundaiFlags.ALT_LIMITS
| HyundaiFlags.ALT_LIMITS_2
| HyundaiFlags.CAMERA_SCC
)
CLASSIC_LONG_IDS = frozenset(identity for identity in CLASSIC_SCC_IDS if not int(identity.config.flags) & _EXCLUDED)
LONG_AOL_WORDS = frozenset(AOL_MARKER | 4 | gas | limits | lda for gas in (0, 1, 2) for limits in (0, 64) for lda in (0, 2048))
@@ -24,33 +36,22 @@ def aol_word(cp):
def qualified(cp, *, marked_only=False):
if not cp.openpilotLongitudinalControl or cp.pcmCruise:
return False
from opendbc.car.hyundai.legacy_long_aol import CARS, qualified as legacy_qualified
if cp.carFingerprint in CARS:
return legacy_qualified(cp, marked_only=marked_only)
if cp.brand != 'hyundai' or cp.carFingerprint not in CLASSIC_LONG_IDS:
return False
declared = int(CAR[cp.carFingerprint].config.flags)
allowed = declared | int(HyundaiFlags.HAS_LDA_BUTTON | HyundaiFlags.USE_FCA | HyundaiFlags.SEND_LFA)
identity_mask = int(
HyundaiFlags.CANFD
| HyundaiFlags.NON_SCC
| HyundaiFlags.FCEV
| HyundaiFlags.LEGACY
| HyundaiFlags.EV
| HyundaiFlags.HYBRID
| HyundaiFlags.ALT_LIMITS
| HyundaiFlags.ALT_LIMITS_2
| HyundaiFlags.CAMERA_SCC
)
allowed = declared | _DYNAMIC_FLAGS
if (
int(cp.flags) & identity_mask != declared & identity_mask
int(cp.flags) & _IDENTITY_MASK != declared & _IDENTITY_MASK
or int(cp.flags) & ~allowed
or is_blended(cp)
or cp.passive
or cp.notCar
or cp.dashcamOnly
or not cp.openpilotLongitudinalControl
or cp.pcmCruise
or cp.steerControlType != structs.CarParams.SteerControlType.torque
or not cp.alphaLongitudinalAvailable
or cp.alternativeExperience not in (0, AOL_EXPERIENCE)
@@ -12,9 +12,21 @@ from opendbc.car.hyundai.values import CAR, HyundaiFlags, HyundaiSafetyFlags, is
AOL_MARKER = 0x0400
AOL_EXPERIENCE = 32
_EXCLUDED = int(HyundaiFlags.CANFD | HyundaiFlags.NON_SCC | HyundaiFlags.FCEV)
_DYNAMIC_FLAGS = int(HyundaiFlags.HAS_LDA_BUTTON | HyundaiFlags.USE_FCA | HyundaiFlags.SEND_LFA)
_IDENTITY_MASK = _EXCLUDED | int(
HyundaiFlags.EV | HyundaiFlags.HYBRID | HyundaiFlags.ALT_LIMITS | HyundaiFlags.ALT_LIMITS_2 | HyundaiFlags.CAMERA_SCC | HyundaiFlags.LEGACY
)
CLASSIC_SCC_IDS = frozenset(identity for identity in CAR if not int(identity.config.flags) & _EXCLUDED and identity != CAR.HYUNDAI_PALISADE_2023) | frozenset(
(CAR.HYUNDAI_NEXO_1ST_GEN,)
)
_STOCK_FLAGS = tuple((int(flag), int(safety)) for flag, safety in (
(HyundaiFlags.FCEV, HyundaiSafetyFlags.FCEV_GAS),
(HyundaiFlags.EV, HyundaiSafetyFlags.EV_GAS),
(HyundaiFlags.HYBRID, HyundaiSafetyFlags.HYBRID_GAS),
(HyundaiFlags.ALT_LIMITS, HyundaiSafetyFlags.ALT_LIMITS),
(HyundaiFlags.ALT_LIMITS_2, HyundaiSafetyFlags.ALT_LIMITS_2),
(HyundaiFlags.CAMERA_SCC, HyundaiSafetyFlags.CAMERA_SCC),
))
_MODELS = (structs.CarParams.SafetyModel.hyundai, structs.CarParams.SafetyModel.hyundaiLegacy)
FCEV_AOL_WORDS = frozenset((0x0500, 0x0D00))
NORMAL_AOL_WORDS = (
@@ -31,16 +43,10 @@ def native_profile_supported(model, param):
def stock_word(cp):
word = int(HyundaiSafetyFlags.CAN_REFRESH_MSGS) if cp.carFingerprint in (CAR.HYUNDAI_ELANTRA_2024, CAR.HYUNDAI_ELANTRA_HEV_2024) else 0
for flag, safety in (
(HyundaiFlags.FCEV, HyundaiSafetyFlags.FCEV_GAS),
(HyundaiFlags.EV, HyundaiSafetyFlags.EV_GAS),
(HyundaiFlags.HYBRID, HyundaiSafetyFlags.HYBRID_GAS),
(HyundaiFlags.ALT_LIMITS, HyundaiSafetyFlags.ALT_LIMITS),
(HyundaiFlags.ALT_LIMITS_2, HyundaiSafetyFlags.ALT_LIMITS_2),
(HyundaiFlags.CAMERA_SCC, HyundaiSafetyFlags.CAMERA_SCC),
):
if int(cp.flags) & int(flag):
word |= int(safety)
flags = int(cp.flags)
for flag, safety in _STOCK_FLAGS:
if flags & flag:
word |= safety
return word
@@ -52,12 +58,9 @@ def qualified(cp, *, marked_only=False):
if cp.brand != "hyundai" or cp.carFingerprint not in CLASSIC_SCC_IDS:
return False
declared = int(CAR[cp.carFingerprint].config.flags)
allowed = declared | int(HyundaiFlags.HAS_LDA_BUTTON | HyundaiFlags.USE_FCA | HyundaiFlags.SEND_LFA)
identity_mask = _EXCLUDED | int(
HyundaiFlags.EV | HyundaiFlags.HYBRID | HyundaiFlags.ALT_LIMITS | HyundaiFlags.ALT_LIMITS_2 | HyundaiFlags.CAMERA_SCC | HyundaiFlags.LEGACY
)
allowed = declared | _DYNAMIC_FLAGS
if (
int(cp.flags) & identity_mask != declared & identity_mask
int(cp.flags) & _IDENTITY_MASK != declared & _IDENTITY_MASK
or int(cp.flags) & ~allowed
or is_blended(cp)
or cp.passive
@@ -161,6 +161,8 @@ def get_radar_can_parser(CP):
# MRR35 publishes many unused/unknown fields in each object packet. Decode
# the four consumed track fields, retaining parser integrity fields automatically.
selected = ({name: ('STATE', 'LONG_DIST', 'LAT_DIST', 'REL_SPEED') for name, _ in messages} if mrr35 else None)
if radar_dbc(CP) == "hyundai_kia_mando_front_radar_generated":
selected = {name: ('STATE', 'AZIMUTH', 'LONG_DIST', 'REL_SPEED') for name, _ in messages}
return CANParser(radar_dbc(CP), messages, radar_bus(CP) if mrr35 or mrr30 or gv70 else 1, signals=selected)
@@ -329,7 +329,7 @@ class TestBlendedLifecycle(unittest.TestCase):
car._deferred_radar_can = None
vars(car)['RI'] = SimpleNamespace(update=lambda can_list: None)
vars(car)['state_publish'] = lambda *args: calls.append('state')
car.CP = SimpleNamespace(passive=False)
car.CP = SimpleNamespace(brand='hyundai', passive=False)
car.ci_initialized = False
class SM(dict):
@@ -216,7 +216,7 @@ def test_actual_classic_family_cancel_and_manual_withdrawal(identity, monkeypatc
config = card.CP.safetyConfigs[0]
model, word = int(config.safetyModel.raw), int(config.safetyParam)
configured = [False]
dispatch_tree = ast.parse(textwrap.dedent(inspect.getsource(card_module.Car.step))).body[0].body
dispatch_tree = ast.parse(textwrap.dedent(inspect.getsource(card_module.Car._step))).body[0].body
assignments = [node for node in dispatch_tree if isinstance(node, ast.Assign) and
any(isinstance(t, ast.Name) and t.id == 'initialized' for t in node.targets)]
decisions = [node for node in dispatch_tree if isinstance(node, ast.If) and ast.unparse(node.test) == 'not self.CP.passive and initialized']
@@ -243,7 +243,7 @@ def test_classic_family_actual_startup_cancel_and_manual_withdrawal(identity, mo
config = card.CP.safetyConfigs[0]
model, word = int(config.safetyModel.raw), int(config.safetyParam)
configured = [False]
dispatch_tree = ast.parse(textwrap.dedent(inspect.getsource(card_module.Car.step))).body[0].body
dispatch_tree = ast.parse(textwrap.dedent(inspect.getsource(card_module.Car._step))).body[0].body
assignments = [
node for node in dispatch_tree if isinstance(node, ast.Assign) and any(isinstance(t, ast.Name) and t.id == 'initialized' for t in node.targets)
]
@@ -13,6 +13,7 @@ from opendbc.car.hyundai.radar_interface import RadarInterface
from openpilot.common.params import Params
from openpilot.common.prefix import OpenpilotPrefix
from openpilot.selfdrive.car.card import Car
from openpilot.starpilot.aol.card_native import aol_configuration
from openpilot.starpilot.aol.intent import AOL_TOGGLE
from openpilot.starpilot.car.hyundai.aol import policy_for, native_accepts_cp
@@ -102,7 +103,8 @@ class TestEV9CombinedPending(EV9StartupFixture):
self.assertEqual(self.sent, [])
with structs.CarParams.from_bytes(saved.get('CarParams')) as published:
self.assertEqual(published.to_dict(), card.CP.to_dict())
self.assertEqual(card.aol_permission_owners()[0], aol)
_, owners, _ = aol_configuration(card)
self.assertEqual(owners[0], aol)
owner.close()
def test_marker_finalization_cannot_relabel_other_cp_fields_or_follow_publication(self):
@@ -116,16 +116,16 @@ class TestNonSccStartup(unittest.TestCase):
message = parser.message_states[parser.dbc.name_to_msg[name].address]
self.assertFalse(message.ignore_alive, (identity, name))
self.assertFalse(message.timestamps, (identity, name))
self.assertFalse(message.valid(1_000_000_000, False), (identity, name, 'never received'))
self.assertFalse(message.valid(1_000_000_000), (identity, name, 'never received'))
packer = CANPacker(DBC[identity][Bus.pt])
packet = packer.make_can_msg(name, 0, {})
if name == 'EMS16':
packet = checksum(packet)
ci.update([(1_000_000_000, [packet])])
self.assertTrue(message.timestamps, (identity, name, 'packed arrival'))
self.assertTrue(message.valid(1_000_000_000, False), (identity, name, 'arrived'))
self.assertTrue(message.valid(1_000_000_000), (identity, name, 'arrived'))
expired = 1_000_000_000 + int(message.timeout_threshold) + 1
self.assertFalse(message.valid(expired, False), (identity, name, 'expired'))
self.assertFalse(message.valid(expired), (identity, name, 'expired'))
self.assertFalse(ci.update([(expired, [])]).canValid, (identity, name, 'incomplete stream'))
def test_required_sources_loss_wrong_bus_and_recovery(self):
@@ -227,7 +227,7 @@ def test_prepublication_classic_owner_preserves_real_boot_and_independent_axes(i
config = card.CP.safetyConfigs[0]
model, word = int(config.safetyModel.raw), int(config.safetyParam)
configured = [False]
dispatch_tree = ast.parse(textwrap.dedent(inspect.getsource(card_module.Car.step))).body[0].body
dispatch_tree = ast.parse(textwrap.dedent(inspect.getsource(card_module.Car._step))).body[0].body
assignments = [
node for node in dispatch_tree if isinstance(node, ast.Assign) and any(isinstance(t, ast.Name) and t.id == 'initialized' for t in node.targets)
]
@@ -4,7 +4,7 @@ from opendbc.car.hyundai import radar_interface
from opendbc.car.hyundai.tests.test_dom_radar_complete_paths import CASES, bank, factory
@pytest.mark.parametrize('name,dbc,bus,start,count,length,lka', [case for case in CASES if 'mrr35' in case[1]])
@pytest.mark.parametrize('name,dbc,bus,start,count,length,lka', [case for case in CASES if any(layout in case[1] for layout in ('mrr35', 'mando_front'))])
def test_projected_radar_matches_complete_decoder(monkeypatch, name, dbc, bus, start, count, length, lka):
cp = factory(name, bus, start, count, length, lka)
projected = radar_interface.RadarInterface(cp)
@@ -532,7 +532,7 @@ class CarController(CarControllerBase):
can_sends.append(make_tester_present_msg(0x750, 0, 0xF))
if self.bsm_poller is not None:
can_sends.extend(self.bsm_poller.update(CS.out, self.frame, factory_bsm=CS.factory_bsm))
can_sends.extend(self.bsm_poller.update(CS.out, self.frame))
door_command = self.door_locks.update(CS.out)
if door_command is not None:
+5 -7
View File
@@ -40,7 +40,6 @@ def has_optional_prius_gap_button(CP):
class CarState(CarStateBase):
def __init__(self, CP):
super().__init__(CP)
self.factory_bsm = False
can_define = CANDefine(DBC[CP.carFingerprint][Bus.pt])
original_prius = prius_sdsu.configured(CP) or prius_advert_filter.configured(CP)
self.eps_torque_scale = ((CP.safetyConfigs[0].safetyParam & 0xFF) / 100. if prius_advert_filter.configured(CP) else
@@ -236,13 +235,12 @@ class CarState(CarStateBase):
ret.genericToggle = bool(cp.vl["LIGHT_STALK"]["AUTO_HIGH_BEAM"])
ret.espDisabled = cp.vl["ESP_CONTROL"]["TC_DISABLED"] != 0
self.factory_bsm = isinstance(cp, enhanced_bsm.BsmCANParser) and cp.factory_bsm
if self.CP.flags & ToyotaFlags.HAS_BSM or self.factory_bsm:
if self.CP.flags & ToyotaFlags.HAS_BSM or isinstance(cp, enhanced_bsm.BsmCANParser) and cp.factory_bsm:
ret.leftBlindspot = (cp.vl["BSM"]["L_ADJACENT"] == 1) or (cp.vl["BSM"]["L_APPROACHING"] == 1)
ret.rightBlindspot = (cp.vl["BSM"]["R_ADJACENT"] == 1) or (cp.vl["BSM"]["R_APPROACHING"] == 1)
elif isinstance(cp, enhanced_bsm.BsmCANParser) and ret.vEgo > 6.0:
ret.leftBlindspot = cp.occupied(enhanced_bsm.SIDES[0])
ret.rightBlindspot = cp.occupied(enhanced_bsm.SIDES[1])
if isinstance(cp, enhanced_bsm.BsmCANParser) and ret.vEgo > 6.0:
ret.leftBlindspot |= cp.occupied(enhanced_bsm.SIDES[0])
ret.rightBlindspot |= cp.occupied(enhanced_bsm.SIDES[1])
if self.CP.carFingerprint != CAR.TOYOTA_PRIUS_V:
self.lkas_hud = copy.copy(cp_cam.vl["LKAS_HUD"])
@@ -417,7 +415,7 @@ class CarState(CarStateBase):
Rav4hCANParser if rav4h_filter_configured(CP) else CANParser)
if enhanced_bsm.configured(CP):
pt_parser = enhanced_bsm.BsmCANParser
pt_messages.append(("BSM", math.nan))
pt_messages.append(("BSM", 0 if CP.flags & ToyotaFlags.HAS_BSM else math.nan))
parsers = {
Bus.pt: pt_parser(DBC[CP.carFingerprint][Bus.pt], pt_messages, 0, **({"stock_word": CP.safetyConfigs[0].safetyParam} if stock else
{"alternate_main": alternate_sdsu_main} if legacy_advert else {})),
@@ -16,7 +16,7 @@ REPLY_MAX_AGE_NS = 500_000_000
def supported(cp):
required = ToyotaFlags.TSS2 | ToyotaFlags.NO_DSU | ToyotaFlags.RAISED_ACCEL_LIMIT | ToyotaFlags.HYBRID
allowed = required | ToyotaFlags.AUTO_BRAKE_HOLD
allowed = required | ToyotaFlags.AUTO_BRAKE_HOLD | ToyotaFlags.HAS_BSM
return (cp.carFingerprint == CAR.TOYOTA_PRIUS_TSS2 and cp.brand == 'toyota' and
cp.pcmCruise and cp.openpilotLongitudinalControl and not (cp.passive or cp.dashcamOnly or cp.notCar or cp.secOcRequired) and
cp.steerControlType == structs.CarParams.SteerControlType.torque and cp.flags & required == required and
@@ -55,8 +55,7 @@ class BsmCANParser(CANParser):
for address, data, bus in frames:
if bus == self.bus and address == 0x3F6 and len(data) == 8:
self.factory_bsm = True
self.blindspots.clear()
if (not self.factory_bsm and bus == self.bus and address == 0x758 and len(data) == 8 and
if (bus == self.bus and address == 0x758 and len(data) == 8 and
data[0] in SIDES and data[1:4] == b'\x06\x61\x69'):
self.blindspots[data[0]] = (timestamp, max(data[5:7]) > 35)
return super().update(strings, sendcan)
@@ -71,8 +70,8 @@ class BsmPoller:
self.active = False
self.started = 0
def update(self, state, frame, *, factory_bsm=False):
ready = (not factory_bsm and frame > 200 and state.canValid and not state.canTimeout and
def update(self, state, frame):
ready = (frame > 200 and state.canValid and not state.canTimeout and
state.gearShifter in (structs.CarState.GearShifter.drive, structs.CarState.GearShifter.sport) and
state.vEgo > (6.0 if self.active else 7.0))
if ready != self.active:
@@ -21,11 +21,12 @@ def params(car=CAR.TOYOTA_PRIUS_TSS2, *, factory=False, requested=True):
@pytest.mark.parametrize('car,factory,requested,configured', (
(CAR.TOYOTA_PRIUS_TSS2, False, True, True),
(CAR.TOYOTA_PRIUS_TSS2, True, True, False),
(CAR.TOYOTA_PRIUS_TSS2, True, True, True),
(CAR.TOYOTA_PRIUS_TSS2, True, False, False),
(CAR.TOYOTA_PRIUS_TSS2, False, False, False),
(CAR.TOYOTA_COROLLA_TSS2, False, True, False),
))
def test_fallback_admission(car, factory, requested, configured):
def test_polling_admission(car, factory, requested, configured):
cp = params(car, factory=factory, requested=requested)
ci = CarInterface(cp)
assert isinstance(ci.can_parsers[Bus.pt], enhanced_bsm.BsmCANParser) == configured
@@ -53,15 +54,20 @@ def test_fresh_bsm_replies_are_independent_and_use_recorded_idle_format():
assert not parser.occupied(0x42)
def test_late_factory_broadcast_takes_priority():
cp = params()
@pytest.mark.parametrize('factory_at_startup', (False, True))
def test_factory_and_diagnostic_detections_are_combined(factory_at_startup):
cp = params(factory=factory_at_startup)
ci = CarInterface(cp)
packer = CANPacker(DBC[CAR.TOYOTA_PRIUS_TSS2][Bus.pt])
factory = packer.make_can_msg('BSM', 0, {'L_APPROACHING': 1})
right = (0x758, bytes.fromhex('4206616900390089'), 0)
state = ci.update([(1_000_000_000, [factory, right])])
wheel = packer.make_can_msg('WHEEL_SPEEDS', 0, {f'WHEEL_SPEED_{side}': 36 for side in ('FL', 'FR', 'RL', 'RR')})
left_factory = packer.make_can_msg('BSM', 0, {'L_APPROACHING': 1})
left_idle = (0x758, bytes.fromhex('4106616900000089'), 0)
right_active = (0x758, bytes.fromhex('4206616900390089'), 0)
ci.update([(990_000_000, [])]) # The wheel message is registered on first access.
state = ci.update([(1_000_000_000, [wheel, left_factory, left_idle, right_active])])
assert state.leftBlindspot and state.rightBlindspot
state = ci.update([(1_500_000_001, [wheel, left_factory])])
assert state.leftBlindspot and not state.rightBlindspot
assert ci.CS.factory_bsm
def test_poll_cadence_and_cleanup():
@@ -132,8 +138,12 @@ def test_native_diagnostics_are_scoped_and_require_a_paced_moving_session(tmp_pa
assert tx(end)
assert not tx(end)
wheel(8.)
rx('BSM', {'L_ADJACENT': 1})
assert tx(enable)
rx('BSM', {})
safety.set_timer(1_141_000)
rx('BSM', {'L_ADJACENT': 1})
assert tx(poll)
wheel(0.)
assert not tx(poll)
assert tx(end)
assert not tx(enable)
@@ -34,7 +34,7 @@ def test_prius_gap_button_requires_the_source_only_during_a_press(stock_aol):
gap_message = parsers[Bus.pt].message_states[0x343]
assert not gap_message.ignore_alive
assert edges(12_000_000_000) == []
assert not gap_message.valid(12_000_000_000, False)
assert not gap_message.valid(12_000_000_000)
assert edges(12_030_000_000, 0) == [False]
assert gap_message.ignore_alive
assert gap_message.valid(23_000_000_000, False)
assert gap_message.valid(23_000_000_000)
+1 -6
View File
@@ -69,7 +69,6 @@ static bool toyota_stock_longitudinal = false;
static bool toyota_lta = false;
static bool toyota_radar_diagnostics_allowed = false;
static bool toyota_enhanced_bsm = false;
static bool toyota_factory_bsm_seen = false;
static uint32_t toyota_bsm_tx_ts[2] = {0U, 0U};
static bool toyota_bsm_session[2] = {false, false};
static int toyota_dbc_eps_torque_factor = 100; // conversion factor for STEER_TORQUE_EPS in %: see dbc file
@@ -224,9 +223,6 @@ static void toyota_hold_observe(const CANPacket_t *msg) {
}
static void toyota_optional_rx_hook(const CANPacket_t *msg) {
if (toyota_enhanced_bsm && msg_matches(msg, 0x3F6U, 0U) && (GET_LEN(msg) == 8U)) {
toyota_factory_bsm_seen = true;
}
// Only bus0 pedal RX belongs to the required catalog. A CRC-valid camera
// copy must neither invalidate its parent nor refresh the primary lease.
const bool camera_copy = toyota_pedal && msg_matches(msg, 0x201U, 2U) && (GET_LEN(msg) == 6U) &&
@@ -627,7 +623,7 @@ static bool toyota_tx_hook(const CANPacket_t *msg) {
const bool paced = safety_get_ts_elapsed(now, toyota_bsm_tx_ts[side]) >= 40000U;
const bool enable = start && !session && (vehicle_speed.values[0] > (7 * VEHICLE_SPEED_FACTOR));
const bool poll_allowed = poll && session && paced && (vehicle_speed.values[0] > (6 * VEHICLE_SPEED_FACTOR));
tx &= (stop_polling && session) || (!toyota_factory_bsm_seen && ready && (enable || poll_allowed));
tx &= (stop_polling && session) || (ready && (enable || poll_allowed));
if (tx) {
toyota_bsm_session[side] = !stop_polling;
toyota_bsm_tx_ts[side] = now;
@@ -646,7 +642,6 @@ static bool toyota_tx_hook(const CANPacket_t *msg) {
}
static safety_config toyota_init(uint16_t param) {
toyota_factory_bsm_seen = false;
toyota_enhanced_bsm = (param == 73U) && ((alternative_experience & ALT_EXP_TOYOTA_ENHANCED_BSM) != 0);
for (unsigned int i = 0U; i < 2U; i++) {
toyota_bsm_tx_ts[i] = 0U;
@@ -603,7 +603,12 @@ class TestToyotaHighlanderAol(unittest.TestCase):
self.assertTrue(send(right, start))
self.rx(0x3F6, bytes(8))
self.safety.set_timer(1_080_000)
self.assertTrue(send(left, poll))
self.assertTrue(send(right, poll))
stopped = dict.fromkeys(speed, 0)
self.assertTrue(self.safety.safety_rx_hook(self.packer.make_can_msg_safety("WHEEL_SPEEDS", 0, stopped)))
self.assertFalse(send(left, poll))
self.assertFalse(send(right, poll))
self.assertTrue(send(left, stop))
self.assertTrue(send(right, stop))
self.assertFalse(send(left, start))
Binary file not shown.
Binary file not shown.
+34 -47
View File
@@ -39,16 +39,10 @@ from openpilot.starpilot.aol.intent import AolProcessFaultContext, claim_remappe
from openpilot.starpilot.aol.transport_pause import TransportPauseFeedback, cp_identity
from opendbc.car.honda.stock_aol import qualified as qualified_honda_stock_aol, native_observation as honda_native_observation
from opendbc.car.volkswagen.stock_aol import safety_config as volkswagen_aol_safety_config
from openpilot.starpilot.car.volkswagen.aol import qualified as qualified_volkswagen_aol
from openpilot.starpilot.car.rivian.aol import retained_brake_lateral_intent as rivian_brake_intent_retained
from opendbc.car.rivian.stock_aol import qualified as qualified_rivian_aol
from opendbc.car.mazda.stock_aol import qualified as qualified_mazda_aol
from opendbc.car.tesla.preap.aol import qualified as qualified_tesla_preap
from opendbc.car.hyundai.canfd_angle_aol import qualified as qualified_angle_aol
from opendbc.car.hyundai.canfd_owner import config_index as hyundai_canfd_config_index
from opendbc.car.hyundai.captured_adrv_startup import CapturedADRVStartup
from openpilot.starpilot.car.nissan.aol import qualified as qualified_nissan_aol
from openpilot.starpilot.car.volvo.aol import qualified as qualified_volvo_aol
from openpilot.starpilot.car.hyundai.aol import aol_safety_config as hyundai_aol_safety_config, pending_stock_angle_arm
from openpilot.starpilot.car.hyundai.aol import retained_shared_long_cancel_intent as hkg_cancel_intent_retained
from openpilot.starpilot.car.ford.aol import (brake_pause_active as ford_brake_pause_active,
@@ -56,7 +50,7 @@ from openpilot.starpilot.car.ford.aol import (brake_pause_active as ford_brake_p
qualification_cycle as ford_qualification_cycle,
qualified as qualified_ford_aol)
from openpilot.starpilot.car.subaru import aol as subaru_aol
from openpilot.starpilot.aol.card_native import native_handlers
from openpilot.starpilot.aol.card_native import aol_configuration
from openpilot.starpilot.aol.runtime import AXIS_MAX_AGE_NS, current_axis, current_native
from openpilot.starpilot.aol.vehicle import create_intent as create_aol_intent, native_latch_rejected, policy_for as aol_policy_for
from openpilot.starpilot.aol.wire import IntentState, encode_intent
@@ -388,6 +382,8 @@ class Car:
self._prepare_feedback_capture()
except Exception:
pass # Optional learning setup cannot stop native startup.
if self.aol_card_intent is not None:
aol_configuration(self)
self.aol_transport_feedback = TransportPauseFeedback(self.CP) if self.aol_replay else None
if isinstance(self.CI, GMInterface) and self.CI.CC is not None and self.CI.CC.volt_sng_plan_input is not None:
self.CI.CC.volt_sng_plan_input.boottime = self.volt_startup_keepalive()
@@ -488,7 +484,11 @@ class Car:
can_strs = messaging.drain_sock_raw(self.can_sock, wait_for_one=True)
can_received_ns = time.monotonic_ns()
can_list = can_capnp_to_list(can_strs)
if (self.CP.carFingerprint == HYUNDAI_CAR.HYUNDAI_SONATA_HYBRID and self.CP.pcmCruise and
not self.CP.openpilotLongitudinalControl):
can_list = can_capnp_to_list(can_strs, include_tx_receipts=False)
else:
can_list = can_capnp_to_list(can_strs)
observe_controller_can(self.CI, can_list)
CS = self.CI.update(can_list)
@@ -644,11 +644,9 @@ class Car:
not any(e.immediateDisable or e.softDisable or e.userDisable for e in self.sm['onroadEvents']))
fault_active = transport_reset or self.aol_disarming_fault(CS, event_ns, now_ns,
transport_observed_healthy=reuse_transport or angle_arm_pending or ford_initial_wait or volkswagen_initial_wait)
angle_aol, ford_aol, honda_aol, mazda_aol, preap_aol, volkswagen_aol = self.aol_permission_owners()
nissan_aol = qualified_nissan_aol(self.CP, marked_only=True)
rivian_aol = qualified_rivian_aol(self.CP, marked_only=True)
volvo_aol = qualified_volvo_aol(self.CP, marked_only=True)
permission_owner = angle_aol or ford_aol or honda_aol or mazda_aol or preap_aol or nissan_aol or volkswagen_aol or rivian_aol or volvo_aol
_, owners, handlers = aol_configuration(self)
angle_aol, ford_aol, honda_aol, mazda_aol, preap_aol, volkswagen_aol, rivian_aol = owners
permission_owner = handlers is not None
angle_panda_ready = not permission_owner or self.startup_panda_configured()
native = (
current_native(self.sm, self.CP, now_ns=now_ns, axis_session_id=self.aol_axis_session() if permission_owner else None)
@@ -658,11 +656,8 @@ class Car:
honda_eps_pending = bool(honda_aol and not transport_reset and native is not None and
getattr(self.aol_transport_feedback, 'honda_eps_retained_native_ns', 0) == int(native.observedMonoTime))
native_reset = False
if permission_owner:
observe, restrict = native_handlers(
self, volvo_aol=volvo_aol, rivian_aol=rivian_aol, volkswagen_aol=volkswagen_aol, nissan_aol=nissan_aol,
preap_aol=preap_aol, mazda_aol=mazda_aol, honda_aol=honda_aol, ford_aol=ford_aol,
)
if handlers is not None:
observe, restrict = handlers
preap_observation = {}
if preap_aol:
cancel_stamp = int(self.CI.CS.preap.cancel_echo_stamp_ns)
@@ -938,29 +933,31 @@ class Car:
getattr(self, '_aol_can_observation', None), now_ns)
def aol_disarming_fault(self, CS, event_ns: int, now_ns: int, *, transport_observed_healthy=False) -> bool:
if not aol_policy_for(self.CP).intent_supported:
if not aol_configuration(self)[0].intent_supported:
return True
from openpilot.starpilot.aol.vehicle import intent_disarming_fault
feedback = getattr(self, 'aol_transport_feedback', None)
if feedback is None:
feedback = self.aol_transport_feedback = TransportPauseFeedback(self.CP)
hkg_cancel_retained = hkg_cancel_intent_retained(self.CP, CS, self.sm, feedback,
self.aol_card_intent, cancel_source_ns=self.aol_cancel_source(CS, now_ns), now_ns=now_ns,
producer=getattr(self, 'slc_producer_session', ''))
if not transport_observed_healthy and not hkg_cancel_retained and feedback.observe(self.sm, self.CP, CS, now_ns,
latched=getattr(getattr(self, 'aol_card_intent', None), 'allowed_latch', True),
cancel_source_ns=self.aol_cancel_source(CS, now_ns), brake_source_ns=self.aol_honda_brake_source(CS, now_ns),
gm_withdrawal_source_ns=self.aol_gm_withdrawal_source(CS, now_ns),
intent_producer_session=getattr(self, 'slc_producer_session', ''),
main_arm_ns=(getattr(self.aol_card_intent, 'main_arm_ns', 0) or
getattr(self.aol_card_intent, 'physical_arm_ns', 0)),
startup_calibration_pending=getattr(self.aol_card_intent, 'startup_calibration_pending', False),
intent_paused=(getattr(self.aol_card_intent, 'pause_lateral', False) or
ford_brake_pause_active(self.CP, CS, self.aol_settings) or
self.CP.brand == 'volkswagen' and CS.canValid and not CS.canTimeout and
not CS.steerFaultPermanent and (CS.gearShifter == car.CarState.GearShifter.reverse or
getattr(self.aol_card_intent, 'reverse_pause', False)))):
return True
if not transport_observed_healthy:
cancel_source_ns = self.aol_cancel_source(CS, now_ns)
hkg_cancel_retained = hkg_cancel_intent_retained(self.CP, CS, self.sm, feedback,
self.aol_card_intent, cancel_source_ns=cancel_source_ns, now_ns=now_ns,
producer=getattr(self, 'slc_producer_session', ''))
if not hkg_cancel_retained and feedback.observe(self.sm, self.CP, CS, now_ns,
latched=getattr(getattr(self, 'aol_card_intent', None), 'allowed_latch', True),
cancel_source_ns=cancel_source_ns, brake_source_ns=self.aol_honda_brake_source(CS, now_ns),
gm_withdrawal_source_ns=self.aol_gm_withdrawal_source(CS, now_ns),
intent_producer_session=getattr(self, 'slc_producer_session', ''),
main_arm_ns=(getattr(self.aol_card_intent, 'main_arm_ns', 0) or
getattr(self.aol_card_intent, 'physical_arm_ns', 0)),
startup_calibration_pending=getattr(self.aol_card_intent, 'startup_calibration_pending', False),
intent_paused=(getattr(self.aol_card_intent, 'pause_lateral', False) or
ford_brake_pause_active(self.CP, CS, self.aol_settings) or
self.CP.brand == 'volkswagen' and CS.canValid and not CS.canTimeout and
not CS.steerFaultPermanent and (CS.gearShifter == car.CarState.GearShifter.reverse or
getattr(self.aol_card_intent, 'reverse_pause', False)))):
return True
events = self.sm['onroadEvents']
if feedback.retention_qualified or feedback.retention_pending:
from openpilot.starpilot.aol.transport_pause import AVAILABILITY_EVENTS
@@ -976,19 +973,9 @@ class Car:
startup_calibration_pending=bool(intent is not None and getattr(intent, 'startup_calibration_pending', False) and
intent.settings.enabled and intent.main_action != 9),
temporary_ui_process_failure=fault_context is not None and fault_context.temporary_ui_failure(event_ns, now_ns),
temporary_selfdrive_lagging=(qualified_gm(self.CP) or aol_policy_for(self.CP).intent_supported),
temporary_selfdrive_lagging=True,
temporary_source_pause=(feedback.qualified or feedback.awaiting))
def aol_permission_owners(self) -> tuple[bool, bool, bool, bool, bool, bool]:
# CP is fixed once the drive starts; these checks ran five times per 100 Hz frame.
cached = getattr(self, '_aol_owner_cache', None)
if cached is None or cached[0] is not self.CP:
owners = (bool(qualified_angle_aol(self.CP, marked_only=True)), bool(qualified_ford_aol(self.CP, marked_only=True)),
bool(qualified_honda_stock_aol(self.CP, marked_only=True)), bool(qualified_mazda_aol(self.CP, marked_only=True)),
bool(qualified_tesla_preap(self.CP, marked_only=True)), bool(qualified_volkswagen_aol(self.CP, marked_only=True)))
cached = self._aol_owner_cache = (self.CP, owners)
return cached[1]
def aol_honda_native_observation(self, native, *, latched, panda_ready, restricted, now_ns, pending_since_ns):
acknowledged = getattr(self, '_honda_aol_acknowledgment', None)
key = None
+2 -2
View File
@@ -22,7 +22,7 @@ from opendbc.car.toyota.values import CAR as TOYOTA_CAR, ToyotaFlags
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
from openpilot.selfdrive.controls.lib.highway_correction_gain import HighwayCorrectionGain, read_gain
from openpilot.selfdrive.controls.lib.latcontrol import LatControl
from openpilot.selfdrive.controls.lib.latcontrol_torque import LatControlTorque
from openpilot.selfdrive.controls.lib.lateral_controller_factory import create_lateral_controller
@@ -661,7 +661,7 @@ class Controls:
self.highway_gain = read_gain(self.params)
predicted = None
if self.sm.all_checks(['modelV2']):
predicted = predicted_lateral_accels(model_v2.position.t, model_v2.velocity.x, model_v2.orientationRate.z)
predicted = self.highway_correction_gain.predict(model_v2)
# before lane centering so its guard measures only its own correction against the smoothed base
new_desired_curvature = self.highway_correction_gain.update(
new_desired_curvature,
@@ -75,8 +75,17 @@ class HighwayCorrectionGain:
def __init__(self):
self.alpha = DT_CTRL / (BASELINE_TAU + DT_CTRL)
self.alpha_curve = DT_CTRL / (CURVE_LEVEL_TAU + DT_CTRL)
self._prediction_model = None
self._prediction = None
self.reset()
def predict(self, model) -> tuple[float, ...] | None:
# SubMaster retains the same immutable reader until another packet arrives.
if model is not self._prediction_model:
self._prediction = predicted_lateral_accels(model.position.t, model.velocity.x, model.orientationRate.z)
self._prediction_model = model
return self._prediction
def reset(self, curvature: float = 0.0) -> None:
self.baseline = curvature
self.curve_level = curvature
@@ -2,6 +2,7 @@ import math
import numpy as np
from openpilot.cereal import messaging
from openpilot.common.realtime import DT_CTRL
from openpilot.selfdrive.controls.lib.highway_correction_gain import KEY, HighwayCorrectionGain, predicted_lateral_accels, read_gain
@@ -168,6 +169,26 @@ def test_gain_is_clamped():
np.testing.assert_allclose(low, floor, rtol=0, atol=1e-15)
def test_prediction_reuses_only_the_same_model_packet():
hcg = HighwayCorrectionGain()
def packet(yaw_rate):
msg = messaging.new_message('modelV2')
msg.modelV2.position.t = [0., 2.]
msg.modelV2.velocity.x = [30., 30.]
msg.modelV2.orientationRate.z = [yaw_rate, yaw_rate]
return msg.as_reader().modelV2
first = packet(0.03125)
second = packet(0.0625)
predicted = hcg.predict(first)
assert predicted == (0.9375, 0.9375)
hcg.reset()
assert hcg.predict(first) is predicted
assert hcg.predict(second) == (1.875, 1.875)
assert hcg.predict(messaging.new_message('modelV2').as_reader().modelV2) is None
def test_predicted_lateral_accels():
t = 10.0 * (np.arange(33) / 32) ** 2
assert predicted_lateral_accels(t, np.full(33, 30.0), np.full(33, 0.02)) == (0.6, 0.6)
Binary file not shown.
Binary file not shown.
Binary file not shown.
+11 -2
View File
@@ -32,6 +32,7 @@ def can_list_to_can_capnp(can_msgs, msgtype='can', valid=True, *, source_observe
Args:
can_msgs: List of tuples [(address, data_bytes, src), ...]
msgtype: 'can' or 'sendcan'
include_tx_receipts: retain Panda TX receipts (sources 128 and above)
valid: Whether the event is valid
Returns:
@@ -64,12 +65,13 @@ def can_list_to_can_capnp(can_msgs, msgtype='can', valid=True, *, source_observe
return dat.to_bytes()
def can_capnp_to_list(strings, msgtype='can'):
def can_capnp_to_list(strings, msgtype='can', *, include_tx_receipts=True):
"""Convert Cap'n Proto serialized bytes to list of CAN messages.
Args:
strings: Tuple/list of serialized Cap'n Proto bytes
msgtype: 'can' or 'sendcan'
include_tx_receipts: retain Panda TX receipts (sources 128 and above)
Returns:
List of tuples [(nanos, [(address, data, src), ...]), ...]
@@ -87,7 +89,14 @@ def can_capnp_to_list(strings, msgtype='can'):
if _cached_reader_fields is not None:
addr_f, dat_f, src_f = _cached_reader_fields
frame_list = [(f._get_by_field(addr_f), f._get_by_field(dat_f), f._get_by_field(src_f)) for f in frames]
if include_tx_receipts:
frame_list = [(f._get_by_field(addr_f), f._get_by_field(dat_f), f._get_by_field(src_f)) for f in frames]
else:
frame_list = []
for f in frames:
src = f._get_by_field(src_f)
if src < 128:
frame_list.append((f._get_by_field(addr_f), f._get_by_field(dat_f), src))
else:
frame_list = []
@@ -0,0 +1,13 @@
from openpilot.cereal import messaging
from openpilot.selfdrive.pandad import can_capnp_to_list, can_list_to_can_capnp
def test_optional_receipt_filter_preserves_physical_frames_and_batch_stamps():
frames = [(0x340, b'physical', 0), (0x340, b'returned', 128),
(0x421, b'physical', 2), (0x421, b'rejected', 194)]
receipts = [frames[1], frames[3]]
packets = [can_list_to_can_capnp(batch) for batch in (frames, receipts, [])]
stamps = [int(messaging.log_from_bytes(packet).logMonoTime) for packet in packets]
assert can_capnp_to_list(packets) == list(zip(stamps, (frames, receipts, []), strict=True))
assert can_capnp_to_list(packets, include_tx_receipts=False) == list(zip(stamps, ([frames[0], frames[2]], [], []), strict=True))
+32
View File
@@ -17,6 +17,38 @@ from openpilot.starpilot.car.volkswagen.aol import temporary_restriction as volk
from openpilot.starpilot.car.volvo.aol import (native_observation as volvo_native_observation,
temporary_restriction as volvo_temporary_restriction)
from openpilot.starpilot.car.volkswagen.aol import qualified as qualified_volkswagen_aol
from opendbc.car.rivian.stock_aol import qualified as qualified_rivian_aol
from opendbc.car.mazda.stock_aol import qualified as qualified_mazda_aol
from opendbc.car.hyundai.canfd_angle_aol import qualified as qualified_angle_aol
from openpilot.starpilot.car.nissan.aol import qualified as qualified_nissan_aol
from openpilot.starpilot.car.volvo.aol import qualified as qualified_volvo_aol
from opendbc.car.honda.stock_aol import qualified as qualified_honda_stock_aol
from opendbc.car.tesla.preap.aol import qualified as qualified_tesla_preap
from openpilot.starpilot.car.ford.aol import qualified as qualified_ford_aol
from openpilot.starpilot.aol.vehicle import policy_for
def aol_configuration(card):
cp = card.CP
cached = getattr(card, '_aol_configuration', None)
if cached is None or cached[0] is not cp:
angle = qualified_angle_aol(cp, marked_only=True)
ford = qualified_ford_aol(cp, marked_only=True)
honda = qualified_honda_stock_aol(cp, marked_only=True)
mazda = qualified_mazda_aol(cp, marked_only=True)
preap = qualified_tesla_preap(cp, marked_only=True)
volkswagen = qualified_volkswagen_aol(cp, marked_only=True)
nissan = qualified_nissan_aol(cp, marked_only=True)
rivian = qualified_rivian_aol(cp, marked_only=True)
volvo = qualified_volvo_aol(cp, marked_only=True)
owners = (angle, ford, honda, mazda, preap, volkswagen, rivian)
handlers = native_handlers(card, volvo_aol=volvo, rivian_aol=rivian, volkswagen_aol=volkswagen,
nissan_aol=nissan, preap_aol=preap, mazda_aol=mazda, honda_aol=honda,
ford_aol=ford) if any(owners) or nissan or volvo else None
cached = card._aol_configuration = (cp, (policy_for(cp), owners, handlers))
return cached[1]
def native_handlers(card, *, volvo_aol: bool, rivian_aol: bool, volkswagen_aol: bool, nissan_aol: bool, preap_aol: bool,
mazda_aol: bool, honda_aol: bool, ford_aol: bool):
@@ -1,7 +1,9 @@
from types import SimpleNamespace
from itertools import product
import pytest
from opendbc.car import structs
from opendbc.car.ford import aol as ford
from opendbc.car.honda import stock_aol as honda
from opendbc.car.hyundai import canfd_angle_aol as hyundai
@@ -12,7 +14,7 @@ from opendbc.car.volkswagen import stock_aol as volkswagen_observer
from openpilot.starpilot.car.nissan import aol as nissan
from openpilot.starpilot.car.volkswagen import aol as volkswagen_restriction
from openpilot.starpilot.car.volvo import aol as volvo
from openpilot.starpilot.aol.card_native import native_handlers
from openpilot.starpilot.aol.card_native import aol_configuration, native_handlers
class _Card:
@@ -41,3 +43,18 @@ def test_native_handlers_keep_card_priority_and_lazy_honda_binding(admitted):
selected = native_handlers(card, **dict(zip(names, admitted, strict=True)))
assert selected == (observations[expected], restrictions[expected])
assert card.honda_lookups == int(expected == 6)
def test_aol_configuration_binds_only_finalized_car_params():
card = SimpleNamespace(CP=structs.CarParams(brand='ford', carFingerprint='FORD_MAVERICK_MK1', flags=2,
transmissionType='automatic', steerControlType='angle', pcmCruise=True,
safetyConfigs=[{'safetyModel': 'ford', 'safetyParam': 16384}], alternativeExperience=32))
first = aol_configuration(card)
assert first[2] == (ford.native_observation, ford.temporary_restriction)
assert aol_configuration(card) is first
card.CP = structs.CarParams(brand='mock', passive=True)
second = aol_configuration(card)
assert second is not first
assert second[2] is None
assert not second[0].intent_supported
@@ -27,6 +27,7 @@ def test_all_gm_initializing_steps_keep_servicing_handoff(cp):
state_update=Mock(return_value=(cs, None)), state_publish=Mock(),
controls_update=Mock(), _deferred_radar_can=None,
radar_update=Mock(), radar_publish=Mock())
card._step = Car._step.__get__(card)
events = [SimpleNamespace(name=1)]
card.sm = type('SM', (), {'seen': {'onroadEvents': True}, '__getitem__': lambda _, key: events if key == 'onroadEvents' else None})()
for method in ('gm_startup_keepalive', 'volt_startup_keepalive', 'volt_sdgm_startup_keepalive'):
@@ -39,11 +39,11 @@ def native_template(tmp_path_factory, request):
timers = (ROOT / 'panda/board/drivers/timers.h').read_text()
timer_check = timers[timers.index('bool timer_check('):timers.index('\nvoid interrupt_timer_init(')]
interrupts = (ROOT / 'panda/board/drivers/interrupts.h').read_text()
interrupts = interrupts[interrupts.index('static void unused_interrupt_handler'):]
interrupts = interrupts[interrupts.index('static void unused_interrupt_handler'):interrupts.index('#endif // BOARD_DRIVERS_INTERRUPTS_H')]
sys = (ROOT / 'panda/board/sys/sys.h').read_text()
faults = sys[sys.index('#define FAULT_STATUS_NONE'):sys.index('// ******************** power_saving')]
fault_impl = (ROOT / 'panda/board/sys/faults.h').read_text()
faults += fault_impl[fault_impl.index('uint8_t fault_status'):]
faults += fault_impl[fault_impl.index('uint8_t fault_status'):fault_impl.index('#endif // BOARD_SYS_FAULTS_H')]
code = r'''
#include "opendbc/safety/tests/libsafety/safety.c"
uint32_t heartbeat_counter, heartbeat_tick_counter, uptime_cnt, ignition_can_cnt, wake_on_can_cnt;
+3 -2
View File
@@ -1181,7 +1181,8 @@ class TransportPauseFeedback:
self.retention_pending = False
try:
axis = sm['aolAxisState']
if not latched or cp_identity(cp) != self.cp or self.session and str(axis.sessionId) != self.session:
same_cp = cp_identity(cp) == self.cp
if not latched or not same_cp or self.session and str(axis.sessionId) != self.session:
self.fit_eps_intent = self.fit_eps_grant = None
self.ordinary_warning_retained = False
self.ordinary_brake_proof = None
@@ -1207,7 +1208,7 @@ class TransportPauseFeedback:
axis.qualified and axis.sessionId and axis.sequence > 0 and stamp == axis.observedMonoTime and
0 < stamp <= now_ns <= axis.validUntilMonoTime and now_ns - stamp <= AXIS_MAX_AGE_NS and
axis.validUntilMonoTime - stamp <= AXIS_MAX_AGE_NS and axis.faultSessionId == axis.sessionId and
cp_identity(cp) == self.cp)
same_cp)
continuity = bool(not self.session or axis.sessionId == self.session and
(axis.sequence > self.sequence or axis.sequence == self.sequence and signature == self.signature))
pending_paddle = self.subaru_paddle_denial
@@ -148,7 +148,9 @@ class LocalModelManagerHttpTest(unittest.TestCase):
self.assertEqual(status, 200)
self.assertTrue(laboratory['runtimeSupported'])
self.assertFalse(laboratory['runtime']['active'])
self.assertEqual(laboratory['summary']['published'], 92)
published = {row['value'] for row in laboratory['models'] if row['modelLabArtifactAvailable']}
self.assertLessEqual({'gwm8223', 'sc23'}, published)
self.assertEqual(laboratory['summary']['published'], len(published))
pair = {'enabled': False, 'lateralModel': 'gwm8223', 'longitudinalModel': 'sc23'}
self.assertEqual(request('/api/models/laboratory', pair)[0], 200)
self.assertEqual(request('/api/models/laboratory', {**pair, 'enabled': True})[0], 409)
@@ -15,6 +15,19 @@ def settings(monkeypatch, topology):
monkeypatch.ford_topology = topology
monkeypatch.ford_nonzero = True
monkeypatch.ford_native_10hz = True
calls = []
observe = card_native.ford_native_observation
def traced_native(native, **kwargs):
result = observe(native, **kwargs)
calls.append({'now': kwargs['now_ns'], 'latched': kwargs['latched'], 'pending': kwargs['pending_since_ns'],
'restricted': kwargs['restricted'], 'result': result,
'native': None if native is None else [native.requestedLateral, native.lateralAllowed,
native.requestedLongitudinal, native.longitudinalAllowed]})
return result
monkeypatch.setattr(card_native, 'ford_native_observation', traced_native)
return calls
@pytest.mark.parametrize('identity,alpha,hands_free,topology', [
@@ -28,10 +41,10 @@ def settings(monkeypatch, topology):
('startup', 'paired'), ('startup', 'axis-delayed'), ('startup', 'state-delayed'),
('brake', 'health-first'), ('brake', 'wire-first'), ('startup', 'native-timeout'),
])
def test_initial_request_and_longitudinal_withdrawal(ford_joined, monkeypatch, scenario, delivery):
def test_initial_request_and_longitudinal_withdrawal(settings, ford_joined, monkeypatch, scenario, delivery):
invalid = [False]
injected = [False]
calls = []
calls = settings
delayed = {}
negative_checked = [False]
if delivery == 'native-timeout':
@@ -65,17 +78,6 @@ def test_initial_request_and_longitudinal_withdrawal(ford_joined, monkeypatch, s
return update(timestamp, adjusted)
local.setattr(sd.sm, 'update_msgs', calibration)
observe = card_native.ford_native_observation
def traced_native(native, **kwargs):
result = observe(native, **kwargs)
calls.append({'now': kwargs['now_ns'], 'latched': kwargs['latched'], 'pending': kwargs['pending_since_ns'],
'restricted': kwargs['restricted'], 'result': result,
'native': None if native is None else [native.requestedLateral, native.lateralAllowed,
native.requestedLongitudinal, native.longitudinalAllowed]})
return result
local.setattr(card_native, 'ford_native_observation', traced_native)
pending = getattr(card_module, 'ford_awaiting_initial_request', None)
if pending is not None:
def checked_pending(cp, cs, sm, native, feedback, intent, **kwargs):
@@ -108,7 +108,7 @@ class TestVehicleStateContext(unittest.TestCase):
enable_edge = next(node for node in helper.body[0].body if isinstance(node, ast.If) and initialize in ast.walk(node))
self.assertEqual(ast.unparse(enable_edge.test), "self.sm['carControl'].enabled and (not self.CC_prev.enabled)")
self.assertIn(initialize, list(ast.walk(enable_edge)))
step = inspect.getsource(card.Car.step)
step = inspect.getsource(card.Car._step)
step_tree = ast.parse(textwrap.dedent(step))
state_update = next(node for node in ast.walk(step_tree)
if isinstance(node, ast.Call) and ast.unparse(node.func) == 'self.state_update')
@@ -7,8 +7,12 @@ Reset and migration actions additionally require a parked vehicle.
from __future__ import annotations
from openpilot.starpilot.ui.feature_profile_edit import (edit_document, PRESETS as PRESETS,
PROFILE_NAMES as PROFILE_NAMES, DOCUMENT_PROFILE_NAMES as DOCUMENT_PROFILE_NAMES)
from openpilot.starpilot.ui.feature_profile_edit import (
edit_document,
PRESETS as PRESETS,
PROFILE_NAMES as PROFILE_NAMES,
DOCUMENT_PROFILE_NAMES as DOCUMENT_PROFILE_NAMES,
)
from collections.abc import Callable
from contextvars import ContextVar
@@ -37,9 +41,12 @@ from openpilot.starpilot.longitudinal.profile_document import (
personality_reference_curves, serialize_personality_profiles,
synchronise_profile_document_enabled,
)
from openpilot.starpilot.ui.feature_defaults import (AGGRESSIVE_COOLING_DESCRIPTION as AGGRESSIVE_COOLING_DESCRIPTION,
AGGRESSIVE_COOLING_KEY as AGGRESSIVE_COOLING_KEY,
BOOL_DEFAULTS as BOOL_DEFAULTS, FLOAT_SPECS as FLOAT_SPECS)
from openpilot.starpilot.ui.feature_defaults import (
AGGRESSIVE_COOLING_DESCRIPTION as AGGRESSIVE_COOLING_DESCRIPTION,
AGGRESSIVE_COOLING_KEY as AGGRESSIVE_COOLING_KEY,
BOOL_DEFAULTS as BOOL_DEFAULTS,
FLOAT_SPECS as FLOAT_SPECS,
)
from openpilot.starpilot.ui.feature_settings_state import (
FeaturePage, FeatureRow, FeatureSettingsRequest, FeatureSettingsState, SettingLevel, SLC_CONFIRM_ACTIONS, SLC_OFFSET_KEYS, TORQUE_CONFIRM_ACTIONS,
)
@@ -59,8 +66,14 @@ from openpilot.starpilot.ui.controller_feature import ControllerFeature, SETUP_A
from openpilot.starpilot.ui.slc_offset_feature import SlcOffsetOwner
from openpilot.starpilot.ui.slc_policy_feature import SLC_ADVANCE_CHOICES, policy_rows
from openpilot.starpilot.longitudinal.profile_preferences import read_document_value, read_profile_health
from openpilot.starpilot.ui.long_profile_feature import (LongProfileFeature, is_long_confirm_action, VALUE_HELP, CATEGORY_HELP,
preset_label, preset_value)
from openpilot.starpilot.ui.long_profile_feature import (
LongProfileFeature,
is_long_confirm_action,
VALUE_HELP,
CATEGORY_HELP,
preset_label,
preset_value,
)
from openpilot.starpilot.ui.traffic_feature import TrafficFeature, EDIT_KEYS as TRAFFIC_EDIT_KEYS
from openpilot.starpilot.ui.cruise_steps_feature import CRUISE_KEYS, apply_cruise, apply_reverse_cruise, cruise_rows
from openpilot.starpilot.ui.lane_change_feature import LaneChangeFeature, KEYS as LANE_CHANGE_KEYS
@@ -87,8 +100,6 @@ from openpilot.starpilot.curve_speed.preferences import (
DOCUMENT_LIMIT as CURVE_DOCUMENT_LIMIT, read_learning,
)
from openpilot.starpilot.curve_speed.actions import ACTION_KEYS as CURVE_ACTION_KEYS, apply_learning, learning_snapshot
from openpilot.starpilot.controllers.toyota_cruise import capability as toyota_cruise_capability
@@ -164,8 +175,8 @@ class FeatureSettingsOwner:
self.volt_radar = VoltRadarFeature(self, galaxy=galaxy)
self.panda_wake = PandaWakeFeature(self, galaxy=galaxy)
self.traffic_profiles = TrafficFeature(self)
self.lane_changes = LaneChangeFeature(params, authority, vehicle_fingerprint, self.vehicle_params,
configuration_longitudinal=self.configuration_longitudinal)
self.lane_changes = LaneChangeFeature(
params, authority, vehicle_fingerprint, self.vehicle_params, configuration_longitudinal=self.configuration_longitudinal)
self.conditional = ConditionalFeature(self)
self.wheel = TeslaWheelRows(self)
@@ -316,6 +316,16 @@ class MiciSidebarWidgets:
self._stop_icon(center)
elif (preview is not None and preview.curve_curvature is not None and state.alert.size != AlertSize.FULL) or curve_controlling(state):
self._curve_icon(center)
elif state.e2e_preview_slowdown is not None and state.alert.size != AlertSize.FULL:
match state.e2e_preview_slowdown:
case 'Stopping':
self._stop_icon(center)
case 'Lead vehicle':
self._lead_icon(center)
case 'Curve':
self._curve_icon(center)
case _:
self._slowdown_icon(center)
elif conditional is not None and self.fonts is not None:
family, _, color = conditional
reason = conditional_reason(state)
@@ -379,6 +389,12 @@ class MiciSidebarWidgets:
def _lead_icon(self, rect: rl.Rectangle) -> None:
draw_lead_icon(rect)
def _slowdown_icon(self, rect: rl.Rectangle) -> None:
cx, cy = rect.x + rect.width / 2, rect.y + rect.height / 2
blue = rl.Color(112, 192, 216, 255)
_line(cx - 12, cy - 5, cx, cy + 7, blue, 4)
_line(cx, cy + 7, cx + 12, cy - 5, blue, 4)
def _stop_icon(self, rect: rl.Rectangle) -> None:
draw_stop_light_icon(rect)
+1
View File
@@ -185,6 +185,7 @@ class OnroadState:
experimental_available: bool = False
experimental_enabled: bool = False
e2e_slowdown: str | None = None
e2e_preview_slowdown: str | None = None
torque_utilization: float = 0.0
personality: int = 1
lead_detected: bool = False
+21 -2
View File
@@ -801,8 +801,27 @@ class RuntimeSnapshotAdapter:
drive_mode_source, display_car, cp=cp, drive_frame=after,
event_ns=int(sm.logMonoTime['starpilotCarState']) if drive_mode_source is not None else 0, now_ns=now_ns,
native_alert=alert, traffic_active=bool(traffic is not None and traffic.state == 'active'))
e2e_mode = observed_experimental and self._conditional_choice in (None, ModeChoice.STOCK)
e2e_preview_slowdown = None
if e2e_mode and not display_long_active and ui.has_longitudinal_control and display_car_valid:
model_action = getattr(display_model, 'action', None)
if getattr(model_action, 'shouldStop', False):
e2e_preview_slowdown = "Stopping"
else:
paired_plan = (display_plan is not None and display_model is not None and
getattr(display_plan, 'modelMonoTime', None) == sm.logMonoTime['modelV2'])
plan_target = getattr(display_plan, 'aTarget', 0.0) if paired_plan else 0.0
source = getattr(display_plan, 'longitudinalPlanSource', None) if paired_plan else None
model_target = getattr(model_action, 'desiredAcceleration', 0.0)
if math.isfinite(plan_target) and plan_target < -0.15 and source in ('lead0', 'lead1') and getattr(display_plan, 'hasLead', False):
e2e_preview_slowdown = "Lead vehicle"
elif (math.isfinite(plan_target) and plan_target < -0.15 and source == 'cruise' and
curve is not None and curve.applied and curve.controlling):
e2e_preview_slowdown = "Curve"
elif math.isfinite(model_target) and model_target < -0.15:
e2e_preview_slowdown = "Slowing"
e2e_slowdown = None
if (observed_experimental and self._conditional_choice in (None, ModeChoice.STOCK) and
if (e2e_mode and
display_long_active and not longitudinal_overridden and display_plan is not None):
target = getattr(display_plan, 'aTarget', None)
if bool(getattr(display_plan, 'shouldStop', False)):
@@ -833,7 +852,7 @@ class RuntimeSnapshotAdapter:
appearance=self._appearance_value, customization=self._customization_value,
alert=alert, metric=bool(ui.is_metric), slc_offset_schedule=self._slc_offset_schedule,
experimental_available=bool(ui.has_longitudinal_control),
experimental_enabled=observed_experimental, e2e_slowdown=e2e_slowdown,
experimental_enabled=observed_experimental, e2e_slowdown=e2e_slowdown, e2e_preview_slowdown=e2e_preview_slowdown,
personality=list(Personality).index(persona),
lead_detected=bool(display_plan is not None and display_plan.hasLead),
gas_pressed_override=bool(display_events is not None and any(
@@ -16,7 +16,7 @@ def test_native_chestnut_status_accepts_typed_params(raw, expected, tmp_path):
params.get_param_path.side_effect = lambda key: str(tmp_path / key)
params.get.return_value = raw
params.get_bool.return_value = False
state = Mock(spec=UIState, params=params, started=True, chestnut_compiled=True, usb_connected=False)
state = Mock(spec=UIState, params=params, started=True, chestnut_compiled=True, usb_connected=False, _gpu_artifacts=None)
with patch('openpilot.selfdrive.ui.ui_state.get_cache', return_value=None), \
patch('openpilot.selfdrive.ui.ui_state.cable_connected', return_value=False):
UIState.update_params(state)
@@ -505,14 +505,14 @@ class NativeSettingsPageTests(unittest.TestCase):
# Run the real controller methods with only device services isolated.
source = Path('openpilot/selfdrive/ui/layouts/settings/toggles.py')
layout = next(node for node in ast.parse(source.read_text()).body if isinstance(node, ast.ClassDef) and node.name == 'TogglesLayout')
methods = {'_update_toggles', '_update_state', '_toggle_callback',
methods = {'_update_toggles', '_update_state', '_toggle_callback', '_toggle_action',
'request_toggle', 'request_personality', '_set_longitudinal_personality'}
layout.bases = []
layout.body = [node for node in layout.body if isinstance(node, ast.FunctionDef) and node.name in methods]
ui = NS(CP=None, engaged=False, parked=True, update_params=Mock(), sm=NS(updated={'selfdriveState': False}))
app = NS(push_widget=Mock())
namespace = ModuleType('toggles_controller_test')
namespace.__dict__.update(tr=lambda text: text, ui_state=ui)
namespace.__dict__.update(tr=lambda text: text, ui_state=ui, ToggleAction=ToggleAction)
exec(compile(ast.Module(body=[layout], type_ignores=[]), str(source), 'exec'), namespace.__dict__)
owner = namespace.TogglesLayout()
class SavedParams(Params):
@@ -383,6 +383,41 @@ class TestOnroadAxes(unittest.TestCase):
companion.sourcePlanMonoTime -= 1
self.assertEqual(self.state(True, True).e2e_slowdown, 'Slowing')
def test_end_to_end_sidebar_previews_slowdown_without_longitudinal_engagement(self):
self.ui.params.put('ConditionalModeConfig', json.loads(encode_preferences(SavedPreferences(mode=ModeChoice.STOCK))), block=True)
sm = self.ui.sm
sm['selfdriveState'].experimentalMode = True
sm['selfdriveState'].enabled = False
sidebar = MiciSidebarWidgets(Mock())
center = rl.Rectangle(476, 80, 60, 80)
for stop, target, source, plan_stamp, expected in (
(True, -0.12, 'cruise', NOW, '_stop_icon'),
(False, -0.25, 'e2e', NOW, '_slowdown_icon'),
(False, -0.12, 'lead0', NOW, '_lead_icon'),
(False, -0.12, 'lead0', NOW - 1, '_chill_icon'),
(False, -0.12, 'cruise', NOW, '_chill_icon'),
):
with self.subTest(stop=stop, target=target, source=source, plan_stamp=plan_stamp):
sm.put('modelV2', NS(action=NS(shouldStop=stop, desiredAcceleration=target)))
sm.put('longitudinalPlan', NS(aTarget=-0.8, hasLead=source == 'lead0', shouldStop=False,
longitudinalPlanSource=source, modelMonoTime=plan_stamp))
for lateral in (True, False):
state = self.state(lateral, False)
self.assertFalse(state.longitudinal_active)
self.assertIsNone(state.e2e_slowdown)
self.assertEqual(rgba(axis_status_color(state)), (10, 186, 181, 255) if lateral else (18, 40, 57, 255))
with patch.multiple(sidebar, **{name: Mock() for name in ('_stop_icon', '_slowdown_icon', '_lead_icon',
'_curve_icon', '_chill_icon', '_speed_icon')}):
sidebar._conditional(center, state)
getattr(sidebar, expected).assert_called_once()
sidebar._speed_icon.assert_not_called()
sm.put('modelV2', NS(action=NS(shouldStop=True, desiredAcceleration=-0.5)))
sm.valid['modelV2'] = False
self.assertIsNone(self.state(True, False).e2e_preview_slowdown)
sm.valid['modelV2'] = True
sm['selfdriveState'].experimentalMode = False
self.assertIsNone(self.state(True, False).e2e_preview_slowdown)
def test_end_to_end_sidebar_uses_a_moon_until_the_planner_reports_a_specific_reason(self):
self.ui.params.put('ConditionalModeConfig', json.loads(encode_preferences(SavedPreferences(mode=ModeChoice.STOCK))), block=True)
self.ui.sm['selfdriveState'].experimentalMode = True
@@ -158,6 +158,7 @@ def test_actual_c4_startup_redirect_only_yields_to_fresh_open_parked_game(monkey
owner._prev_onroad, owner._prev_standstill = True, True
owner._onroad_time_delay = 5.
owner._onboarding_window = Mock()
owner._home_layout = Mock()
page = object.__new__(native.SpacePilotPage)
page.closed = condition == 'closed'
page.session = Mock(stage=native.Stage.CLOSED if page.closed else native.Stage.VERIFYING)
@@ -1,6 +1,8 @@
from dataclasses import replace
from types import SimpleNamespace
import pytest
from opendbc.car import gen_empty_fingerprint, structs
from opendbc.car.toyota.enhanced_bsm import configured
from opendbc.car.toyota.interface import CarInterface
@@ -12,10 +14,14 @@ from openpilot.starpilot.ui.vehicle_bool import VEHICLE_BOOL_KEYS, confirmation_
from openpilot.starpilot.vehicle_preferences import VehicleStartupPreferences
def test_vehicle_setting_and_startup_permission(tmp_path):
@pytest.mark.parametrize('factory_bsm', (False, True))
def test_vehicle_setting_and_startup_permission(tmp_path, factory_bsm):
params = Params(str(tmp_path))
fw = [structs.CarParams.CarFw(ecu=structs.CarParams.Ecu.hybrid)]
current = SimpleNamespace(cp=CarInterface.get_params(CAR.TOYOTA_PRIUS_TSS2, gen_empty_fingerprint(), fw, False, False, False), parked=True)
fp = gen_empty_fingerprint()
if factory_bsm:
fp[0][0x3F6] = 8
current = SimpleNamespace(cp=CarInterface.get_params(CAR.TOYOTA_PRIUS_TSS2, fp, fw, False, False, False), parked=True)
owner = FeatureSettingsOwner(params, lambda group: current.parked and group in ('vehicle', 'parked_preferences'),
vehicle_fingerprint=lambda: current.cp.carFingerprint, vehicle_params=lambda: current.cp)
@@ -46,8 +52,6 @@ def test_vehicle_setting_and_startup_permission(tmp_path):
params.put_bool('SafeMode', True, block=True)
VehicleStartupPreferences.read(params, enabled=True).finalize(cp)
assert not configured(cp)
fp = gen_empty_fingerprint()
fp[0][0x3F6] = 8
current.cp = CarInterface.get_params(CAR.TOYOTA_PRIUS_TSS2, fp, fw, False, False, False)
current.cp = CarInterface.get_params(CAR.TOYOTA_COROLLA_TSS2, fp, fw, False, False, False)
assert not rows()
assert not configured(prefs.prepare(current.cp))
@@ -112,7 +112,7 @@ def test_renderer_dispatches_each_widget_in_saved_order(profile, viewport):
method = next(node for node in ast.walk(tree) if isinstance(node, ast.FunctionDef) and node.name == '_ordered_widgets')
namespace: dict[str, Any] = {'CLOCK_WIDGET': CLOCK_WIDGET, 'MODE_WIDGET': MODE_WIDGET, 'placement': placement, 'widget_order': widget_order,
'RAIL_WIDGETS': RAIL_WIDGETS, 'STOPPED_TIMER_WIDGET': STOPPED_TIMER_WIDGET,
'render_rear_fog': lambda *args: seen.append('rear_fog'),
'render_rear_fog': lambda *args: seen.append('rear_fog'), 'compact_wheel_warning': lambda state: False,
'manual_slc_confirmation': lambda profile, state: False, 'AlertSize': NS(NONE='none', FULL='full'), 'CameraViewChoice': NS(NONE='none'),
'rl': NS(Rectangle=lambda x, y, width, height: NS(x=x, y=y, width=width, height=height))}
exec(compile(ast.Module(body=[method], type_ignores=[]), str(source), 'exec'), namespace)
+17 -5
View File
@@ -462,12 +462,24 @@ class TestAthenadMethods(OpenpilotTestCase):
fn = self._create_file('qlog.zst')
item = athenad.UploadItem(path=fn, url=f"{host}/qlog.zst", headers={}, created_at=int(time.time()*1000), id='', allow_cellular=True) # noqa: TID251
athenad.upload_queue.put_nowait(item)
self._wait_for_upload()
started, release = threading.Event(), threading.Event()
upload = athenad._do_upload
items = dispatcher["listUploadQueue"]()
assert len(items) == 1
assert items[0]['current']
def hold_upload(*args, **kwargs):
started.set()
if not release.wait(5):
raise TimeoutError("Upload queue assertion did not release the transfer")
return upload(*args, **kwargs)
with mock.patch.object(athenad, "_do_upload", side_effect=hold_upload):
athenad.upload_queue.put_nowait(item)
try:
assert started.wait(5)
items = dispatcher["listUploadQueue"]()
assert len(items) == 1
assert items[0]['current'] and items[0]['path'] == fn
finally:
release.set()
def test_list_upload_queue_priority(self):
priorities = (25, 50, 99, 75, 0)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -1,4 +1,4 @@
#pragma once
extern const uint8_t gitversion[29];
const uint8_t gitversion[29] = "DEV-6bd89852-Pf38f504f-DEBUG";
const uint8_t gitversion[29] = "DEV-57f15547-Pf38f504f-DEBUG";
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -1 +1 @@
DEV-6bd89852-Pf38f504f-DEBUG
DEV-57f15547-Pf38f504f-DEBUG
Binary file not shown.
+1 -1
View File
@@ -1 +1 @@
{"protected_inventory_sha256": "a99017021edd749982e3b3ec07191fe296b48b997b65b0d64294a720023d7ca8", "schema_version": 1}
{"protected_inventory_sha256": "9ecf7ff0e3a1d1292bc4e4ec99225755b1bdfd0a678329094f974832b97829f2", "schema_version": 1}
+23 -23
View File
@@ -10,123 +10,123 @@
"basis": "Existing exact capability guard, preserved from8b9338a0; skipped remains unavailable, never passed",
"guard": "real_xapk",
"reason": "Skipped: the user's own Android Auto XAPK is not in .cache/",
"source_blob": "b642d677dcabd4d51f8379dd05d9c72cdcf35f37"
"source_blob": "d09d62b9e7a947df49bcf46c39eb3b396719d306"
},
"openpilot/starpilot/system/starport/tests/test_gpu_nv12.py::test_composed_car_frame_converts_to_the_same_picture[False-32-18-0-0]": {
"basis": "Re-audited software EGL setup through ff5342ca; exact GPU environment guard unchanged; skipped remains unavailable, never passed",
"guard": "gpu_env",
"reason": "Skipped: STARPILOT_AUTO_GL_TEST=1 enables tests requiring a real graphics context",
"source_blob": "6890e34c1e01be80495c1dc1089529c362de68f3"
"source_blob": "e9113b0c1e44d0975721a3ae165fdf056a7a106e"
},
"openpilot/starpilot/system/starport/tests/test_gpu_nv12.py::test_composed_car_frame_converts_to_the_same_picture[False-32-18-4-2]": {
"basis": "Re-audited software EGL setup through ff5342ca; exact GPU environment guard unchanged; skipped remains unavailable, never passed",
"guard": "gpu_env",
"reason": "Skipped: STARPILOT_AUTO_GL_TEST=1 enables tests requiring a real graphics context",
"source_blob": "6890e34c1e01be80495c1dc1089529c362de68f3"
"source_blob": "e9113b0c1e44d0975721a3ae165fdf056a7a106e"
},
"openpilot/starpilot/system/starport/tests/test_gpu_nv12.py::test_composed_car_frame_converts_to_the_same_picture[False-32-20-3-5]": {
"basis": "Re-audited software EGL setup through ff5342ca; exact GPU environment guard unchanged; skipped remains unavailable, never passed",
"guard": "gpu_env",
"reason": "Skipped: STARPILOT_AUTO_GL_TEST=1 enables tests requiring a real graphics context",
"source_blob": "6890e34c1e01be80495c1dc1089529c362de68f3"
"source_blob": "e9113b0c1e44d0975721a3ae165fdf056a7a106e"
},
"openpilot/starpilot/system/starport/tests/test_gpu_nv12.py::test_composed_car_frame_converts_to_the_same_picture[False-40-18-0-6]": {
"basis": "Re-audited software EGL setup through ff5342ca; exact GPU environment guard unchanged; skipped remains unavailable, never passed",
"guard": "gpu_env",
"reason": "Skipped: STARPILOT_AUTO_GL_TEST=1 enables tests requiring a real graphics context",
"source_blob": "6890e34c1e01be80495c1dc1089529c362de68f3"
"source_blob": "e9113b0c1e44d0975721a3ae165fdf056a7a106e"
},
"openpilot/starpilot/system/starport/tests/test_gpu_nv12.py::test_composed_car_frame_converts_to_the_same_picture[True-32-18-0-0]": {
"basis": "Re-audited software EGL setup through ff5342ca; exact GPU environment guard unchanged; skipped remains unavailable, never passed",
"guard": "gpu_env",
"reason": "Skipped: STARPILOT_AUTO_GL_TEST=1 enables tests requiring a real graphics context",
"source_blob": "6890e34c1e01be80495c1dc1089529c362de68f3"
"source_blob": "e9113b0c1e44d0975721a3ae165fdf056a7a106e"
},
"openpilot/starpilot/system/starport/tests/test_gpu_nv12.py::test_composed_car_frame_converts_to_the_same_picture[True-32-18-4-2]": {
"basis": "Re-audited software EGL setup through ff5342ca; exact GPU environment guard unchanged; skipped remains unavailable, never passed",
"guard": "gpu_env",
"reason": "Skipped: STARPILOT_AUTO_GL_TEST=1 enables tests requiring a real graphics context",
"source_blob": "6890e34c1e01be80495c1dc1089529c362de68f3"
"source_blob": "e9113b0c1e44d0975721a3ae165fdf056a7a106e"
},
"openpilot/starpilot/system/starport/tests/test_gpu_nv12.py::test_composed_car_frame_converts_to_the_same_picture[True-32-20-3-5]": {
"basis": "Re-audited software EGL setup through ff5342ca; exact GPU environment guard unchanged; skipped remains unavailable, never passed",
"guard": "gpu_env",
"reason": "Skipped: STARPILOT_AUTO_GL_TEST=1 enables tests requiring a real graphics context",
"source_blob": "6890e34c1e01be80495c1dc1089529c362de68f3"
"source_blob": "e9113b0c1e44d0975721a3ae165fdf056a7a106e"
},
"openpilot/starpilot/system/starport/tests/test_gpu_nv12.py::test_composed_car_frame_converts_to_the_same_picture[True-40-18-0-6]": {
"basis": "Re-audited software EGL setup through ff5342ca; exact GPU environment guard unchanged; skipped remains unavailable, never passed",
"guard": "gpu_env",
"reason": "Skipped: STARPILOT_AUTO_GL_TEST=1 enables tests requiring a real graphics context",
"source_blob": "6890e34c1e01be80495c1dc1089529c362de68f3"
"source_blob": "e9113b0c1e44d0975721a3ae165fdf056a7a106e"
},
"openpilot/starpilot/system/starport/tests/test_gpu_nv12.py::test_fused_projection_conversion_matches_rgba_composition[False-32-18-0-0]": {
"basis": "Re-audited software EGL setup through ff5342ca; exact GPU environment guard unchanged; skipped remains unavailable, never passed",
"guard": "gpu_env",
"reason": "Skipped: STARPILOT_AUTO_GL_TEST=1 enables tests requiring a real graphics context",
"source_blob": "6890e34c1e01be80495c1dc1089529c362de68f3"
"source_blob": "e9113b0c1e44d0975721a3ae165fdf056a7a106e"
},
"openpilot/starpilot/system/starport/tests/test_gpu_nv12.py::test_fused_projection_conversion_matches_rgba_composition[False-32-18-4-2]": {
"basis": "Re-audited software EGL setup through ff5342ca; exact GPU environment guard unchanged; skipped remains unavailable, never passed",
"guard": "gpu_env",
"reason": "Skipped: STARPILOT_AUTO_GL_TEST=1 enables tests requiring a real graphics context",
"source_blob": "6890e34c1e01be80495c1dc1089529c362de68f3"
"source_blob": "e9113b0c1e44d0975721a3ae165fdf056a7a106e"
},
"openpilot/starpilot/system/starport/tests/test_gpu_nv12.py::test_fused_projection_conversion_matches_rgba_composition[False-32-20-3-5]": {
"basis": "Re-audited software EGL setup through ff5342ca; exact GPU environment guard unchanged; skipped remains unavailable, never passed",
"guard": "gpu_env",
"reason": "Skipped: STARPILOT_AUTO_GL_TEST=1 enables tests requiring a real graphics context",
"source_blob": "6890e34c1e01be80495c1dc1089529c362de68f3"
"source_blob": "e9113b0c1e44d0975721a3ae165fdf056a7a106e"
},
"openpilot/starpilot/system/starport/tests/test_gpu_nv12.py::test_fused_projection_conversion_matches_rgba_composition[True-32-18-0-0]": {
"basis": "Re-audited software EGL setup through ff5342ca; exact GPU environment guard unchanged; skipped remains unavailable, never passed",
"guard": "gpu_env",
"reason": "Skipped: STARPILOT_AUTO_GL_TEST=1 enables tests requiring a real graphics context",
"source_blob": "6890e34c1e01be80495c1dc1089529c362de68f3"
"source_blob": "e9113b0c1e44d0975721a3ae165fdf056a7a106e"
},
"openpilot/starpilot/system/starport/tests/test_gpu_nv12.py::test_fused_projection_conversion_matches_rgba_composition[True-32-18-4-2]": {
"basis": "Re-audited software EGL setup through ff5342ca; exact GPU environment guard unchanged; skipped remains unavailable, never passed",
"guard": "gpu_env",
"reason": "Skipped: STARPILOT_AUTO_GL_TEST=1 enables tests requiring a real graphics context",
"source_blob": "6890e34c1e01be80495c1dc1089529c362de68f3"
"source_blob": "e9113b0c1e44d0975721a3ae165fdf056a7a106e"
},
"openpilot/starpilot/system/starport/tests/test_gpu_nv12.py::test_fused_projection_conversion_matches_rgba_composition[True-32-20-3-5]": {
"basis": "Re-audited software EGL setup through ff5342ca; exact GPU environment guard unchanged; skipped remains unavailable, never passed",
"guard": "gpu_env",
"reason": "Skipped: STARPILOT_AUTO_GL_TEST=1 enables tests requiring a real graphics context",
"source_blob": "6890e34c1e01be80495c1dc1089529c362de68f3"
"source_blob": "e9113b0c1e44d0975721a3ae165fdf056a7a106e"
},
"openpilot/starpilot/ui/tests/test_onroad_map.py::test_overlay_draws_heading_up_roads_route_and_soft_edges": {
"basis": "Re-audited unchanged map GPU test bodies and shared fixture alias; software EGL setup through ff5342ca; exact environment guard unchanged; skipped remains unavailable, never passed",
"guard": "gpu_env",
"guard_source_blob": "6890e34c1e01be80495c1dc1089529c362de68f3",
"guard_source_blob": "e9113b0c1e44d0975721a3ae165fdf056a7a106e",
"guard_source_path": "openpilot/starpilot/system/starport/tests/test_gpu_nv12.py",
"reason": "Skipped: STARPILOT_AUTO_GL_TEST=1 enables tests requiring a real graphics context",
"source_blob": "df1f777daf295f4997e0659ad0dec4e4efcf38ee"
"source_blob": "92db495f2fdadcd961a92da8bbdb2118a0085a81"
},
"openpilot/starpilot/ui/tests/test_onroad_map.py::test_overlay_opacity_fades_map_background": {
"basis": "Re-audited unchanged map GPU test bodies and shared fixture alias; software EGL setup through ff5342ca; exact environment guard unchanged; skipped remains unavailable, never passed",
"guard": "gpu_env",
"guard_source_blob": "6890e34c1e01be80495c1dc1089529c362de68f3",
"guard_source_blob": "e9113b0c1e44d0975721a3ae165fdf056a7a106e",
"guard_source_path": "openpilot/starpilot/system/starport/tests/test_gpu_nv12.py",
"reason": "Skipped: STARPILOT_AUTO_GL_TEST=1 enables tests requiring a real graphics context",
"source_blob": "df1f777daf295f4997e0659ad0dec4e4efcf38ee"
"source_blob": "92db495f2fdadcd961a92da8bbdb2118a0085a81"
},
"openpilot/starpilot/ui/tests/test_onroad_map.py::test_overlay_without_gps_waits_without_drawing_roads": {
"basis": "Re-audited unchanged map GPU test bodies and shared fixture alias; software EGL setup through ff5342ca; exact environment guard unchanged; skipped remains unavailable, never passed",
"guard": "gpu_env",
"guard_source_blob": "6890e34c1e01be80495c1dc1089529c362de68f3",
"guard_source_blob": "e9113b0c1e44d0975721a3ae165fdf056a7a106e",
"guard_source_path": "openpilot/starpilot/system/starport/tests/test_gpu_nv12.py",
"reason": "Skipped: STARPILOT_AUTO_GL_TEST=1 enables tests requiring a real graphics context",
"source_blob": "df1f777daf295f4997e0659ad0dec4e4efcf38ee"
"source_blob": "92db495f2fdadcd961a92da8bbdb2118a0085a81"
},
"openpilot/starpilot/ui/tests/test_onroad_map.py::test_route_stays_bright_at_minimum_map_opacity": {
"basis": "Re-audited unchanged map GPU test bodies and shared fixture alias; software EGL setup through ff5342ca; exact environment guard unchanged; skipped remains unavailable, never passed",
"guard": "gpu_env",
"guard_source_blob": "6890e34c1e01be80495c1dc1089529c362de68f3",
"guard_source_blob": "e9113b0c1e44d0975721a3ae165fdf056a7a106e",
"guard_source_path": "openpilot/starpilot/system/starport/tests/test_gpu_nv12.py",
"reason": "Skipped: STARPILOT_AUTO_GL_TEST=1 enables tests requiring a real graphics context",
"source_blob": "df1f777daf295f4997e0659ad0dec4e4efcf38ee"
"source_blob": "92db495f2fdadcd961a92da8bbdb2118a0085a81"
}
},
"independent_functions": {