incorporate advanced setting levels

This commit is contained in:
Prabhaav Pillai
2026-11-26 00:07:36 -05:00
parent 3ca28e6f24
commit c33241ba7e
15 changed files with 109 additions and 80 deletions
@@ -6,7 +6,7 @@ from openpilot.starpilot.ui.calibration_reset import calibration_reset
from openpilot.starpilot.saved_document import commit_exact
from openpilot.starpilot.saved_source import read_saved
from openpilot.starpilot.system.starport import head_unit_fixes
from openpilot.starpilot.ui.feature_settings_state import FeatureRow, FeatureSettingsState
from openpilot.starpilot.ui.feature_settings_state import FeatureRow, FeatureSettingsState, SettingLevel
STARPORT_WIFI_KEY = "StarPortDedicatedWifi"
@@ -119,13 +119,13 @@ class DeviceSettingsOwner:
row = FeatureRow(KEY, "Use VOACC", ("On" if raw == b"1" else "Off") if valid else "Invalid saved value",
raw, ("Off", "On") if valid else (), available=parked and valid,
reason=(DESCRIPTION if parked else "Park the vehicle to change this setting.") if valid else
"Invalid saved value", default_value="Off")
"Invalid saved value", default_value="Off", level=SettingLevel.ADVANCED)
hold_raw, hold_readable = read_saved(self.params, HOLD_KEY, 8)
hold_valid = hold_readable and hold_raw in (None, b"0", b"1")
hold_row = FeatureRow(HOLD_KEY, HOLD_LABEL, ("On" if hold_raw == b"1" else "Off") if hold_valid else "Invalid saved value",
hold_raw, ("Off", "On") if hold_valid else (), available=parked and hold_valid,
reason=(HOLD_DESCRIPTION if parked else "Park the vehicle to change this setting.") if hold_valid else
"Invalid saved value", default_value="Off")
"Invalid saved value", default_value="Off", level=SettingLevel.ADVANCED)
return row, hold_row
def _reset_rows(self):
@@ -155,21 +155,19 @@ assert.match(SettingsPage.template, /Adjust acceleration, braking and following
assert.match(SettingsPage.template, /Tune low-speed following and jerk, blending toward Relaxed at higher speeds\./)
const app = (await import('node:fs')).readFileSync(new URL('../web/js/app.js', import.meta.url), 'utf8')
assert.match(app, /:initial-panel="route\.path === '\/appearance' \? 'display' : 'widgets'"/)
const filtered = SettingsPage.computed.visibleRows.call({ state: { query: "lane", data: { rows: [
const pageRows = SettingsPage.computed.visibleRows.call({ state: { data: { rows: [
{ label: "SLC", value: "Off", reason: "" }, { label: "Lane Centering", value: "On", reason: "" },
] } } })
assert.deepEqual(filtered.map(({ index }) => index), [1]) // Filter keeps the original owner row index.
assert.deepEqual(pageRows.map(({ index }) => index), [0, 1]) // Keep the original owner row indices.
const developerRows = [{ label: "Use VOACC", value: "Off", reason: "" }, { label: "StarPort", value: "", reason: "", heading: true },
{ label: "Stay on Wi-Fi", value: "On", reason: "" }, { label: "Allow H.265 video", value: "Off", reason: "" }]
const cardsFor = (query) => {
const view = { state: { query, data: { rows: developerRows } }, initialPage: "developer", activeSection: {} }
const cardsFor = () => {
const view = { state: { data: { rows: developerRows } }, initialPage: "developer", activeSection: {} }
view.visibleRows = SettingsPage.computed.visibleRows.call(view)
return SettingsPage.computed.rowCards.call(view).map(({ title, entries }) => [title, entries.map(({ index }) => index)])
}
assert.deepEqual(cardsFor(""), [["", [0]], ["StarPort", [2, 3]]], "a heading row starts its own card")
assert.deepEqual(cardsFor("h.265"), [["", []], ["StarPort", [3]]], "search keeps a row in its card when the heading is filtered out")
assert.deepEqual(cardsFor("voacc"), [["", [0]]], "an emptied card is not shown")
assert.deepEqual(cardsFor(), [["", [0]], ["StarPort", [2, 3]]], "a heading row starts its own card")
const experimentRows = [{ label: "Stay on Wi-Fi", value: "On", reason: "" }, { key: "heading:experiments", label: "Specific car experiments", value: "", reason: "", heading: true, collapsed: true },
{ label: "Try experimental fixes", value: "Off", reason: "" }]
@@ -180,7 +178,6 @@ const experimentCards = (state) => {
}
assert.deepEqual(experimentCards({ openCards: [] }), [["", true], ["Specific car experiments", false]], "a collapsible group starts closed")
assert.deepEqual(experimentCards({ openCards: ["heading:experiments"] }), [["", true], ["Specific car experiments", true]])
assert.deepEqual(experimentCards({ openCards: [], query: "experimental" }).at(-1), ["Specific car experiments", true], "searching opens a matching group")
const toggled = { state: { openCards: [] } }
SettingsPage.methods.toggleCard.call(toggled, "heading:experiments")
assert.deepEqual(toggled.state.openCards, ["heading:experiments"])
@@ -1,7 +1,5 @@
/* Settings controls adapted from the current StarPilot Vue Galaxy. */
.gx-settings__header .gx-note { margin: var(--sp-2) 0 0; }
.gx-settings__search { padding: var(--sp-3) var(--sp-4) 0; }
.gx-settings__search .gx-field { width: 100%; }
.gx-settings__section .gx-section__header .gx-icon-btn { flex: none; height: 40px; min-height: 40px; width: 40px; min-width: 40px; }
.gx-settings__section .gx-section__header .gx-icon-btn:hover { background: var(--glass-bg-hover); }
.gx-settings__body, .gx-settings-tabs { animation: gx-fade-in var(--motion-base) ease-out; }
+8 -20
View File
@@ -325,8 +325,8 @@ export const SettingsPage = {
const navigation = route.view
const navigationKey = `${props.initialPage}:${props.initialSection || ""}`
const saved = navigation.settings?.key === navigationKey ? navigation.settings : null
const state = reactive({ status: "idle", data: null, pending: null, error: "", modeError: "", query: "", searchOpen: false, section: props.initialSection || "lateral", layoutOpen: false, layoutPanel: "widgets", favoritesOpen: false, soundChoicesDirty: false, testingSound: false, openCards: [], parents: [], panelDirection: 1, settingsPreference, pageLevels: {} })
if (saved) Object.assign(state, { section: saved.section, query: saved.query, searchOpen: saved.searchOpen, parents: saved.parents.slice() })
const state = reactive({ status: "idle", data: null, pending: null, error: "", modeError: "", section: props.initialSection || "lateral", layoutOpen: false, layoutPanel: "widgets", favoritesOpen: false, soundChoicesDirty: false, testingSound: false, openCards: [], parents: [], panelDirection: 1, settingsPreference, pageLevels: {} })
if (saved) Object.assign(state, { section: saved.section, parents: saved.parents.slice() })
const feed = new SettingsFeed({ publish: (update) => Object.assign(state, update), unauthorized: props.unauthorized })
return { state, feed, sections: SETTINGS_SECTIONS, navigation, navigationKey, restoredPage: saved?.page }
},
@@ -352,7 +352,6 @@ export const SettingsPage = {
(this.activeSection.pages.length === 1 && this.state.data?.page === this.activeSection.pages[0])
},
visibleRows() {
const needle = this.state.query.trim().toLocaleLowerCase()
const rows = this.state.data?.rows || []
const inHub = this.initialPage === "hub" && this.state.data?.page === "hub"
const section = this.activeSection
@@ -372,10 +371,9 @@ export const SettingsPage = {
const previous = rows[index - 1]
return !(["sounds", "display"].includes(this.state.data?.page) && row.repairValue === "Auto" &&
previous?.choices?.includes("Auto") && settingControl(previous) === "slider" && row.label === `Use Auto ${previous.label}`)
}).filter(({ row }) =>
!needle || `${row.label} ${row.value} ${row.reason}`.toLocaleLowerCase().includes(needle))
})
},
// A heading row starts its own card; the rows after it belong to that card even when search hides the heading.
// A heading row starts its own card; the rows after it belong to that card.
rowCards() {
const heads = []
const owner = (this.state.data?.rows || []).map((row) => {
@@ -384,7 +382,7 @@ export const SettingsPage = {
})
const cards = [{ title: "", key: "main", entries: [], collapsible: false, open: true }, ...heads.map(({ title, key, collapsible }) => ({ title, key, entries: [], collapsible, open: !collapsible }))]
for (const entry of this.visibleRows) if (!entry.row.heading) cards[owner[entry.index] || 0].entries.push(entry)
for (const card of cards) if (card.collapsible) card.open = !!this.state.query || this.state.openCards.includes(card.key)
for (const card of cards) if (card.collapsible) card.open = this.state.openCards.includes(card.key)
return cards.filter((card, index) => !index || card.entries.length)
},
},
@@ -411,9 +409,9 @@ export const SettingsPage = {
if (this.feed.active && this.navigation.scroll) window.scrollTo(this.navigation.scroll.x, this.navigation.scroll.y)
},
beforeUnmount() {
const { data, section, query, searchOpen, parents } = this.state
const { data, section, parents } = this.state
this.navigation.settings = {
key: this.navigationKey, page: data?.page || this.restoredPage || this.initialPage, section, query, searchOpen, parents: parents.slice(),
key: this.navigationKey, page: data?.page || this.restoredPage || this.initialPage, section, parents: parents.slice(),
}
this.navigation.searchPage = this.initialPage === "hub" ? "" : this.initialPage
this.feed.stop()
@@ -459,7 +457,6 @@ export const SettingsPage = {
open(page) {
if (this.busy) return
this.$emit?.("nested")
this.state.query = ""
this.state.panelDirection = 1
if (page === "ui_layout" || page === "appearance") {
this.feed.stop()
@@ -478,11 +475,6 @@ export const SettingsPage = {
if (at < 0) open.push(title)
else open.splice(at, 1)
},
togglePageSearch() {
this.state.searchOpen = !this.state.searchOpen
if (this.state.searchOpen) this.$nextTick(() => this.$refs.pageSearch?.focus())
else this.state.query = ""
},
async openCropEditor() { (await import("./router.js")).navigate("/cameras/pip") },
// The embedded editor switches targets through the routed editor, which keeps the leave guard.
async openLayoutTarget(target) { (await import("./router.js")).navigate(target === "projection" ? "/theme_maker/starport" : "/theme_maker") },
@@ -499,7 +491,6 @@ export const SettingsPage = {
this.state.parents = []
this.state.section = section.id
if (!this.feed.active) { this.feed.start(section.pages.length === 1 ? section.pages[0] : "hub"); return }
this.state.query = ""
const page = section.pages.length === 1 ? section.pages[0] : "hub"
if (this.state.data?.page !== page) this.feed.load(page, { keepData: false, quiet: false })
},
@@ -524,7 +515,6 @@ export const SettingsPage = {
this.state.panelDirection = -1
const page = this.state.data?.page || this.initialPage
this.state.section = this.activeSection?.id || this.state.section
this.state.query = ""
if (page === this.initialPage && this.returnTo) { this.returnTo(); return }
const parent = this.state.parents?.pop()
if (parent) { this.feed.load(parent); return }
@@ -596,15 +586,13 @@ export const SettingsPage = {
</div>
<SettingsMode v-if="mode === 'local' && showPreferences && initialPage === 'hub' && !atSectionRoot" :advanced="advancedMode" :saving="state.settingsPreference.saving" @change="setSettingsMode" />
<WikiHelp v-if="title && initialPage === 'hub' && !atSectionRoot" :page="state.data.page" />
<button v-if="state.data.page !== 'hub' && state.data.rows.length" type="button" class="gx-icon-btn" :aria-label="state.searchOpen ? 'Close page search' : 'Search within this page'" :aria-pressed="state.searchOpen" @click="togglePageSearch"><i class="bi" :class="state.searchOpen ? 'bi-x-lg' : 'bi-search'" aria-hidden="true"></i></button>
</div>
<div v-if="state.searchOpen && !cardIndex" class="gx-settings__search"><input ref="pageSearch" v-model="state.query" class="gx-field" type="search" aria-label="Search within this page" placeholder="Search within…"></div>
<GxCollapse><div v-if="card.open">
<GxCollapse v-for="{ row, index, visible } in card.entries" :key="rowKey(row, index)"><div v-show="visible" :inert="!visible"><GalaxySettingRow :row="row" :index="index"
:busy="busy" :disabled="!!state.error || !row.available" :save-value="(index, value) => feed.previewValue(index, value)" :test-alert="state.data.page === 'sounds' ? testAlert : null"
@open="open" @review="(index, direction) => feed.preview(index, direction)" @reset-default="index => feed.resetDefault(index)" /></div></GxCollapse>
</div></GxCollapse>
<div v-if="!cardIndex && !visibleRows.length" class="gx-empty"><template v-if="state.data.page === 'starport_options' && !state.query">Turn on StarPort to manage connection options. <a class="gx-link" href="#/starport">Open StarPort setup</a></template><template v-else>No matching settings.</template></div>
<div v-if="!cardIndex && !visibleRows.length" class="gx-empty"><template v-if="state.data.page === 'starport_options'">Turn on StarPort to manage connection options. <a class="gx-link" href="#/starport">Open StarPort setup</a></template><template v-else>No matching settings.</template></div>
</section></GxCollapse>
<GxCollapse><div v-if="state.data.page === 'sounds'" v-show="categoryVisible" :inert="!categoryVisible"><SoundPacks :unauthorized="unauthorized" :busy="busy" @installed="refreshSoundChoices" /></div></GxCollapse>
</template>
+2 -1
View File
@@ -10,7 +10,7 @@ from openpilot.starpilot.saved_source import read_saved
from openpilot.starpilot.ui.onroad_customization import MAX_BYTES, PARAM_KEY, decode_document, default_document
from openpilot.starpilot.ui.appearance_preferences import (CAMERA_LABELS, DEFAULTS, LEAD_INFO_LABELS, MAX_RAW_BYTES,
RETIRED_DISPLAY_KEYS, read_camera_view, read_lead_info, read_visibility)
from openpilot.starpilot.ui.feature_settings_state import FeatureRow, FeatureSettingsRequest, FeatureSettingsState
from openpilot.starpilot.ui.feature_settings_state import FeatureRow, FeatureSettingsRequest, FeatureSettingsState, SettingLevel
from openpilot.starpilot.ui.presentation import Profile
@@ -112,6 +112,7 @@ class AppearanceOwner:
row = FeatureRow("SpeedDisplayOffset", "Speed display adjustment", value, source=raw,
step=0.1, minimum=-5., maximum=5., unit="%", default_value="0",
available=self.parked() and valid,
level=SettingLevel.ADVANCED,
reason=("0% leaves the display unchanged. Lower if the comma reads too high; raise if it reads too low. " +
"Only changes displayed vehicle speed, not cruise speed or vehicle control.") if valid else
"Repair the saved driving-screen layout first.")
@@ -22,7 +22,7 @@ from openpilot.starpilot.conditional_mode.manual_saved import KEY as MANUAL_KEY,
from openpilot.starpilot.conditional_mode.preferences import encode_preferences
from openpilot.starpilot.conditional_mode.runtime_settings import experimental_available, read_mode_sources
from openpilot.starpilot.conditional_mode.policy import ModeChoice
from openpilot.starpilot.ui.feature_settings_state import FeatureRow, FeatureSettingsRequest
from openpilot.starpilot.ui.feature_settings_state import SettingLevel, FeatureRow, FeatureSettingsRequest
LABELS = {
@@ -217,7 +217,7 @@ class ConditionalFeature:
unit=unit if valid_units else "",
available=allowed and valid_units, reason=SIGNAL_LANE_HELP.get(name, "") if allowed and valid_units else
"Invalid saved units" if not valid_units else unavailable,
dependencies=dependencies, display_unit=unit if valid_units else ""))
dependencies=dependencies, display_unit=unit if valid_units else "", level=SettingLevel.ADVANCED))
return rows
def apply(self, request: FeatureSettingsRequest) -> bool:
+4 -4
View File
@@ -17,7 +17,7 @@ from openpilot.starpilot.saved_source import read_saved
from openpilot.starpilot.lateral.lane_change_preferences import (
KEY as LANE_CHANGE_KEY, MAX_BYTES as LANE_CHANGE_LIMIT, LaneChangePolicy, decode as decode_lane_change, to_value,
)
from openpilot.starpilot.ui.feature_settings_state import FeatureRow, FeatureSettingsRequest
from openpilot.starpilot.ui.feature_settings_state import SettingLevel, FeatureRow, FeatureSettingsRequest
CHOICES = ('Stock Controller', 'StarPilot Controller')
@@ -152,7 +152,7 @@ class ControllerFeature:
'Turn off to restore your previous tune.' if not conflict and (not active or complete) else
'Preparation was interrupted. Turn off to restore your previous tune.' if not conflict else
'Turn off to restore previous settings while keeping changes made after preparation.'),
capability=capability, dependencies=tuple((key, raw) for key, raw in (sources or {}).items()))
capability=capability, dependencies=tuple((key, raw) for key, raw in (sources or {}).items()), level=SettingLevel.ADVANCED)
def apply_setup(self, request: FeatureSettingsRequest) -> bool:
from openpilot.starpilot.ui.tuning_preparation import transition
@@ -194,7 +194,7 @@ class ControllerFeature:
return FeatureRow(DOCUMENT_KEY, 'Steering Controller', value, raw, choices if valid else (),
available=allowed, reason=reason, capability=capability,
dependencies=((LEARNING_OFF_KEY, learning), (LEARNING_PREFERENCES_KEY, preference.raw)),
default_value=CHOICES[0] if selection_from_bytes(CP, None).mode == ControllerMode.STANDARD else CHOICES[1])
default_value=CHOICES[0] if selection_from_bytes(CP, None).mode == ControllerMode.STANDARD else CHOICES[1], level=SettingLevel.ADVANCED)
def learning_row(self, CP=None) -> FeatureRow | None:
CP = self.vehicle_params() if CP is None else CP
@@ -212,7 +212,7 @@ class ControllerFeature:
available=valid and self.authority('preferences'),
reason=reason if valid else 'Saved controller or learning preference is unreadable or invalid.',
capability=capability, dependencies=((DOCUMENT_KEY, controller), (LEARNING_OFF_KEY, legacy)),
default_value="On")
default_value="On", level=SettingLevel.ADVANCED)
def apply_learning(self, request: FeatureSettingsRequest) -> bool:
CP = self.vehicle_params()
@@ -41,7 +41,7 @@ from openpilot.starpilot.ui.feature_defaults import (AGGRESSIVE_COOLING_DESCRIPT
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, SLC_CONFIRM_ACTIONS, SLC_OFFSET_KEYS, TORQUE_CONFIRM_ACTIONS,
FeaturePage, FeatureRow, FeatureSettingsRequest, FeatureSettingsState, SettingLevel, SLC_CONFIRM_ACTIONS, SLC_OFFSET_KEYS, TORQUE_CONFIRM_ACTIONS,
)
from openpilot.starpilot.speed_limits.offset_document import MPH_TO_MPS
from openpilot.starpilot.speed_limits.runtime_settings import (
@@ -218,7 +218,7 @@ class FeatureSettingsOwner:
('Off', 'On') if valid else (), default_value='Off', capability=capability, vehicle_fingerprint=self.vehicle_fingerprint(),
available=valid and parked and self.authority('parked_preferences') and self.authority('preferences'),
reason='Let StarPilot control acceleration and braking instead of factory ACC. ' +
'Takes effect next drive. May disable factory Automatic Emergency Braking.'),)
'Takes effect next drive. May disable factory Automatic Emergency Braking.', level=SettingLevel.ADVANCED),)
def _apply_alpha_long(self, request):
from openpilot.starpilot.saved_document import commit_exact
@@ -636,15 +636,16 @@ class FeatureSettingsOwner:
except (OSError, ValueError, UnknownKeyName):
return "invalid saved value", b"", False
def _bool_row(self, key: str, label: str, allowed: bool, reason: str = "") -> FeatureRow:
def _bool_row(self, key: str, label: str, allowed: bool, reason: str = "", *, level: SettingLevel | None = None) -> FeatureRow:
value, raw, valid = self._value(key)
return FeatureRow(key, label, value if value not in ("0", "1") else ("On" if value == "1" else "Off"), raw,
("Off", "On") if valid and value in ("0", "1") else (), available=allowed and valid and value in ("0", "1"),
default_value="On" if self._default(key) == "1" else "Off",
level=level, default_value="On" if self._default(key) == "1" else "Off",
reason="Invalid saved value" if not valid or value not in ("0", "1") else
reason if allowed else "Unavailable with the current vehicle or feature settings")
def _number_row(self, key: str, label: str, allowed: bool, *, scale: float = 1.0, unit: str | None = None) -> FeatureRow:
def _number_row(self, key: str, label: str, allowed: bool, *, scale: float = 1.0, unit: str | None = None,
level: SettingLevel | None = None) -> FeatureRow:
low, high, step, stored_unit = FLOAT_SPECS[key]
value, raw, valid = self._value(key)
try:
@@ -661,7 +662,7 @@ class FeatureSettingsOwner:
return FeatureRow(key, label, str(round(number * scale, 3)) if valid else f"Saved {value}", raw,
step=step * scale if valid else 0.0, minimum=low * scale, maximum=high * scale,
unit=unit or stored_unit, available=allowed and valid,
default_value=default_value,
default_value=default_value, level=level,
reason="Invalid saved value" if not valid else "" if allowed else "Unavailable with the current vehicle or feature settings")
def _with_default(self, row: FeatureRow) -> FeatureRow:
@@ -809,7 +810,8 @@ class FeatureSettingsOwner:
available=allowed and (valid or self.authority("parked_preferences") and self._readable(KEY)),
repair_value="0" if not valid else "", default_value="0",
vehicle_fingerprint=self.vehicle_fingerprint(), capability=capability,
reason="Reduces small steering corrections on highways above about 40 mph. 0% is off; higher values add more smoothing.")
reason="Reduces small steering corrections on highways above about 40 mph. 0% is off; higher values add more smoothing.",
level=SettingLevel.ADVANCED)
def _apply_highway_smoothing(self, request: FeatureSettingsRequest) -> bool:
from openpilot.selfdrive.controls.lib.highway_correction_gain import KEY, MAX_SETTING, MIN_SETTING
@@ -849,6 +851,7 @@ class FeatureSettingsOwner:
configurable = parked or configure_while_driving
title = {FeaturePage.HUB: "Driving Controls", FeaturePage.LANE: "Lane Centering"}.get(page, page.replace("_", " ").title())
rows: list[FeatureRow] = []
level = SettingLevel.SIMPLE
if page == "data":
title = "Data Uploads"
rows = [self._bool_row("AlwaysAllowUploads", "Always Allow Uploads", self.authority("preferences"),
@@ -888,6 +891,7 @@ class FeatureSettingsOwner:
rows.append(FeatureRow("", "Driving Personalities", "Adjust Aggressive, Standard, Relaxed and Traffic profiles",
page=FeaturePage.PERSONALITIES, available=True))
elif page == FeaturePage.PERSONALITIES:
level = SettingLevel.ADVANCED
title = "Driving Personalities"
rows = [FeatureRow("", name.title() + " Personality", "", page=name, available=True)
for name in (*PROFILE_NAMES, "traffic")]
@@ -952,7 +956,7 @@ class FeatureSettingsOwner:
row = self._bool_row("DisableOpenpilotLongitudinal", "Use Factory ACC" if toyota_factory_acc else "Disable StarPilot Speed Control",
parked and self.authority("parked_preferences"),
"Turn this on to use your car's factory adaptive cruise instead of StarPilot's" if toyota_factory_acc else
"StarPilot does not control speed in this mode. Steering remains available after the next startup")
"StarPilot does not control speed in this mode. Steering remains available after the next startup", level=SettingLevel.ADVANCED)
if self._vw_alpha_off():
row = replace(row, value="On", available=False,
reason="Speed control is off in driving settings. Enable Alpha Longitudinal there to restore it")
@@ -999,7 +1003,7 @@ class FeatureSettingsOwner:
pitch_capability = self._long_pitch_capability()
if pitch_capability is not None:
row = self._bool_row("LongPitch", "Grade Compensation", configurable and self.authority("preferences"),
"Compensates acceleration and braking for road grade. Refreshes during the drive.")
"Compensates acceleration and braking for road grade. Refreshes during the drive.", level=SettingLevel.ADVANCED)
rows.append(replace(row, available=row.available and self._readable("LongPitch"), capability=pitch_capability))
cp = self.vehicle_params()
policy = self.aol_settings_policy(cp)
@@ -1065,6 +1069,7 @@ class FeatureSettingsOwner:
rows.extend(FordBluePilotFeature(self).rows(parked, options=True))
rows.extend(FordClusterFeature(self).rows(parked))
elif page == FeaturePage.TUNING:
level = SettingLevel.ADVANCED
title = "Manual steering tune"
capability = self._capability("torque")
rows.extend(self.torque.manual_rows(capability, parked and self.authority("torque") and
@@ -1089,10 +1094,12 @@ class FeatureSettingsOwner:
if learning_row is not None:
rows.append(learning_row)
elif page == FeaturePage.DEVELOPER_LONGITUDINAL:
level = SettingLevel.ADVANCED
from openpilot.starpilot.ui.longitudinal_developer import rows as longitudinal_developer_rows
title = "Developer Parameters"
rows.extend(longitudinal_developer_rows(self))
elif page == FeaturePage.DEVELOPER_LATERAL:
level = SettingLevel.ADVANCED
title = 'Developer Parameters'
controller_row = self.controller.row()
if controller_row is not None:
@@ -1215,11 +1222,11 @@ class FeatureSettingsOwner:
replace(self._bool_row("LaneCenteringPauseOnSignal", "Pause on signal", allowed and lane_enabled == "1"),
default_reset_available=allowed and parked and self._value("LaneCenteringPauseOnSignal")[2] and
self._value("LaneCenteringPauseOnSignal")[0] in ("0", "1")),
self._number_row("LaneCenterOffset", "Lane offset", allowed),
replace(self._number_row("LaneCenteringE2EAuthority", "Model path preference", allowed, scale=100, unit="%"),
self._number_row("LaneCenterOffset", "Lane offset", allowed, level=SettingLevel.ADVANCED),
replace(self._number_row("LaneCenteringE2EAuthority", "Model path preference", allowed, scale=100, unit="%", level=SettingLevel.ADVANCED),
reason="Higher values let a confident model path reduce lane-centering correction when it differs from the lane center")))
strength_row = self._number_row("LaneCenteringStrength", "Lane Centering Strength",
allowed and strength_supported, scale=100 / STRENGTH_BASELINE, unit="%")
allowed and strength_supported, scale=100 / STRENGTH_BASELINE, unit="%", level=SettingLevel.ADVANCED)
rows.append(replace(strength_row,
value=str(round(float(strength_row.value))) if strength_row.step > 0 else strength_row.value,
default_value=str(round(float(strength_row.default_value))) if strength_row.default_value is not None else None,
@@ -1233,7 +1240,8 @@ class FeatureSettingsOwner:
elif page == FeaturePage.PROFILES:
title = "Long Planner"
rows.append(self._bool_row(PLANNER_SELECTION_KEY, "Use StarPilot Longitudinal Planner", self.authority("preferences"),
reason="Off uses the upstream planner. Supported longitudinal control stays active. Changes apply on the next drive."))
reason="Off uses the upstream planner. Supported longitudinal control stays active. Changes apply on the next drive.",
level=SettingLevel.ADVANCED))
allowed = configurable and system_long
force_enabled, _, _ = self._value("ForceStops")
rows.append(self._bool_row(
@@ -1257,7 +1265,7 @@ class FeatureSettingsOwner:
"Lets gravity carry the car above set speed without targeting a higher speed. Changes apply while driving.")
rows.append(downhill)
if downhill.value == "On":
rows.append(self._number_row(SURPLUS_KEY, "Maximum Speed Above Set Speed", downhill_allowed))
rows.append(self._number_row(SURPLUS_KEY, "Maximum Speed Above Set Speed", downhill_allowed, level=SettingLevel.ADVANCED))
rows.append(self._bool_row(LOW_SPEED_CRUISE_ON_SET, "Low-Speed Cruise Start", self.authority("preferences"),
reason="Lets StarPilot SET at your current speed down to the vehicle’s minimum engagement speed. " +
"Factory cruise still uses the car’s minimum speed."))
@@ -1286,11 +1294,12 @@ class FeatureSettingsOwner:
step=0.1 if unit_value == "1" else 0.5, minimum=0., maximum=round(MAX_EXTRA_STOPPED_GAP_M * scale, 3),
unit="m" if unit_value == "1" else "ft", available=allowed and valid and unit_valid,
dependencies=(("IsMetric", unit_raw),), display_unit="m" if unit_value == "1" else "ft",
default_value="0", reason="Adds space behind slow or stopped leads with the StarPilot planner; zero keeps the normal gap."))
default_value="0", reason="Adds space behind slow or stopped leads with the StarPilot planner; zero keeps the normal gap.",
level=SettingLevel.ADVANCED))
health = read_profile_health(self.params)
master = health.values["CustomPersonalities"]
master_row = self._bool_row("CustomPersonalities", "Custom Following and Jerk",
allowed and (health.dependencies_valid or master.value is True))
allowed and (health.dependencies_valid or master.value is True), level=SettingLevel.ADVANCED)
reason = ("Invalid saved profile settings; restore defaults below" if not health.dependencies_valid else
"Enables saved following and jerk settings, plus preserved legacy curves. New acceleration/deceleration selections apply independently.")
rows.append(replace(master_row, related_source=raw, dependencies=self.long_profiles.dependencies(health),
@@ -1300,13 +1309,14 @@ class FeatureSettingsOwner:
rows.append(FeatureRow("long_repair:CustomPersonalities", "Restore saved profiles switch to Off",
"Invalid saved switch", master.raw,
available=parked and allowed and master.readable and self.long_profiles.capability() is not None,
capability=self.long_profiles.capability(), dependencies=self.long_profiles.dependencies(health)))
capability=self.long_profiles.capability(), dependencies=self.long_profiles.dependencies(health), level=SettingLevel.ADVANCED))
if not valid:
rows.append(FeatureRow("reset_profiles", "Invalid profile document", "", raw,
available=parked and allowed and health.values[PERSONALITY_PROFILES_PARAM].readable,
reason="Resets saved curves and presets" if health.values[PERSONALITY_PROFILES_PARAM].readable else
"Saved document unreadable or too large"))
"Saved document unreadable or too large", level=SettingLevel.ADVANCED))
elif page == FeaturePage.TRAFFIC:
level = SettingLevel.ADVANCED
title = "Traffic Profile"
rows.extend(self.traffic_profiles.rows(configurable, system_long, repair_allowed=parked))
for category in PRESETS:
@@ -1314,6 +1324,7 @@ class FeatureSettingsOwner:
rows.extend(self.snapshot(f"traffic/{category}", parked=parked, system_long=system_long, lateral_context=lateral_context, metric=False,
configure_while_driving=configure_while_driving).rows)
elif page in PROFILE_NAMES:
level = SettingLevel.ADVANCED
allowed = configurable and system_long
name = page.title()
health = read_profile_health(self.params)
@@ -1335,6 +1346,7 @@ class FeatureSettingsOwner:
elif "/" in page:
name, category = page.split("/", 1)
if name in DOCUMENT_PROFILE_NAMES and category in PRESETS:
level = SettingLevel.ADVANCED
title = f"{name.title()} {category.title()}"
document, raw, valid = self._document()
seed_from_named_acceleration = (name in PROFILE_NAMES and category == "acceleration" and valid and
@@ -1403,7 +1415,7 @@ class FeatureSettingsOwner:
if page == FeaturePage.LANE_CHANGE else
"Adjust these preferences for your vehicle."
)
return FeatureSettingsState(page, title, subtitle, tuple(self._with_default(row) for row in rows), parked)
return FeatureSettingsState(page, title, subtitle, tuple(self._with_default(row) for row in rows), parked, level=level)
def apply(self, request: FeatureSettingsRequest, *, reset_default: bool = False) -> bool:
if reset_default and not self.authority("parked_preferences"):
@@ -14,7 +14,7 @@ from openpilot.starpilot.saved_source import read_saved
from openpilot.starpilot.car.ford.controller_selection import (KEY as MODE, CHOICES as CONTROLLERS,
default_controller, read_controller, encoded_choice)
from openpilot.starpilot.saved_document import commit_exact
from openpilot.starpilot.ui.feature_settings_state import FeaturePage, FeatureRow
from openpilot.starpilot.ui.feature_settings_state import SettingLevel, FeaturePage, FeatureRow
MANIFEST = {setting.key: setting for setting in SETTINGS}
PINION = "FordPrefSteerAngleCurvature"
@@ -117,7 +117,7 @@ class FordBluePilotFeature:
available=parked_ok and readable and safe_off, capability=capability,
dependencies=dependencies or (), default_value=labels[int(default)],
repair_value="" if number is not None else labels[int(default)],
reason="Safe Mode must be off" if not safe_off else "" if parked else "Change while parked")
reason="Safe Mode must be off" if not safe_off else "" if parked else "Change while parked", level=SettingLevel.ADVANCED)
tuning = TUNING_BY_KEY[key]
if tuning.mode != self.mode():
@@ -130,7 +130,7 @@ class FordBluePilotFeature:
shown = SWITCH[int(default)]
return FeatureRow(key, tuning.label, SWITCH[int(number)] if number is not None else "Invalid saved value", raw,
choices=SWITCH, available=available, capability=capability, dependencies=dependencies or (),
default_value=shown, repair_value="" if number is not None else shown, reason=reason)
default_value=shown, repair_value="" if number is not None else shown, reason=reason, level=SettingLevel.ADVANCED)
bounds = MANIFEST[key].range
assert bounds is not None
low, high = bounds
@@ -138,7 +138,7 @@ class FordBluePilotFeature:
return FeatureRow(key, tuning.label, str(round(number, 4)) if number is not None else "Invalid saved value", raw,
step=tuning.step if number is not None else 0.0, minimum=low, maximum=high, available=available,
capability=capability, dependencies=dependencies or (), default_value=shown,
repair_value="" if number is not None else shown, reason=reason)
repair_value="" if number is not None else shown, reason=reason, level=SettingLevel.ADVANCED)
def default(self, key):
"""Vehicle-specific controller defaults and the library defaults for its own tuning settings."""
+5 -4
View File
@@ -1,7 +1,7 @@
from opendbc.car.gm.long_tune import CONFIGURABLE_ACC_TUNE_CARS, VOLT_TUNE_CARS, tune_options
from openpilot.starpilot.car.gm.tune_preferences import KEY, CHOICES, read_choice
from openpilot.starpilot.saved_document import commit_exact
from openpilot.starpilot.ui.feature_settings_state import FeatureRow
from openpilot.starpilot.ui.feature_settings_state import SettingLevel, FeatureRow
class GmTuneFeature:
@@ -45,7 +45,7 @@ class GmTuneFeature:
return (FeatureRow(KEY, "Speed Control Tune", CHOICES[value] if valid else "Invalid saved choice", raw,
choices=tuple(CHOICES[v] for v in options), available=parked and self.owner.authority("parked_preferences") and readable,
capability=capability, repair_value="" if applicable else CHOICES[0], default_value=CHOICES[0],
reason=reason + timing),)
reason=reason + timing, level=SettingLevel.ADVANCED),)
def apply(self, request):
value = next((code for code, label in CHOICES.items() if label == request.value), None)
@@ -89,7 +89,8 @@ class GmTruckFeature:
return (FeatureRow(TRUCK_KEY, "Truck Speed Control", ("On" if enabled else "Off") if valid else "Invalid saved choice", raw,
choices=("Off", "On"), available=parked and self.owner.authority("parked_preferences") and readable,
capability=capability, repair_value="" if valid else "Off", default_value="Off",
reason="Softens small acceleration requests, reduces grade corrections, and smooths light braking. Updates within half a second."),)
reason="Softens small acceleration requests, reduces grade corrections, and smooths light braking. Updates within half a second.",
level=SettingLevel.ADVANCED),)
def apply(self, request):
from openpilot.starpilot.car.gm.tune_preferences import TRUCK_KEY, read_truck_choice
@@ -143,7 +144,7 @@ class GmEvPresetFeature:
return (FeatureRow(self.KEY, 'EV Acceleration Presets', ('On' if value else 'Off') if valid else 'Invalid saved choice', raw,
choices=('Off', 'On'), available=parked and self.owner.authority('parked_preferences') and readable,
capability=capability, repair_value='' if valid else ('On' if default else 'Off'),
default_value='On' if default else 'Off',
default_value='On' if default else 'Off', level=SettingLevel.ADVANCED,
reason=('Select EV curves for inherited acceleration presets. ' +
'Individual personality and custom curves remain as selected. ' +
'Truck presets take priority. Updates within one second.')),)
@@ -14,7 +14,7 @@ from openpilot.starpilot.lateral.lane_change_preferences import (
)
from openpilot.starpilot.lateral.turn_initiation_preferences import KEY as TURN_INITIATION_KEY, saved as turn_initiation_saved
from openpilot.starpilot.saved_document import commit_exact
from openpilot.starpilot.ui.feature_settings_state import FeatureRow, FeatureSettingsRequest
from openpilot.starpilot.ui.feature_settings_state import SettingLevel, FeatureRow, FeatureSettingsRequest
GUIDANCE = "lane_change:automatic_turn_initiation"
@@ -115,7 +115,7 @@ class LaneChangeFeature:
rows = [replace(common, key=PACE, label="Lane Change Speed", value=str(round(1.0 + (8.0 - policy.duration_s) * 9.0 / 5.0, 2)),
step=1.0, minimum=1.0, maximum=10.0, unit="", available=allowed,
reason="Sets how quickly steering moves into the adjacent lane. Higher values change lanes " +
"more quickly; lower values make steering gentler."),
"more quickly; lower values make steering gentler.", level=SettingLevel.ADVANCED),
replace(common, key=ENABLED, label="Allow lane changes", value="On" if policy.enabled else "Off",
choices=("Off", "On"), available=allowed,
reason="Enables lane-change assistance after you signal. With Automatic Lane Changes off, give the wheel a nudge to begin."),
@@ -123,7 +123,7 @@ class LaneChangeFeature:
maximum=math.floor(MAX_SPEED_MPS * multiplier * 1000) / 1000,
unit=unit if unit_valid else "", available=allowed and unit_valid,
reason="Sets the lowest speed at which lane-change assistance can begin." if unit_valid else "Saved speed units unavailable",
dependencies=(("IsMetric", unit_raw),), display_unit=unit if unit_valid else ""),
dependencies=(("IsMetric", unit_raw),), display_unit=unit if unit_valid else "", level=SettingLevel.ADVANCED),
replace(common, key=ONE, label="One change per signal", value="On" if policy.one_per_signal else "Off",
choices=("Off", "On"), available=allowed,
reason="Allows one assisted lane change until you release the turn signal."),
@@ -140,13 +140,15 @@ class LaneChangeFeature:
reason="Time to wait after signaling before an automatic lane change; lane and blindspot checks still apply"),
replace(common, key=WIDTH, label="Minimum adjacent lane width", value=str(round(policy.minimum_lane_width_m / 0.3048, 1)),
step=0.1, minimum=0.0, maximum=15.0, unit="ft", available=allowed,
reason="Minimum detected adjacent lane width for an automatic lane change; narrower or uncertain lanes require a driver nudge"),
reason="Minimum detected adjacent lane width for an automatic lane change; narrower or uncertain lanes require a driver nudge",
level=SettingLevel.ADVANCED),
replace(common, key=CLOSE, label="Close lane-change gap", value="On" if policy.close_gap else "Off",
choices=("Off", "On"), available=allowed and long_available,
reason="Temporarily reduces following time during a lane change when the lane and lead gap are clear; requires StarPilot speed control"),
replace(common, key=GAP, label="Lane-change follow gap", value=str(round(policy.close_gap_seconds, 2)),
step=0.05, minimum=0.75, maximum=1.0, unit="s", available=allowed and long_available,
reason="Following time while Close lane-change gap is active. Higher values leave more space; returns to the normal gap afterward.")]
reason="Following time while Close lane-change gap is active. Higher values leave more space; returns to the normal gap afterward.",
level=SettingLevel.ADVANCED)]
defaults = LaneChangePolicy()
targets = {ENABLED: "On" if defaults.enabled else "Off", ONE: "On" if defaults.one_per_signal else "Off",
@@ -2,7 +2,7 @@ from opendbc.car import structs
from opendbc.car.tesla.values import CAR
from openpilot.starpilot.saved_document import commit_exact
from openpilot.starpilot.car.tesla.radar_settings import DOCUMENT_KEY, MAX_BYTES, encode, read_radar_settings
from openpilot.starpilot.ui.feature_settings_state import FeatureRow
from openpilot.starpilot.ui.feature_settings_state import SettingLevel, FeatureRow
KEYS = frozenset(("preap_radar:mode", "preap_radar:offset"))
FLOAT32_MAX = 3.4028234663852886e38
@@ -36,11 +36,11 @@ class PreAPRadarFeature:
return [FeatureRow("preap_radar:mode", "Hardware radar", mode if saved.valid else "Invalid saved configuration", source,
choices=("Off", "Front", "Behind nosecone") if saved.valid else (),
repair_value="" if saved.valid else "Off", available=allowed, capability=capable, vehicle_fingerprint=owner.vehicle_fingerprint(),
dependencies=saved.sources, reason="Parked hardware setup. Applies after restart."),
dependencies=saved.sources, reason="Parked hardware setup. Applies after restart.", level=SettingLevel.ADVANCED),
FeatureRow("preap_radar:offset", "Radar lateral offset", str(saved.offset) if saved.valid else "Invalid saved configuration", source,
step=0.05 if saved.valid else 0.0, minimum=-FLOAT32_MAX, maximum=FLOAT32_MAX, unit="m",
repair_value="" if saved.valid else "0.0", available=allowed, capability=capable, vehicle_fingerprint=owner.vehicle_fingerprint(),
dependencies=saved.sources, reason="Parked hardware setup. Applies after restart.")]
dependencies=saved.sources, reason="Parked hardware setup. Applies after restart.", level=SettingLevel.ADVANCED)]
def apply(self, request):
if request.key not in KEYS or request.related_source is not None or request.direction or request.display_unit:
@@ -4,7 +4,7 @@ from opendbc.car.subaru.stock_aol import qualified
from openpilot.starpilot.car.subaru.smoothing import KEY, selected
from openpilot.starpilot.saved_document import commit_exact
from openpilot.starpilot.saved_source import read_saved
from openpilot.starpilot.ui.feature_settings_state import FeatureRow
from openpilot.starpilot.ui.feature_settings_state import SettingLevel, FeatureRow
from openpilot.starpilot.vehicle_selection import read_selection
@@ -54,13 +54,13 @@ class SubaruSmoothingFeature:
self.owner.authority('parked_preferences')), capability=capability,
dependencies=self.safe_dependency() or (), vehicle_fingerprint=self.owner.vehicle_fingerprint(),
repair_value='' if dev_valid else 'Off',
reason='Use an explicit saved Subaru smoothing value next drive. Off uses the vehicle default.')
reason='Use an explicit saved Subaru smoothing value next drive. Off uses the vehicle default.', level=SettingLevel.ADVANCED)
return (toggle, FeatureRow(KEY, 'Subaru model curvature smoothing', shown if valid else 'Invalid saved choice', raw,
step=.005 if valid else 0., minimum=0., maximum=2., unit='s',
available=bool(parked and readable and dependencies is not None and self.owner.authority('parked_preferences')),
capability=capability, dependencies=dependencies or (), vehicle_fingerprint=self.owner.vehicle_fingerprint(),
repair_value='' if valid else '0', presets=(('0', 'Off'), ('.4', '0.4 s')),
reason='Applies next drive. Maximum below 2 m/s, fades to zero at 8 m/s. Zero turns smoothing off.'),)
reason='Applies next drive. Maximum below 2 m/s, fades to zero at 8 m/s. Zero turns smoothing off.', level=SettingLevel.ADVANCED),)
def apply(self, request):
if request.key == 'DeveloperUI':
@@ -31,6 +31,36 @@ def required_document(raw: object) -> dict:
class FeatureSettingsOwnerTests(unittest.TestCase):
def test_setting_levels_follow_tuning_and_convenience_policy(self):
from openpilot.starpilot.ui.feature_settings_state import SettingLevel
def snapshot(page):
return self.owner.snapshot(page, parked=True, system_long=True, lateral_context=True, metric=False)
for page in ("torque/developer", "profiles/developer", "tuning", "personalities",
"standard", "traffic", "traffic/braking"):
state = snapshot(page)
self.assertEqual(state.level, SettingLevel.ADVANCED)
self.assertTrue(all(state.row_level(row) == SettingLevel.ADVANCED for row in state.rows))
for page, advanced, simple in (
("lane", "LaneCenteringStrength", "LaneCentering"),
("profiles", "profile:stopped_gap", "profile:global_acceleration"),
("lane_change", "lane_change:width", "lane_change:delay"),
("lane_change", "conditional:cem:signal_lane_width_m", "lane_change:auto"),
("conditional/cem", "conditional:cem:speed_mps", "conditional:cem:lead"),
):
state = snapshot(page)
rows = {row.key: row for row in state.rows}
self.assertEqual(state.row_level(rows[advanced]), SettingLevel.ADVANCED)
self.assertEqual(state.row_level(rows[simple]), SettingLevel.SIMPLE)
state = snapshot("aol")
rows = {row.key: row for row in state.rows}
for key in ("PauseLateralSpeed", "AolBrakePauseSpeedMps", "LateralResumeDelay"):
self.assertEqual(state.row_level(rows[key]), SettingLevel.SIMPLE)
for page in ("slc", "curve", "wheel", "data", "power"):
state = snapshot(page)
self.assertTrue(all(state.row_level(row) == SettingLevel.SIMPLE for row in state.rows))
def test_bolt_wheel_menu_exposes_only_received_buttons(self):
from opendbc.car.gm.tests.test_bolt_pedal import params
from opendbc.car.gm.values import CAR
+2 -2
View File
@@ -3,7 +3,7 @@ from collections.abc import Callable
from openpilot.starpilot.car.gm.radar_recovery import KEY, capability
from openpilot.starpilot.saved_document import commit_exact
from openpilot.starpilot.saved_source import read_saved
from openpilot.starpilot.ui.feature_settings_state import FeatureRow
from openpilot.starpilot.ui.feature_settings_state import SettingLevel, FeatureRow
class VoltRadarFeature:
@@ -23,7 +23,7 @@ class VoltRadarFeature:
return (FeatureRow(KEY, "Radar Recovery Alert", ("On" if raw == b"1" else "Off") if valid else "Invalid saved choice",
source=raw, choices=("Off", "On") if valid else (), default_value="Off", capability=binding,
available=valid and self.owner.authority("preferences"),
reason="Play a chime and show a brief message when a radar fault clears. You must re-engage manually."),)
reason="Play a chime and show a brief message when a radar fault clears. You must re-engage manually.", level=SettingLevel.ADVANCED),)
def apply(self, request):
if (request.key != KEY or request.value not in ("Off", "On") or request.expected not in (None, b"0", b"1") or