Simplify Driving Modes to Automatic, Chill and Experimental

This commit is contained in:
firestar5683
2026-11-13 10:05:09 -06:00
parent 94538a3d4f
commit b834a9327a
54 changed files with 88 additions and 61 deletions
@@ -178,7 +178,8 @@ def encode_preferences(preferences: SavedPreferences) -> bytes:
def saved_selection_for_drive(preferences: SavedPreferences, drive_id: object) -> ModeSelection | None:
"""Bind validated preferences to a drive; live authority is checked by Host."""
_validate(preferences)
return selection_for_drive(preferences.mode, preferences.mode_settings(), drive_id)
choice = ModeChoice.CEM if preferences.mode is ModeChoice.CCM else preferences.mode
return selection_for_drive(choice, preferences.mode_settings(), drive_id)
@dataclass(frozen=True)
@@ -20,6 +20,7 @@ from openpilot.starpilot.conditional_mode.preferences import (
SavedPreferences, decode_preferences, saved_selection_for_drive,
)
from openpilot.starpilot.saved_source import read_saved
from openpilot.starpilot.conditional_mode.policy import ModeChoice
DOCUMENT_KEY = 'ConditionalModeConfig'
@@ -114,7 +115,10 @@ def _document(raw: bytes | None, readable: bool) -> tuple[DocumentState, SavedPr
if raw is None:
return DocumentState.ABSENT, SavedPreferences()
try:
return DocumentState.VALID, decode_preferences(raw)
preferences = decode_preferences(raw)
if preferences.mode is ModeChoice.CCM:
preferences = replace(preferences, mode=ModeChoice.CEM)
return DocumentState.VALID, preferences
except PreferenceError:
return DocumentState.INVALID, None
@@ -58,7 +58,7 @@ class ManualSavedTests(unittest.TestCase):
self.assertEqual(read_codes(self.params).status, 'invalid')
self.assertEqual(Path(self.params.get_param_path(KEY)).read_bytes(), raw)
def test_persisted_modes_restore_independently_and_auto_zero_is_saved(self):
def test_auto_zero_is_saved_and_retired_manual_choice_cannot_restore(self):
self.params.put(KEY, json.loads(encode(SavedCodes(2, 1))), block=True)
owner, snapshot = self.owner(ModeChoice.CEM, persist=True)
start = owner.begin_drive(snapshot, choice=ModeChoice.CEM, drive_id=self.drive_id, now_ns=self.now)
@@ -75,7 +75,9 @@ class ManualSavedTests(unittest.TestCase):
self.addCleanup(second.close)
restored = second.begin_drive(second_snapshot, choice=ModeChoice.CCM, drive_id=self.drive_id + 2_000_000_000,
now_ns=self.now)
self.assertEqual((restored.code, restored.intent), (1, ManualIntent.FORCE_EXPERIMENTAL))
self.assertEqual((restored.code, restored.intent), (None, None))
self.assertEqual(second_snapshot.preferences.mode, ModeChoice.CEM)
self.assertEqual(read_codes(self.params).codes, SavedCodes(0, 1))
def test_optout_clears_selected_code_only(self):
self.params.put(KEY, json.loads(encode(SavedCodes(1, 2))), block=True)
@@ -63,7 +63,7 @@ class ConditionalModePreferencesTest(unittest.TestCase):
def test_drive_binding_preserves_existing_typed_api_and_does_not_grant_authority(self):
preferences = SavedPreferences(mode=ModeChoice.CCM)
selection = saved_selection_for_drive(preferences, 42)
self.assertEqual(selection, selection_for_drive(ModeChoice.CCM, preferences.mode_settings(), 42))
self.assertEqual(selection, selection_for_drive(ModeChoice.CEM, preferences.mode_settings(), 42))
self.assertIsNone(saved_selection_for_drive(preferences, 0))
self.assertIsNone(saved_selection_for_drive(preferences, True))
self.assertIsNone(manual_for_drive('force_chill', 42, 100))
@@ -141,7 +141,7 @@ class ConditionalRuntimeSettingsTest(unittest.TestCase):
recovered = self.owner.refresh(2_000_000_000)
self.assertEqual(recovered.revision, 2)
self.assertEqual(self.owner.verdict(recovered, now_mono_ns=2_050_000_000, drive_id=1).selection.choice,
ModeChoice.CCM)
ModeChoice.CEM)
self.assertEqual(self.path(DOCUMENT_KEY).read_bytes(), encode_preferences(self.saved(ModeChoice.CCM)))
def test_read_error_is_distinct_from_absence_and_stops_old_affirmation(self):
@@ -297,7 +297,7 @@ class TestStopCommitTransport(unittest.TestCase):
for _ in range(25):
proposal, result = self.sample(manual=ManualIntent.FORCE_CHILL)
self.assertTrue(result.accepted and result.experimental)
self.assertEqual(proposal.choice, choice)
self.assertEqual(proposal.choice, ModeChoice.CEM if choice is ModeChoice.CCM else choice)
for _ in range(30):
proposal, result = self.sample(horizon=192., model_should_stop=False)
self.assertFalse(result.experimental)
@@ -62,7 +62,7 @@ class TestUiAction(unittest.TestCase):
self.sample(MONO + 10_000_000)
def configure(self, choice=ModeChoice.CEM, persist=False):
self.choice = choice
self.choice = ModeChoice.CEM if choice is ModeChoice.CCM else choice
document = SavedPreferences(mode=choice, cem=CEMOptions(speed_mps=20.0, persist_manual=persist),
ccm=CCMOptions(persist_manual=persist))
self.params.put('ConditionalModeConfig', json.loads(encode_preferences(document)), block=True)
@@ -135,7 +135,7 @@ class TestUiAction(unittest.TestCase):
time.sleep(.005)
self.fail('manual writer did not settle')
def test_cem_ccm_typed_cycle_and_actual_consumer(self):
def test_automatic_and_retired_mode_typed_cycle_and_actual_consumer(self):
cases = ((choice, effective) for choice in (ModeChoice.CEM, ModeChoice.CCM) for effective in (False, True))
for index, (choice, effective) in enumerate(cases):
with self.subTest(choice=choice, effective=effective):
@@ -144,14 +144,14 @@ class TestUiAction(unittest.TestCase):
self.sample(stamp)
event = self.request(stamp + 10_000_000, effective=effective)
proposal, snapshot = self.sample(stamp + 20_000_000, ui_event=event, effective=effective)
self.assertEqual(self.owner.manual.code, next_manual_status(choice, 0, effective))
self.assertEqual(self.owner.manual.code, next_manual_status(self.choice, 0, effective))
self.assertEqual(self.owner.manual_state.intent, ManualIntent.FORCE_CHILL if effective else ManualIntent.FORCE_EXPERIMENTAL)
self.assertIs(proposal.override_experimental, not effective)
consumer = ModeConsumer()
arguments: dict[str, Any] = {'now_ns': stamp + 21_000_000, 'now_boot_ns': BOOT + stamp - MONO + 21_000_000,
'sample_skew_ns': 1000, 'message_ns': stamp + 21_000_000, 'receipt_ns': stamp + 21_000_000,
'drive_id': MONO, 'model_ns': stamp + 20_000_000, 'car_state_ns': stamp + 20_000_000,
'authority': True, 'stock_experimental': False, 'choice': choice,
'authority': True, 'stock_experimental': False, 'choice': self.choice,
'settings_fingerprint': settings_fingerprint(snapshot)}
consumer.sample(None, **arguments) # Establish its real restart barrier.
later = stamp + 40_000_000
+1 -1
View File
@@ -42,7 +42,7 @@ from openpilot.starpilot.ui.vasm_owner import ANNOTATION as VASM_ANNOTATION, RES
PAGES = frozenset(("hub", "localization", "developer", "vehicle", "slc", "lane", "lane_change", "profiles", "personalities",
"traffic", "aggressive", "standard", "relaxed",
"curve", "torque", "tuning", "torque/bluepilot", "aol", "wheel", "appearance", "display", "data", "power", "sounds", "pip", "sentry", "vasm",
"conditional", "conditional/cem", "conditional/ccm",
"conditional", "conditional/cem",
*(f"{name}/{category}" for name in ("traffic", "aggressive", "standard", "relaxed")
for category in ("acceleration", "braking", "following"))))
CONFIRM_ACTIONS = FEATURE_CONFIRM_ACTIONS | {DRIVER_MONITORING_RESET, CALIBRATION_RESET}
@@ -18,7 +18,7 @@ def setup(tmp_path):
def mode_row(page):
return next(index for index, row in enumerate(page['rows']) if row['label'] == 'Saved driving mode')
return next(index for index, row in enumerate(page['rows']) if row['label'] == 'Driving Mode')
def test_absent_car_can_save_core_conditional_choice_for_later_drive(tmp_path):
@@ -27,9 +27,9 @@ def test_absent_car_can_save_core_conditional_choice_for_later_drive(tmp_path):
index = mode_row(page)
assert page['rows'][index]['available']
assert not any('Wheel assignment' in row['label'] for row in page['rows'])
intent = gateway.preview(page['view'], index, 0, 'session', b'generation', value='Conditional Chill')
intent = gateway.preview(page['view'], index, 0, 'session', b'generation', value='Automatic')
assert gateway.confirm(intent['intent'], 'session', b'generation')
assert decode_preferences(Path(params.get_param_path('ConditionalModeConfig')).read_bytes()).mode.value == 'conditional_chill'
assert decode_preferences(Path(params.get_param_path('ConditionalModeConfig')).read_bytes()).mode.value == 'conditional_experimental'
current.parked = False
page = gateway.page('conditional', 'session', b'generation')
assert page['rows'][index]['available']
@@ -60,7 +60,7 @@ def test_unsupported_car_can_save_core_but_not_use_stale_context(tmp_path):
def test_changed_saved_document_rejects_confirm_without_overwrite(tmp_path):
params, _, gateway = setup(tmp_path)
page = gateway.page('conditional', 'session', b'generation')
intent = gateway.preview(page['view'], mode_row(page), 0, 'session', b'generation', value='Conditional Chill')
intent = gateway.preview(page['view'], mode_row(page), 0, 'session', b'generation', value='Automatic')
path = Path(params.get_param_path('ConditionalModeConfig'))
path.write_bytes(b'{"version":2}')
assert not gateway.confirm(intent['intent'], 'session', b'generation')
@@ -104,7 +104,7 @@ class TestOffroadConfigurationPages(unittest.TestCase):
self.assertTrue(self.gateway.confirm(intent['intent'], 'session', b'generation'))
expected = {
'aol': ('Enable Always On Lateral', 'Brake pause below'),
'conditional': ('Saved driving mode',),
'conditional': ('Driving Mode',),
'conditional/cem': ('Speed threshold', 'Speed with lead', 'Stop lights'),
'lane_change': ('Allow lane changes', 'Minimum lane-change speed', 'Automatic Lane Changes', 'Lane Change Speed'),
'slc': ('Speed Limit Controller', 'Confirm limits'),
@@ -193,7 +193,7 @@ await conditional.reply(0, { ...lane, page: "hub", rows: [{ label: "Conditional
value: "Development saved settings", available: true, action: false }] })
conditional.feed.load("conditional")
assert.equal(conditional.requests[1].url, "./api/settings/pages/conditional")
await conditional.reply(1, { ...lane, page: "conditional", rows: [{ ...lane.rows[0], label: "Saved driving mode",
await conditional.reply(1, { ...lane, page: "conditional", rows: [{ ...lane.rows[0], label: "Driving Mode",
value: "Stock", choices: ["Stock", "Conditional Experimental", "Conditional Chill"] }] })
conditional.feed.preview(0, 1)
await conditional.reply(2, { intent: "mode-once", question: "Save for a later drive?", proposed: "Conditional Experimental" })
@@ -265,7 +265,7 @@ class SettingsGatewayTest(unittest.TestCase):
"vehicle", "personalities"])
self.assertEqual([row["page"] for row in self.page("personalities")["rows"]],
["aggressive", "standard", "relaxed", "traffic"])
for page in ("slc", "lane", "lane_change", "profiles", "conditional", "conditional/cem", "conditional/ccm",
for page in ("slc", "lane", "lane_change", "profiles", "conditional", "conditional/cem",
"curve", "torque", "aol", "appearance", "display", "sounds", "pip", "sentry", "personalities",
"aggressive", "standard", "relaxed", "traffic", "aggressive/following"):
with self.subTest(page=page):
@@ -648,13 +648,13 @@ class SettingsGatewayTest(unittest.TestCase):
from openpilot.starpilot.conditional_mode.preferences import decode_preferences
self.context.value.cp.pcmCruise = True # Nidec still supports native long.
page = self.page("conditional")
self.assertEqual(page["rows"][0]["value"], "Conditional Experimental")
self.assertEqual(page["rows"][0]["value"], "Automatic")
intent = self.gateway.preview(page["view"], 0, 1, self.session, self.generation)
self.assertIn("Conditional Chill", intent["question"])
self.assertIn("Chill", intent["question"])
self.context.value = AuthorityContext(False, self.context.value.cp, b"verified-cp")
self.assertTrue(self.gateway.confirm(intent["intent"], self.session, self.generation))
self.assertEqual(decode_preferences(Path(self.params.get_param_path("ConditionalModeConfig")).read_bytes()).mode.value,
"conditional_chill")
"stock")
page = self.page("conditional/cem")
index = next(i for i, row in enumerate(page["rows"]) if row["label"] == "Open road")
intent = self.gateway.preview(page["view"], index, 1, self.session, self.generation)
@@ -691,7 +691,7 @@ class SettingsGatewayTest(unittest.TestCase):
source = Path(self.params.get_param_path("ConditionalModeConfig"))
source.write_bytes(b'{"version":2}')
page = self.page("conditional")
self.assertFalse(any(row["label"] == "Saved driving mode" for row in page["rows"]))
self.assertFalse(any(row["label"] == "Driving Mode" for row in page["rows"]))
index = next(i for i, row in enumerate(page["rows"]) if row["label"] == "Restore Chill defaults")
self.assertTrue(page["rows"][index]["confirm"])
intent = self.gateway.preview(page["view"], index, 0, self.session, self.generation)
@@ -1827,7 +1827,7 @@ class SettingsHttpTest(SettingsHttpFixture):
cookie = self.login()
status, page, _ = self.request("/api/settings/pages/conditional", cookie=cookie)
self.assertEqual(status, 200)
self.assertEqual(page["rows"][0]["value"], "Conditional Experimental")
self.assertEqual(page["rows"][0]["value"], "Automatic")
status, preview, _ = self.request("/api/settings/preview", cookie=cookie,
payload={"view": page["view"], "row": 0, "direction": 1})
self.assertEqual(status, 200)
@@ -1837,7 +1837,7 @@ class SettingsHttpTest(SettingsHttpFixture):
payload={"intent": preview["intent"], "confirmed": True})
self.assertEqual((status, result), (200, {"saved": True}))
saved = Path(self.params.get_param_path("ConditionalModeConfig")).read_bytes()
self.assertEqual(decode_preferences(saved).mode.value, "conditional_chill")
self.assertEqual(decode_preferences(saved).mode.value, "stock")
def test_conditional_manual_persist_over_authenticated_loopback_http(self):
from openpilot.starpilot.conditional_mode.manual_saved import SavedCodes, decode, encode
+1 -1
View File
@@ -20,7 +20,7 @@ export const DRIVING_GROUPS = Object.freeze([
{ page: "torque", title: "Torque tuning", detail: "Saved steering tune and vehicle-source selection" },
] },
{ title: "Speed and longitudinal", items: [
{ page: "conditional", title: "Conditional driving modes", detail: "Experimental and Chill conditions" },
{ page: "conditional", title: "Driving Modes", detail: "Automatic, Chill and Experimental" },
{ page: "curve", title: "Curve Speed Controller", detail: "Saved curve-speed choices" },
{ page: "slc", title: "Speed Limit Controller", detail: "Dashboard and qualified vision source choices" },
{ page: "profiles", title: "Longitudinal profiles", detail: "Saved acceleration, braking, and following profiles" },
+10 -7
View File
@@ -33,7 +33,7 @@ LABELS = {
"signal_lane_detection": "Signal lane detection", "signal_lane_width_m": "Signal lane width",
"set_speed_margin_mps": "Set speed margin", "launch_assist": "Launch assist",
}
MODES = ("Chill", "Experimental", "Conditional Experimental", "Conditional Chill")
MODES = ("Automatic", "Chill", "Experimental")
SIGNAL_LANE_FIELDS = frozenset(("signal_lane_detection", "signal_lane_width_m"))
SIGNAL_LANE_HELP = {
"signal_lane_detection": "Distinguish a turn from a lane change using the space beside your car. With this on, a turn signal requests " +
@@ -137,6 +137,8 @@ class ConditionalFeature:
return self._media_rows(document, safe, safe_readable, config_valid=valid)
def rows(self, page: str, parked: bool) -> list[FeatureRow]:
if page == "conditional/ccm":
return []
document, units, readable, valid_units, metric = self._source()
allowed = self.owner.authority("preferences")
repair_allowed = parked and self.owner.authority("parked_preferences")
@@ -163,17 +165,16 @@ class ConditionalFeature:
mode_valid = (mode_readable and mode_document == document and baseline_readable and baseline in (None, b"0", b"1") and
mode_safe_readable and mode_safe in (None, b"0", b"1"))
choice = {"stock": "Experimental" if baseline == b"1" else "Chill",
"conditional_experimental": "Conditional Experimental", "conditional_chill": "Conditional Chill"}[preferences.mode.value]
"conditional_experimental": "Automatic", "conditional_chill": "Automatic"}[preferences.mode.value]
cp = self.owner.vehicle_params()
choices = MODES if choice == "Experimental" or experimental_available(cp) and mode_safe in (None, b"0") else tuple(
mode for mode in MODES if mode != "Experimental")
rows.append(FeatureRow(MODE, "Saved driving mode", choice if mode_valid else "Unavailable", document,
rows.append(FeatureRow(MODE, "Driving Mode", choice if mode_valid else "Unavailable", document,
choices if mode_valid else (), default_value=MODES[0], available=allowed and mode_valid,
reason="Choose Chill, Experimental, or automatic switching from your saved conditions." if allowed and mode_valid else unavailable,
reason="Automatic switches between Chill and Experimental using your saved conditions." if allowed and mode_valid else unavailable,
vehicle_fingerprint=self.owner.vehicle_fingerprint(), capability=_mode_capability(cp),
dependencies=dependencies + (("ExperimentalMode", baseline), ("SafeMode", mode_safe))))
rows.append(FeatureRow("", "Experimental conditions", "Saved options", page="conditional/cem", available=True))
rows.append(FeatureRow("", "Chill conditions", "Saved options", page="conditional/ccm", available=True))
rows.append(FeatureRow("", "Automatic conditions", "Saved options", page="conditional/cem", available=True))
if manual.status in ("invalid", "read_error"):
rows.append(FeatureRow("", "Remembered manual choices", "Invalid" if manual.status == "invalid" else "Unavailable"))
if manual.status == "invalid":
@@ -220,6 +221,8 @@ class ConditionalFeature:
return rows
def apply(self, request: FeatureSettingsRequest) -> bool:
if request.key.startswith(PREFIX + "ccm:"):
return False
if request.key.startswith(BUTTON_PREFIX):
key = request.key.removeprefix(BUTTON_PREFIX)
if key not in (*MEDIA_KEYS, *DISTANCE_KEYS) or not request.vehicle_fingerprint or request.capability is None:
@@ -257,7 +260,7 @@ class ConditionalFeature:
return False
try:
preferences = SavedPreferences() if document is None else decode_preferences(document)
value = "Stock" if request.value in ("Chill", "Experimental") else request.value
value = "Stock" if request.value in ("Chill", "Experimental") else "Conditional Experimental"
raw = edit(preferences, MODE, value, metric=units == b"1")
except PreferenceError:
return False
+2 -1
View File
@@ -24,7 +24,8 @@ def configured_choice(params) -> ModeChoice | None:
raw, readable = read_saved(params, 'ConditionalModeConfig', MAX_DOCUMENT_BYTES)
if not readable:
return None
return ModeChoice.CEM if raw is None else decode_preferences(raw).mode
choice = ModeChoice.CEM if raw is None else decode_preferences(raw).mode
return ModeChoice.CEM if choice is ModeChoice.CCM else choice
except (AttributeError, PreferenceError, OSError, TypeError, ValueError):
return None
@@ -890,7 +890,7 @@ class FeatureSettingsOwner:
FeatureRow("", "Lane Centering", "Adjust lane positioning, lane detection, and steering alerts", page=FeaturePage.LANE, available=True),
FeatureRow("", "Lane Changes", "Configure lane-change speed, automatic timing, and driver nudges", page=FeaturePage.LANE_CHANGE, available=True),
FeatureRow("", "Long Planner", "Tune acceleration, braking, and following distances", page=FeaturePage.PROFILES, available=True),
FeatureRow("", "Conditional Driving Modes", "Choose when to switch between Chill and Experimental", page=FeaturePage.CONDITIONAL, available=True),
FeatureRow("", "Driving Modes", "Choose Automatic, Chill or Experimental", page=FeaturePage.CONDITIONAL, available=True),
FeatureRow("", "Steering and Torque", "Select the steering controller and tune its response", page=FeaturePage.TORQUE, available=True),
FeatureRow("", "Always On Lateral", "Keep steering assistance active independently of cruise control", page=FeaturePage.AOL, available=True),
FeatureRow("", "Wheel Controls", "Assign steering-wheel buttons and cruise behavior", page=FeaturePage.WHEEL, available=True)]
@@ -1038,9 +1038,9 @@ class FeatureSettingsOwner:
if valid and nostalgia in ("0", "1") else
"Choose Off to repair the saved preference"),
capability=capability, repair_value="Off" if nostalgia not in ("0", "1") else ""))
elif page in (FeaturePage.CONDITIONAL, FeaturePage.CONDITIONAL_CEM, FeaturePage.CONDITIONAL_CCM):
title = "Conditional Driving Modes" if page == FeaturePage.CONDITIONAL else \
"Experimental Conditions" if page == FeaturePage.CONDITIONAL_CEM else "Chill Conditions"
elif page in (FeaturePage.CONDITIONAL, FeaturePage.CONDITIONAL_CEM):
title = "Driving Modes" if page == FeaturePage.CONDITIONAL else \
"Automatic Conditions"
rows.extend(self.conditional.rows(page, parked))
elif page == FeaturePage.CURVE:
title = "Curve Speed Controller"
@@ -1389,7 +1389,6 @@ class FeatureSettingsOwner:
if page in (
FeaturePage.CONDITIONAL,
FeaturePage.CONDITIONAL_CEM,
FeaturePage.CONDITIONAL_CCM,
) else
"Changes apply during this drive. Pace and trigger changes wait until the current signal and maneuver end."
if page == FeaturePage.LANE_CHANGE else
@@ -54,7 +54,7 @@ class ConditionalFeatureTests(unittest.TestCase):
vehicle_fingerprint=lambda: getattr(self.cp, "carFingerprint", None),
vehicle_params=lambda: self.cp)
def test_four_saved_modes_round_trip_through_actual_baseline_owner(self):
def test_three_saved_modes_round_trip_through_actual_baseline_owner(self):
original = SavedPreferences(cem=replace(SavedPreferences().cem, speed_mps=13.0))
self.params.put("ConditionalModeConfig", json.loads(encode_preferences(original)), block=True)
manual = encode_manual(SavedCodes())
@@ -65,9 +65,9 @@ class ConditionalFeatureTests(unittest.TestCase):
drive.conditional_replay = False
now = 1_000_000_000
for value, choice, baseline in (("Experimental", ModeChoice.STOCK, True), ("Chill", ModeChoice.STOCK, False),
("Conditional Experimental", ModeChoice.CEM, False), ("Conditional Chill", ModeChoice.CCM, False)):
("Automatic", ModeChoice.CEM, False)):
row = self.row("conditional:mode")
self.assertEqual(row.choices, ("Chill", "Experimental", "Conditional Experimental", "Conditional Chill"))
self.assertEqual(row.choices, ("Automatic", "Chill", "Experimental"))
self.assertTrue(self.owner.apply(replace(required_change(row), value=value)))
self.assertEqual(self.row("conditional:mode").value, value)
saved = decode_preferences(Path(self.params.get_param_path("ConditionalModeConfig")).read_bytes())
@@ -230,13 +230,31 @@ class ConditionalFeatureTests(unittest.TestCase):
self.assertIsNone(self.params.get("ConditionalModeConfig"))
self.assertIn(FeaturePage.CONDITIONAL, [row.page for row in self.rows(FeaturePage.HUB)])
mode = self.row("conditional:mode")
self.assertEqual(mode.value, "Conditional Experimental")
self.assertEqual(mode.value, "Automatic")
self.assertTrue(mode.available)
self.assertTrue(self.owner.apply(required_change(mode)))
saved = decode_preferences(Path(self.params.get_param_path("ConditionalModeConfig")).read_bytes())
self.assertEqual(saved.mode.value, "conditional_chill")
self.assertEqual(saved.mode.value, "stock")
self.assertFalse(saved.cem.persist_manual)
def test_retired_chill_mode_uses_automatic_and_has_no_editable_menu(self):
from openpilot.starpilot.ui.conditional_status import configured_choice
path = Path(self.params.get_param_path("ConditionalModeConfig"))
raw = encode_preferences(replace(SavedPreferences(), mode=ModeChoice.CCM))
path.write_bytes(raw)
self.assertEqual(self.row("conditional:mode").value, "Automatic")
self.assertEqual(configured_choice(self.params), ModeChoice.CEM)
settings = ConditionalSettingsOwner(self.params)
snapshot = settings.refresh(1_000_000_000)
verdict = settings.verdict(snapshot, now_mono_ns=1_000_000_000, drive_id=1)
assert verdict.selection is not None
self.assertEqual(verdict.selection.choice, ModeChoice.CEM)
self.assertFalse(any(row.page == FeaturePage.CONDITIONAL_CCM for row in self.rows()))
self.assertEqual(self.rows(FeaturePage.CONDITIONAL_CCM), ())
retired = FeatureSettingsRequest("conditional:ccm:launch_assist", raw, "On", confirmation=True)
self.assertFalse(self.owner.apply(retired))
self.assertEqual(path.read_bytes(), raw)
def test_chill_label_and_signal_rows_preserve_existing_consumers(self):
path = Path(self.params.get_param_path("ConditionalModeConfig"))
path.write_bytes(stock_document())
@@ -269,7 +287,7 @@ class ConditionalFeatureTests(unittest.TestCase):
threshold = self.row("conditional:cem:speed_mps", FeaturePage.CONDITIONAL_CEM)
self.assertTrue(threshold.available)
self.assertTrue(self.owner.apply(required_change(threshold)))
pending = required_change(self.row("conditional:ccm:launch_assist", FeaturePage.CONDITIONAL_CCM))
pending = required_change(self.row("conditional:cem:open_road", FeaturePage.CONDITIONAL_CEM))
self.parked = False
self.assertFalse(self.owner.apply(pending))
@@ -355,12 +373,12 @@ class ConditionalFeatureTests(unittest.TestCase):
self.assertTrue(self.owner.apply(required_change(speed)))
saved = decode_preferences(Path(self.params.get_param_path("ConditionalModeConfig")).read_bytes())
self.assertAlmostEqual(saved.cem.speed_mps, 1 / 3.6)
stale = required_change(self.row("conditional:ccm:launch_assist", FeaturePage.CONDITIONAL_CCM))
stale = required_change(self.row("conditional:cem:open_road", FeaturePage.CONDITIONAL_CEM))
Path(self.params.get_param_path("ConditionalModeConfig")).write_bytes(b'{"bad":true}')
self.assertFalse(self.owner.apply(stale))
def test_bounds_and_manual_persistence_clears_only_selected_code(self):
row = self.row("conditional:ccm:set_speed_margin_mps", FeaturePage.CONDITIONAL_CCM)
row = self.row("conditional:cem:model_stop_s", FeaturePage.CONDITIONAL_CEM)
forged = FeatureSettingsRequest(row.key, row.source, "100", vehicle_fingerprint=row.vehicle_fingerprint,
capability=row.capability, dependencies=row.dependencies, display_unit=row.display_unit)
self.assertFalse(self.owner.apply(forged))
@@ -454,7 +472,7 @@ class ConditionalFeatureTests(unittest.TestCase):
def test_invalid_manual_bytes_need_explicit_confirmed_reset(self):
manual_path = Path(self.params.get_param_path("ConditionalManualState"))
manual_path.write_bytes(b'{"version":9}')
persist = self.row("conditional:ccm:persist_manual", FeaturePage.CONDITIONAL_CCM)
persist = self.row("conditional:cem:persist_manual", FeaturePage.CONDITIONAL_CEM)
self.assertFalse(persist.available)
reset = self.row("conditional:manual_reset")
request = FeatureSettingsRequest(reset.key, reset.source, "confirm", vehicle_fingerprint=reset.vehicle_fingerprint,
@@ -511,8 +529,7 @@ class ConditionalFeatureTests(unittest.TestCase):
ccm=replace(preferences.ccm, set_speed_margin_mps=30 / 3.6))
path.write_bytes(encode_preferences(preferences))
self.params.put_bool("IsMetric", False, block=True)
for key, page, old in (("conditional:cem:signal_lane_width_m", FeaturePage.LANE_CHANGE, 15.0),
("conditional:ccm:set_speed_margin_mps", FeaturePage.CONDITIONAL_CCM, 30 / 3.6)):
for key, page, old in (("conditional:cem:signal_lane_width_m", FeaturePage.LANE_CHANGE, 15.0),):
row = self.row(key, page)
self.assertGreater(float(row.value), 15.0)
self.assertTrue(self.owner.apply(required_change(row, -1)))
@@ -633,12 +650,12 @@ class ConditionalFeatureTests(unittest.TestCase):
patch.object(compact.gui_app, "get_active_widget", side_effect=lambda: stack[-1]):
adapter = compact.FeatureSettingsCompact(Session(self.owner))
adapter.open(FeaturePage.HUB)
next(card for card in stack[-1].items if card.text == "conditional driving modes").click()
next(card for card in stack[-1].items if card.text == "driving modes").click()
child = stack[-1]
next(card for card in child.items if card.text == "saved driving mode").click()
next(card for card in child.items if card.text == "driving mode").click()
self.assertEqual(decode_preferences(Path(self.params.get_param_path("ConditionalModeConfig")).read_bytes()).mode.value,
"conditional_chill")
next(card for card in child.items if card.text == "experimental conditions").click()
"stock")
next(card for card in child.items if card.text == "automatic conditions").click()
self.assertTrue(any(card.text.startswith("speed threshold") for card in stack[-1].items))
stack.pop()
Path(self.params.get_param_path("ConditionalModeConfig")).write_bytes(b'{"version":2}')
@@ -669,10 +686,10 @@ class ConditionalFeatureTests(unittest.TestCase):
patch.object(large.clip, "begin_scissor_mode"), \
patch.object(large.clip, "end_scissor_mode"):
large.FeatureSettingsView(Mock(spec=BitmapFonts, **vars(fonts))).render(state)
self.assertIn("Conditional Driving Modes", labels)
self.assertIn("Saved driving mode", labels)
self.assertIn("Experimental conditions", labels)
self.assertIn("Chill conditions", labels)
self.assertIn("Driving Modes", labels)
self.assertIn("Driving Mode", labels)
self.assertIn("Automatic conditions", labels)
self.assertNotIn("Chill conditions", labels)
def test_large_manual_reset_confirmation_revoked_on_navigation(self):
from openpilot.starpilot.ui.runtime_app import StarShellSession
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-de2df523-Pf38f504f-DEBUG";
const uint8_t gitversion[29] = "DEV-94538a3d-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-de2df523-Pf38f504f-DEBUG
DEV-94538a3d-Pf38f504f-DEBUG
+1 -1
View File
@@ -1 +1 @@
{"protected_inventory_sha256": "c5470046602bb69af744b8534e12e5b010cc4a55abfda60770e3724d0e1a819d", "schema_version": 1}
{"protected_inventory_sha256": "4cce0ee0d8ac19c947fbb94958e46fbbffbc03abcf8f4e2f6d7d03567e0c8e3a", "schema_version": 1}