mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-09-26 17:43:43 +08:00
ee5c1c4507
* allow re-regage * bump opendbc * bump panda * apply pause/resume fix for hyundai (should do this in a separate PR) * bump opendbc * fix * rename * Fix? * make sure to disengage for allow always cars * fix * combine * more fix * not needed * check if engagement is from openpilot's state machine * Rename * fix panda safety * fix * no fake lfa button for @devtekve ;) * fix non drive gear re-engage * fix settings * combine * add replace method * use replace * remoev already checks if it exists * fix * group * add todo * reserve events * cleaner * hyundai: only allow for cars with lfa button * sunnyParams * make sure it's car only * Move car-specific changes to opendbc * no need * bump opendbc * more fixes * no more available * more! * final? * always emit user disable * no longer needed * move unit test * add sunnypilot to unit tests * bump opendbc * use new cereal * bump opendbc * static analysis * no unittest * no need available * UI border update * show MADS updates * Add TODO * no longer needed * fix changed events * fix cluster enabled * don't add pre enable if not long * should use enabled * enabled <-> active * better format * bump opendbc * static analysis * static analysis * Rename test as collector was dying * Show our overriding * Revert "show MADS updates" This reverts commitdaf0ad62Revert "fix changed events" This reverts commit31d8c97f* ignoring reserved events * adjusting creation delays * back to stock removing allow_cancel * should be enabled * revert * silent lkas disable * no need * user disable tests * just warning * MUST REMOVE test process replay * fix no entry * fixme * bump opendbc * need this check * cleanup * allow entering paused state if no entry from disabled * brake hold should apply to all * in lists * update unit test * simpler * unused * same thing * fix * only mads in enabled state and long in disabled state * unify silent enable * do this for dlob * bump submodules * fix * bump submodules * bump opendbc * less frequent * more events * fix * allow no entry to paused for non-drive gears * fix * use cereal * Revert "allow no entry to paused for non-drive gears" This reverts commit6d64a4dd9c. * allow in all * Revert "allow in all" This reverts commit6375f14891. * should not be all! * rename for clarity * silent park brake * flipped * bump submodules * Bump to latest mads-new panda * bump panda * more nissan * bump panda * bump msgq * bump panda * bump submodules * bump opendbc * bump opendbc * improving the state * Revert "PlayStation® model (#34133)" This reverts commit5160bee543. * should be none * bump panda * bump opendbc * Apply suggestions from code review * bump panda * bump ref panda * add todo-sp * bump panda ref * bump more panda * changing refs * nuke nuke nuke * use sunny's newer states * bump with new panda * bump panda * Parse more flags from alt exp, more tests, hyundai main cruise allowed * Parse more flags from alt exp, more tests, hyundai main cruise allowed * missed * mutation for controls allowed rising edge * ford mutation * license * remove * unused * bump submodules * use always allowed mads button alt exp * fix * whitelist jason's lastname to codespell * test_processes: update ref logs to82c0278* bump submodules * bump submodules * bump submodules * bump panda * add controls mismatch lateral event * Simplify lateral disengagement logic for MADS configuration Reversed the conditional to align the logic with the `disengage_lateral_on_brake` parameter. This ensures that lateral disengagement behavior is more intuitive and matches the expected configuration. Improves code readability and reduces potential misconfigurations. * remove unified engagement mode in panda * controls allow should be allowed at all times * squash! treat MADS button as user entry * heartbeat for mads * heartbeat mismatch exit control * remove always allow mads button from alt * move to safety_mads * remove main cruise allowed from alt * bump panda * heartbeat engaged mads mismatch mutation test * bump panda * use mads the third panda * ignore pre enable with mads * only force exit if actually actuating * use brake signal instead of pedal events when dlob is active * fix tests * fix panda tests * bump panda * new events to retain long blocks * format * uem: do not engage mads if long is engaged * bump submodules * fix not allowed engaged bug * block uem from engaging * flipped * use different heartbeat check if dlob * hard code to skip heartbeat check * remove toyota lta status for lkas, causes weird behaviors * block tesla * bump panda * bump to merged panda * bump opendbc * bump opendbc * bump opendbc * bump opendbc * Apply suggestions from code review * code ignore spells * needs to be in carstate * Bump opendbc * Update MADS toggle descriptions for clarity. Added notes to clarify behavior of the "MadsMainCruiseAllowed" setting, particularly its impact on vehicles without LFA/LKAS buttons. This ensures users are informed about potential implications when disabling this feature. * Updating translations + Adding spanish * Disengage Lateral on Brake -> Pause Lateral on Brake * test_processes: update ref logs todd41005* Apply suggestions from code review * fix mads button not allowed * bump submodules * bump submodule * test_processes: update ref logs to0a0b998* has multiple lists * Revert "has multiple lists" This reverts commita37c1d26fe. * base * Reapply "has multiple lists" This reverts commitd1cd8dcc81. * migrate mads toggles to sp panel * this is why it keeps crashing * house keeping * more housekeeping * more housekeeping * don't show description by default (yet) * reset to main panel when clicked away * more * some more with interactions * don't stretch cause it looks weird with descriptions * simpler to handle offroad transition * some are toggleable while onroad * remove unused event * slight cleanup * default to true for HKG main cruise toggle * append to list after * add Customize MADS to UI preview * simpler * move to sp list * how tf was this removed * update mads settings button on show event * test_processes: update ref logs toefa9c32--------- Co-authored-by: Jason Wen <haibin.wen3@gmail.com>
131 lines
4.4 KiB
Python
131 lines
4.4 KiB
Python
import copy
|
|
import json
|
|
import os
|
|
import random
|
|
from PIL import Image, ImageDraw, ImageFont
|
|
|
|
from cereal import log, car
|
|
from cereal.messaging import SubMaster
|
|
from openpilot.common.basedir import BASEDIR
|
|
from openpilot.common.params import Params
|
|
from openpilot.selfdrive.selfdrived.events import Alert, EVENTS, ET
|
|
from openpilot.selfdrive.selfdrived.alertmanager import set_offroad_alert
|
|
from openpilot.selfdrive.test.process_replay.process_replay import CONFIGS
|
|
|
|
AlertSize = log.SelfdriveState.AlertSize
|
|
|
|
OFFROAD_ALERTS_PATH = os.path.join(BASEDIR, "selfdrive/selfdrived/alerts_offroad.json")
|
|
|
|
# TODO: add callback alerts
|
|
ALERTS = []
|
|
for event_types in EVENTS.values():
|
|
for alert in event_types.values():
|
|
ALERTS.append(alert)
|
|
|
|
|
|
class TestAlerts:
|
|
|
|
@classmethod
|
|
def setup_class(cls):
|
|
with open(OFFROAD_ALERTS_PATH) as f:
|
|
cls.offroad_alerts = json.loads(f.read())
|
|
|
|
# Create fake objects for callback
|
|
cls.CS = car.CarState.new_message()
|
|
cls.CP = car.CarParams.new_message()
|
|
cfg = [c for c in CONFIGS if c.proc_name == 'selfdrived'][0]
|
|
cls.sm = SubMaster(cfg.pubs)
|
|
|
|
def test_events_defined(self):
|
|
# Ensure all events in capnp schema are defined in events.py
|
|
events = log.OnroadEvent.EventName.schema.enumerants
|
|
|
|
for name, e in events.items():
|
|
if not name.endswith("DEPRECATED") and not name.startswith("eventReserved"):
|
|
fail_msg = f"{name} @{e} not in EVENTS"
|
|
assert e in EVENTS.keys(), fail_msg
|
|
|
|
# ensure alert text doesn't exceed allowed width
|
|
def test_alert_text_length(self):
|
|
font_path = os.path.join(BASEDIR, "selfdrive/assets/fonts")
|
|
regular_font_path = os.path.join(font_path, "Inter-SemiBold.ttf")
|
|
bold_font_path = os.path.join(font_path, "Inter-Bold.ttf")
|
|
semibold_font_path = os.path.join(font_path, "Inter-SemiBold.ttf")
|
|
|
|
max_text_width = 2160 - 300 # full screen width is usable, minus sidebar
|
|
draw = ImageDraw.Draw(Image.new('RGB', (0, 0)))
|
|
|
|
fonts = {
|
|
AlertSize.small: [ImageFont.truetype(semibold_font_path, 74)],
|
|
AlertSize.mid: [ImageFont.truetype(bold_font_path, 88),
|
|
ImageFont.truetype(regular_font_path, 66)],
|
|
}
|
|
|
|
for alert in ALERTS:
|
|
if not isinstance(alert, Alert):
|
|
alert = alert(self.CP, self.CS, self.sm, metric=False, soft_disable_time=100, personality=log.LongitudinalPersonality.standard)
|
|
|
|
# for full size alerts, both text fields wrap the text,
|
|
# so it's unlikely that they would go past the max width
|
|
if alert.alert_size in (AlertSize.none, AlertSize.full):
|
|
continue
|
|
|
|
for i, txt in enumerate([alert.alert_text_1, alert.alert_text_2]):
|
|
if i >= len(fonts[alert.alert_size]):
|
|
break
|
|
|
|
font = fonts[alert.alert_size][i]
|
|
left, _, right, _ = draw.textbbox((0, 0), txt, font)
|
|
width = right - left
|
|
msg = f"type: {alert.alert_type} msg: {txt}"
|
|
assert width <= max_text_width, msg
|
|
|
|
def test_alert_sanity_check(self):
|
|
for event_types in EVENTS.values():
|
|
for event_type, a in event_types.items():
|
|
# TODO: add callback alerts
|
|
if not isinstance(a, Alert):
|
|
continue
|
|
|
|
if a.alert_size == AlertSize.none:
|
|
assert len(a.alert_text_1) == 0
|
|
assert len(a.alert_text_2) == 0
|
|
elif a.alert_size == AlertSize.small:
|
|
assert len(a.alert_text_1) > 0
|
|
assert len(a.alert_text_2) == 0
|
|
elif a.alert_size == AlertSize.mid:
|
|
assert len(a.alert_text_1) > 0
|
|
assert len(a.alert_text_2) > 0
|
|
else:
|
|
assert len(a.alert_text_1) > 0
|
|
|
|
assert a.duration >= 0.
|
|
|
|
if event_type not in (ET.WARNING, ET.PERMANENT, ET.PRE_ENABLE):
|
|
assert a.creation_delay == 0.
|
|
|
|
def test_offroad_alerts(self):
|
|
params = Params()
|
|
for a in self.offroad_alerts:
|
|
# set the alert
|
|
alert = copy.copy(self.offroad_alerts[a])
|
|
set_offroad_alert(a, True)
|
|
alert['extra'] = ''
|
|
assert json.dumps(alert) == params.get(a, encoding='utf8')
|
|
|
|
# then delete it
|
|
set_offroad_alert(a, False)
|
|
assert params.get(a) is None
|
|
|
|
def test_offroad_alerts_extra_text(self):
|
|
params = Params()
|
|
for i in range(50):
|
|
# set the alert
|
|
a = random.choice(list(self.offroad_alerts))
|
|
alert = self.offroad_alerts[a]
|
|
set_offroad_alert(a, True, extra_text="a"*i)
|
|
|
|
written_alert = json.loads(params.get(a, encoding='utf8'))
|
|
assert "a"*i == written_alert['extra']
|
|
assert alert["text"] == written_alert['text']
|