Skip to content

Commit f0d8ebd

Browse files
mici training guide tuneups (#36652)
* bump up size * lil more * rm param * 5m timeout and 100% brightness * set parasm:
1 parent 3a001dd commit f0d8ebd

File tree

8 files changed

+48
-34
lines changed

8 files changed

+48
-34
lines changed

common/params_keys.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,6 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {
113113
{"RouteCount", {PERSISTENT, INT, "0"}},
114114
{"SnoozeUpdate", {CLEAR_ON_MANAGER_START | CLEAR_ON_OFFROAD_TRANSITION, BOOL}},
115115
{"SshEnabled", {PERSISTENT, BOOL}},
116-
{"TermsVersion", {PERSISTENT, STRING}},
117-
{"TrainingVersion", {PERSISTENT, STRING}},
118116
{"UbloxAvailable", {PERSISTENT, BOOL}},
119117
{"UpdateAvailable", {CLEAR_ON_MANAGER_START | CLEAR_ON_ONROAD_TRANSITION, BOOL}},
120118
{"UpdateFailedCount", {CLEAR_ON_MANAGER_START, INT}},

selfdrive/ui/layouts/onboarding.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from openpilot.system.ui.widgets.button import Button, ButtonStyle
1212
from openpilot.system.ui.widgets.label import Label
1313
from openpilot.selfdrive.ui.ui_state import ui_state
14+
from openpilot.system.version import terms_version, training_version
1415

1516
DEBUG = False
1617

@@ -169,10 +170,8 @@ def _render(self, _):
169170
class OnboardingWindow(Widget):
170171
def __init__(self):
171172
super().__init__()
172-
self._current_terms_version = ui_state.params.get("TermsVersion")
173-
self._current_training_version = ui_state.params.get("TrainingVersion")
174-
self._accepted_terms: bool = ui_state.params.get("HasAcceptedTerms") == self._current_terms_version
175-
self._training_done: bool = ui_state.params.get("CompletedTrainingVersion") == self._current_training_version
173+
self._accepted_terms: bool = ui_state.params.get("HasAcceptedTerms") == terms_version
174+
self._training_done: bool = ui_state.params.get("CompletedTrainingVersion") == training_version
176175

177176
self._state = OnboardingState.TERMS if not self._accepted_terms else OnboardingState.ONBOARDING
178177

@@ -192,13 +191,13 @@ def _on_decline_back(self):
192191
self._state = OnboardingState.TERMS
193192

194193
def _on_terms_accepted(self):
195-
ui_state.params.put("HasAcceptedTerms", self._current_terms_version)
194+
ui_state.params.put("HasAcceptedTerms", terms_version)
196195
self._state = OnboardingState.ONBOARDING
197196
if self._training_done:
198197
gui_app.set_modal_overlay(None)
199198

200199
def _on_completed_training(self):
201-
ui_state.params.put("CompletedTrainingVersion", self._current_training_version)
200+
ui_state.params.put("CompletedTrainingVersion", training_version)
202201
gui_app.set_modal_overlay(None)
203202

204203
def _render(self, _):

selfdrive/ui/mici/layouts/onboarding.py

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from openpilot.selfdrive.ui.mici.onroad.driver_camera_dialog import DriverCameraDialog
1616
from openpilot.system.ui.widgets.label import gui_label
1717
from openpilot.system.ui.lib.multilang import tr
18+
from openpilot.system.version import terms_version, training_version
1819

1920

2021
class OnboardingState(IntEnum):
@@ -60,7 +61,7 @@ def __init__(self, continue_callback):
6061
self._title_header = TermsHeader("welcome to openpilot", gui_app.texture("icons_mici/offroad_alerts/green_wheel.png", 60, 60))
6162

6263
self._dm_label = UnifiedLabel("Before we get on the road, let's review the " +
63-
"functionality and limitations of openpilot.", 36,
64+
"functionality and limitations of openpilot.", 42,
6465
FontWeight.ROMAN)
6566

6667
@property
@@ -90,7 +91,7 @@ def __init__(self, continue_callback):
9091

9192
self._dm_label = UnifiedLabel("Next, we'll ensure comma four is mounted properly.\n\nIf it does not have a clear view of the driver, " +
9293
"simply unplug and remount before continuing.\n\n" +
93-
"NOTE: the driver camera will have a purple tint due to the IR illumination used for seeing at night.", 36,
94+
"NOTE: the driver camera will have a purple tint due to the IR illumination used for seeing at night.", 42,
9495
FontWeight.ROMAN)
9596

9697
def show_event(self):
@@ -123,7 +124,14 @@ def __init__(self, continue_callback):
123124
super().__init__()
124125
self._title_header = TermsHeader("fill the circle to continue", gui_app.texture("icons_mici/setup/green_dm.png", 60, 60))
125126

126-
self._dialog = DriverCameraSetupDialog(continue_callback)
127+
self._original_continue_callback = continue_callback
128+
129+
# Wrap the continue callback to restore settings
130+
def wrapped_continue_callback():
131+
self._restore_settings()
132+
continue_callback()
133+
134+
self._dialog = DriverCameraSetupDialog(wrapped_continue_callback)
127135

128136
# Disable driver monitoring model when device times out for inactivity
129137
def inactivity_callback():
@@ -135,6 +143,13 @@ def show_event(self):
135143
super().show_event()
136144
self._dialog.show_event()
137145

146+
device.set_offroad_brightness(100)
147+
device.reset_interactive_timeout(300) # 5 minutes
148+
149+
def _restore_settings(self):
150+
device.set_offroad_brightness(None)
151+
device.reset_interactive_timeout()
152+
138153
def _update_state(self):
139154
super()._update_state()
140155
if device.awake:
@@ -168,7 +183,7 @@ def on_continue():
168183
self._title_header = TermsHeader("improve driver monitoring", gui_app.texture("icons_mici/setup/green_dm.png", 60, 60))
169184

170185
self._dm_label = UnifiedLabel("Help improve driver monitoring by including your driving data in the training data set. " +
171-
"Your preference can be changed at any time in Settings. Would you like to share your data?", 36,
186+
"Your preference can be changed at any time in Settings. Would you like to share your data?", 42,
172187
FontWeight.ROMAN)
173188

174189
def show_event(self):
@@ -200,7 +215,7 @@ class TrainingGuideAttentionNotice1(SetupTermsPage):
200215
def __init__(self, continue_callback):
201216
super().__init__(continue_callback, continue_text="continue")
202217
self._title_header = TermsHeader("not a self driving car", gui_app.texture("icons_mici/setup/warning.png", 60, 60))
203-
self._warning_label = UnifiedLabel("THIS IS A DRIVER ASSISTANCE SYSTEM. A DRIVER ASSISTANCE SYSTEM IS NOT A SELF DRIVING CAR.", 36,
218+
self._warning_label = UnifiedLabel("THIS IS A DRIVER ASSISTANCE SYSTEM. A DRIVER ASSISTANCE SYSTEM IS NOT A SELF-DRIVING CAR.", 42,
204219
FontWeight.ROMAN)
205220

206221
@property
@@ -227,7 +242,8 @@ class TrainingGuideAttentionNotice2(SetupTermsPage):
227242
def __init__(self, continue_callback):
228243
super().__init__(continue_callback, continue_text="continue")
229244
self._title_header = TermsHeader("attention is required", gui_app.texture("icons_mici/setup/warning.png", 60, 60))
230-
self._warning_label = UnifiedLabel("YOU MUST PAY ATTENTION AT ALL TIMES. YOU ARE FULLY RESPONSIBLE FOR DRIVING THE CAR.", 36,
245+
self._warning_label = UnifiedLabel("1. You must pay attention at all times.\n\n2. You must be ready to take over at any time."+
246+
"\n\n3. You are fully responsible for driving the car.", 42,
231247
FontWeight.ROMAN)
232248

233249
@property
@@ -255,7 +271,7 @@ def __init__(self, continue_callback):
255271
super().__init__(continue_callback, continue_text="continue")
256272
self._title_header = TermsHeader("disengaging openpilot", gui_app.texture("icons_mici/setup/green_pedal.png", 60, 60))
257273
self._warning_label = UnifiedLabel("You can disengage openpilot by either pressing the brake pedal or " +
258-
"the cancel button on your steering wheel.", 36,
274+
"the cancel button on your steering wheel.", 42,
259275
FontWeight.ROMAN)
260276

261277
@property
@@ -288,7 +304,7 @@ def __init__(self, continue_callback):
288304

289305
self._title_header = TermsHeader("confidence ball", gui_app.texture("icons_mici/setup/green_car.png", 60, 60))
290306
self._warning_label = UnifiedLabel("The ball on the right communicates how confident openpilot " +
291-
"is about the road scene at any given time.", 36,
307+
"is about the road scene at any given time.", 42,
292308
FontWeight.ROMAN)
293309

294310
def show_event(self):
@@ -343,7 +359,7 @@ def __init__(self, continue_callback):
343359
self._title_header = TermsHeader("steering arc", gui_app.texture("icons_mici/offroad_alerts/green_wheel.png", 60, 60))
344360
self._warning_label = UnifiedLabel("All cars limit the amount of steering that openpilot is able to apply. While driving, the " +
345361
"steering arc shows the current amount of force being applied in relation to the maximum available to openpilot. " +
346-
"You may need to assist if you see the arc nearing its orange state.", 36,
362+
"You may need to assist if you see the arc nearing its orange state.", 42,
347363
FontWeight.ROMAN)
348364

349365
def show_event(self):
@@ -506,10 +522,8 @@ def _render_content(self, scroll_offset):
506522
class OnboardingWindow(Widget):
507523
def __init__(self):
508524
super().__init__()
509-
self._current_terms_version = ui_state.params.get("TermsVersion")
510-
self._current_training_version = ui_state.params.get("TrainingVersion")
511-
self._accepted_terms: bool = ui_state.params.get("HasAcceptedTerms") == self._current_terms_version
512-
self._training_done: bool = ui_state.params.get("CompletedTrainingVersion") == self._current_training_version
525+
self._accepted_terms: bool = ui_state.params.get("HasAcceptedTerms") == terms_version
526+
self._training_done: bool = ui_state.params.get("CompletedTrainingVersion") == training_version
513527

514528
self._state = OnboardingState.TERMS if not self._accepted_terms else OnboardingState.ONBOARDING
515529

@@ -535,11 +549,11 @@ def close(self):
535549
gui_app.set_modal_overlay(None)
536550

537551
def _on_terms_accepted(self):
538-
ui_state.params.put("HasAcceptedTerms", self._current_terms_version)
552+
ui_state.params.put("HasAcceptedTerms", terms_version)
539553
self._state = OnboardingState.ONBOARDING
540554

541555
def _on_completed_training(self):
542-
ui_state.params.put("CompletedTrainingVersion", self._current_training_version)
556+
ui_state.params.put("CompletedTrainingVersion", training_version)
543557
self.close()
544558

545559
def _render(self, _):

selfdrive/ui/tests/test_ui/raylib_screenshots.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from openpilot.selfdrive.test.helpers import with_processes
1919
from openpilot.selfdrive.selfdrived.alertmanager import set_offroad_alert
2020
from openpilot.system.updated.updated import parse_release_notes
21+
from openpilot.system.version import terms_version, training_version
2122

2223
AlertSize = log.SelfdriveState.AlertSize
2324
AlertStatus = log.SelfdriveState.AlertStatus
@@ -298,6 +299,10 @@ def create_screenshots():
298299
params.put("UpdaterCurrentDescription", VERSION)
299300
params.put("UpdaterNewDescription", VERSION)
300301

302+
# Set terms and training version (to skip onboarding)
303+
params.put("HasAcceptedTerms", terms_version)
304+
params.put("CompletedTrainingVersion", training_version)
305+
301306
if name == "homescreen_paired":
302307
params.put("PrimeType", 0) # NONE
303308
elif name == "homescreen_prime":

selfdrive/ui/ui_state.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,9 @@ def update(self):
217217
self._update_brightness()
218218
self._update_wakefulness()
219219

220-
def set_offroad_brightness(self, brightness: int):
221-
# TODO: not yet used, should be used in prime widget for QR code, etc.
220+
def set_offroad_brightness(self, brightness: int | None):
221+
if brightness is None:
222+
brightness = BACKLIGHT_OFFROAD
222223
self._offroad_brightness = min(max(brightness, 0), 100)
223224

224225
def _update_brightness(self):

system/manager/manager.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from openpilot.system.manager.process_config import managed_processes
1818
from openpilot.system.athena.registration import register, UNREGISTERED_DONGLE_ID
1919
from openpilot.common.swaglog import cloudlog, add_file_handler
20-
from openpilot.system.version import get_build_metadata, terms_version, training_version
20+
from openpilot.system.version import get_build_metadata
2121
from openpilot.system.hardware.hw import Paths
2222

2323

@@ -54,8 +54,6 @@ def manager_init() -> None:
5454
# set params
5555
serial = HARDWARE.get_serial()
5656
params.put("Version", build_metadata.openpilot.version)
57-
params.put("TermsVersion", terms_version)
58-
params.put("TrainingVersion", training_version)
5957
params.put("GitCommit", build_metadata.openpilot.git_commit)
6058
params.put("GitCommitDate", build_metadata.openpilot.git_commit_date)
6159
params.put("GitBranch", build_metadata.channel)

system/ui/mici_setup.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from openpilot.system.hardware import HARDWARE
1919
from openpilot.system.ui.lib.application import gui_app, FontWeight
2020
from openpilot.system.ui.lib.wifi_manager import WifiManager
21+
from openpilot.selfdrive.ui.ui_state import device
2122
from openpilot.system.ui.lib.scroll_panel2 import GuiScrollPanel2
2223
from openpilot.system.ui.widgets import Widget, DialogResult
2324
from openpilot.system.ui.widgets.button import (IconButton, SmallButton, WideRoundedButton, SmallerRoundedButton,
@@ -225,6 +226,10 @@ def reset(self):
225226
self._back_button.set_opacity(0.0)
226227
self._scroll_down_indicator.set_opacity(1.0)
227228

229+
def show_event(self):
230+
super().show_event()
231+
device.reset_interactive_timeout(300)
232+
228233
@property
229234
@abstractmethod
230235
def _content_height(self):

system/version.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,4 @@ def get_build_metadata(path: str = BASEDIR) -> BuildMetadata:
157157

158158

159159
if __name__ == "__main__":
160-
from openpilot.common.params import Params
161-
162-
params = Params()
163-
params.put("TermsVersion", terms_version)
164-
params.put("TrainingVersion", training_version)
165-
166160
print(get_build_metadata())

0 commit comments

Comments
 (0)