Skip to content

Commit 8bc6bec

Browse files
simplify mici onboarding (#36666)
* simplify mici onboarding * shorter * dead * cleanup
1 parent 5151bb8 commit 8bc6bec

File tree

1 file changed

+9
-284
lines changed

1 file changed

+9
-284
lines changed

selfdrive/ui/mici/layouts/onboarding.py

Lines changed: 9 additions & 284 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
from openpilot.system.ui.widgets.slider import SmallSlider
1010
from openpilot.system.ui.mici_setup import TermsHeader, TermsPage as SetupTermsPage
1111
from openpilot.selfdrive.ui.ui_state import ui_state, device
12-
from openpilot.selfdrive.ui.mici.onroad.confidence_ball import ConfidenceBall
13-
from openpilot.selfdrive.ui.mici.onroad.torque_bar import TorqueBar
1412
from openpilot.selfdrive.ui.mici.onroad.driver_state import DriverStateRenderer
1513
from openpilot.selfdrive.ui.mici.onroad.driver_camera_dialog import DriverCameraDialog
1614
from openpilot.system.ui.widgets.label import gui_label
@@ -55,43 +53,13 @@ def _render(self, rect):
5553
return -1
5654

5755

58-
class TrainingGuideIntro(SetupTermsPage):
59-
def __init__(self, continue_callback):
60-
super().__init__(continue_callback, continue_text="continue")
61-
self._title_header = TermsHeader("welcome to openpilot", gui_app.texture("icons_mici/offroad_alerts/green_wheel.png", 60, 60))
62-
63-
self._dm_label = UnifiedLabel("Before we get on the road, let's review the " +
64-
"functionality and limitations of openpilot.", 42,
65-
FontWeight.ROMAN)
66-
67-
@property
68-
def _content_height(self):
69-
return self._dm_label.rect.y + self._dm_label.rect.height - self._scroll_panel.get_offset()
70-
71-
def _render_content(self, scroll_offset):
72-
self._title_header.render(rl.Rectangle(
73-
self._rect.x + 16,
74-
self._rect.y + 16 + scroll_offset,
75-
self._title_header.rect.width,
76-
self._title_header.rect.height,
77-
))
78-
79-
self._dm_label.render(rl.Rectangle(
80-
self._rect.x + 16,
81-
self._title_header.rect.y + self._title_header.rect.height + 16,
82-
self._rect.width - 32,
83-
self._dm_label.get_content_height(int(self._rect.width - 32)),
84-
))
85-
86-
8756
class TrainingGuidePreDMTutorial(SetupTermsPage):
8857
def __init__(self, continue_callback):
8958
super().__init__(continue_callback, continue_text="continue")
9059
self._title_header = TermsHeader("driver monitoring setup", gui_app.texture("icons_mici/setup/green_dm.png", 60, 60))
9160

9261
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, " +
93-
"simply unplug and remount before continuing.\n\n" +
94-
"NOTE: the driver camera will have a purple tint due to the IR illumination used for seeing at night.", 42,
62+
"unplug and remount before continuing.", 42,
9563
FontWeight.ROMAN)
9664

9765
def show_event(self):
@@ -182,8 +150,7 @@ def on_continue():
182150
super().__init__(on_continue, back_callback=on_back, back_text="no", continue_text="yes")
183151
self._title_header = TermsHeader("improve driver monitoring", gui_app.texture("icons_mici/setup/green_dm.png", 60, 60))
184152

185-
self._dm_label = UnifiedLabel("Help improve driver monitoring by including your driving data in the training data set. " +
186-
"Your preference can be changed at any time in Settings.\n\nWould you like to share your data?", 42,
153+
self._dm_label = UnifiedLabel("Do you want to upload driver camera data to improve driver monitoring?", 42,
187154
FontWeight.ROMAN)
188155

189156
def show_event(self):
@@ -211,221 +178,20 @@ def _render_content(self, scroll_offset):
211178
))
212179

213180

214-
class TrainingGuideAttentionNotice1(SetupTermsPage):
215-
def __init__(self, continue_callback):
216-
super().__init__(continue_callback, continue_text="continue")
217-
self._title_header = TermsHeader("not a self driving car", gui_app.texture("icons_mici/setup/warning.png", 60, 60))
218-
self._warning_label = UnifiedLabel("THIS IS A DRIVER ASSISTANCE SYSTEM. A DRIVER ASSISTANCE SYSTEM IS NOT A SELF-DRIVING CAR.", 42,
219-
FontWeight.ROMAN)
220-
221-
@property
222-
def _content_height(self):
223-
return self._warning_label.rect.y + self._warning_label.rect.height - self._scroll_panel.get_offset()
224-
225-
def _render_content(self, scroll_offset):
226-
self._title_header.render(rl.Rectangle(
227-
self._rect.x + 16,
228-
self._rect.y + 16 + scroll_offset,
229-
self._title_header.rect.width,
230-
self._title_header.rect.height,
231-
))
232-
233-
self._warning_label.render(rl.Rectangle(
234-
self._rect.x + 16,
235-
self._title_header.rect.y + self._title_header.rect.height + 16,
236-
self._rect.width - 32,
237-
self._warning_label.get_content_height(int(self._rect.width - 32)),
238-
))
239-
240-
241-
class TrainingGuideAttentionNotice2(SetupTermsPage):
242-
def __init__(self, continue_callback):
243-
super().__init__(continue_callback, continue_text="continue")
244-
self._title_header = TermsHeader("attention is required", gui_app.texture("icons_mici/setup/warning.png", 60, 60))
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,
247-
FontWeight.ROMAN)
248-
249-
@property
250-
def _content_height(self):
251-
return self._warning_label.rect.y + self._warning_label.rect.height - self._scroll_panel.get_offset()
252-
253-
def _render_content(self, scroll_offset):
254-
self._title_header.render(rl.Rectangle(
255-
self._rect.x + 16,
256-
self._rect.y + 16 + scroll_offset,
257-
self._title_header.rect.width,
258-
self._title_header.rect.height,
259-
))
260-
261-
self._warning_label.render(rl.Rectangle(
262-
self._rect.x + 16,
263-
self._title_header.rect.y + self._title_header.rect.height + 16,
264-
self._rect.width - 32,
265-
self._warning_label.get_content_height(int(self._rect.width - 32)),
266-
))
267-
268-
class TrainingGuideEngaging(SetupTermsPage):
269-
def __init__(self, continue_callback):
270-
super().__init__(continue_callback, continue_text="continue")
271-
self._title_header = TermsHeader("engaging openpilot", gui_app.texture("icons_mici/offroad_alerts/green_wheel.png", 60, 60))
272-
self._warning_label = UnifiedLabel("You can engage openpilot using your car's cruise control inputs.\n\n" +
273-
"These are usually located on either the steering wheel or on a lever near the wheel.", 42,
274-
FontWeight.ROMAN)
275-
276-
@property
277-
def _content_height(self):
278-
return self._warning_label.rect.y + self._warning_label.rect.height - self._scroll_panel.get_offset()
279-
280-
def _render_content(self, scroll_offset):
281-
self._title_header.render(rl.Rectangle(
282-
self._rect.x + 16,
283-
self._rect.y + 16 + scroll_offset,
284-
self._title_header.rect.width,
285-
self._title_header.rect.height,
286-
))
287-
288-
self._warning_label.render(rl.Rectangle(
289-
self._rect.x + 16,
290-
self._title_header.rect.y + self._title_header.rect.height + 16,
291-
self._rect.width - 32,
292-
self._warning_label.get_content_height(int(self._rect.width - 32)),
293-
))
294-
295-
296-
class TrainingGuideEnd(SetupTermsPage):
297-
def __init__(self, continue_callback):
298-
super().__init__(continue_callback, continue_text="finish")
299-
self._title_header = TermsHeader("training complete!", gui_app.texture("icons_mici/setup/green_info.png", 60, 60))
300-
self._warning_label = UnifiedLabel("You have completed the openpilot training.\n\n" +
301-
"This guide can be revisited at any time in Settings.", 42,
302-
FontWeight.ROMAN)
303-
304-
@property
305-
def _content_height(self):
306-
return self._warning_label.rect.y + self._warning_label.rect.height - self._scroll_panel.get_offset()
307-
308-
def _render_content(self, scroll_offset):
309-
self._title_header.render(rl.Rectangle(
310-
self._rect.x + 16,
311-
self._rect.y + 16 + scroll_offset,
312-
self._title_header.rect.width,
313-
self._title_header.rect.height,
314-
))
315-
316-
self._warning_label.render(rl.Rectangle(
317-
self._rect.x + 16,
318-
self._title_header.rect.y + self._title_header.rect.height + 16,
319-
self._rect.width - 32,
320-
self._warning_label.get_content_height(int(self._rect.width - 32)),
321-
))
322-
323-
324-
325-
class TrainingGuideDisengaging(SetupTermsPage):
326-
def __init__(self, continue_callback):
327-
super().__init__(continue_callback, continue_text="continue")
328-
self._title_header = TermsHeader("disengaging openpilot", gui_app.texture("icons_mici/setup/green_pedal.png", 60, 60))
329-
self._warning_label = UnifiedLabel("You can disengage openpilot by either pressing the brake pedal or " +
330-
"the cruise control cancel button.", 42,
331-
FontWeight.ROMAN)
332-
333-
@property
334-
def _content_height(self):
335-
return self._warning_label.rect.y + self._warning_label.rect.height - self._scroll_panel.get_offset()
336-
337-
def _render_content(self, scroll_offset):
338-
self._title_header.render(rl.Rectangle(
339-
self._rect.x + 16,
340-
self._rect.y + 16 + scroll_offset,
341-
self._title_header.rect.width,
342-
self._title_header.rect.height,
343-
))
344-
345-
self._warning_label.render(rl.Rectangle(
346-
self._rect.x + 16,
347-
self._title_header.rect.y + self._title_header.rect.height + 16,
348-
self._rect.width - 32,
349-
self._warning_label.get_content_height(int(self._rect.width - 32)),
350-
))
351-
352-
353-
class TrainingGuideConfidenceBall(SetupTermsPage):
354-
ANIMATION_PAUSE = 3.5
355-
181+
class TrainingGuideAttentionNotice(SetupTermsPage):
356182
def __init__(self, continue_callback):
357183
super().__init__(continue_callback, continue_text="continue")
358-
self._confidence_ball = ConfidenceBall(demo=True)
359-
self._start_time = 0.0
360-
361-
self._title_header = TermsHeader("confidence ball", gui_app.texture("icons_mici/setup/green_car.png", 60, 60))
362-
self._warning_label = UnifiedLabel("The ball on the right communicates how confident openpilot " +
363-
"is about the road scene at any given time.", 42,
184+
self._title_header = TermsHeader("driver assistance", gui_app.texture("icons_mici/setup/warning.png", 60, 60))
185+
self._warning_label = UnifiedLabel("1. openpilot is a driver assistance system.\n\n" +
186+
"2. You must pay attention at all times.\n\n" +
187+
"3. You must be ready to take over at any time.\n\n" +
188+
"4. You are fully responsible for driving the car.", 42,
364189
FontWeight.ROMAN)
365190

366-
def show_event(self):
367-
super().show_event()
368-
self._start_time = rl.get_time()
369-
370191
@property
371192
def _content_height(self):
372193
return self._warning_label.rect.y + self._warning_label.rect.height - self._scroll_panel.get_offset()
373194

374-
def _render_content(self, scroll_offset):
375-
self._title_header.render(rl.Rectangle(
376-
self._rect.x + 16,
377-
self._rect.y + 16 + scroll_offset,
378-
self._title_header.rect.width,
379-
self._title_header.rect.height,
380-
))
381-
382-
# room for confidence ball
383-
label_width = self._rect.width - 32 - 60
384-
self._warning_label.render(rl.Rectangle(
385-
self._rect.x + 16,
386-
self._title_header.rect.y + self._title_header.rect.height + 16,
387-
label_width,
388-
self._warning_label.get_content_height(int(label_width)),
389-
))
390-
391-
duration = rl.get_time() - self._start_time
392-
if duration > 5 + self.ANIMATION_PAUSE * 2:
393-
# reset animation
394-
self._start_time = rl.get_time()
395-
if duration > 5 + self.ANIMATION_PAUSE:
396-
self._confidence_ball.update_filter(0.1)
397-
elif duration > 5:
398-
self._confidence_ball.update_filter(0.4)
399-
elif duration > 0.5:
400-
self._confidence_ball.update_filter(0.9)
401-
402-
self._confidence_ball.render(self._rect)
403-
self._rect.width -= 60
404-
405-
406-
class TrainingGuideSteeringArc(SetupTermsPage):
407-
ANIMATION_PAUSE = 2
408-
TORQUE_BAR_HEIGHT = 100
409-
410-
def __init__(self, continue_callback):
411-
super().__init__(continue_callback, continue_text="continue")
412-
self._torque_bar = TorqueBar(demo=True)
413-
self._start_time = 0.0
414-
415-
self._title_header = TermsHeader("steering arc", gui_app.texture("icons_mici/offroad_alerts/green_wheel.png", 60, 60))
416-
self._warning_label = UnifiedLabel("All cars limit the amount of steering that openpilot is able to apply. While driving, the " +
417-
"steering arc shows the current amount of force being applied in relation to the maximum available to openpilot. " +
418-
"You may need to assist if you see the arc nearing its orange state.", 42,
419-
FontWeight.ROMAN)
420-
421-
def show_event(self):
422-
super().show_event()
423-
self._start_time = rl.get_time()
424-
425-
@property
426-
def _content_height(self):
427-
return self._warning_label.rect.y + self._warning_label.rect.height - self._scroll_panel.get_offset() + self.TORQUE_BAR_HEIGHT
428-
429195
def _render_content(self, scroll_offset):
430196
self._title_header.render(rl.Rectangle(
431197
self._rect.x + 16,
@@ -441,40 +207,6 @@ def _render_content(self, scroll_offset):
441207
self._warning_label.get_content_height(int(self._rect.width - 32)),
442208
))
443209

444-
duration = rl.get_time() - self._start_time
445-
if duration > self.ANIMATION_PAUSE * 5:
446-
# reset animation
447-
self._start_time = rl.get_time()
448-
elif duration > self.ANIMATION_PAUSE * 4:
449-
self._torque_bar.update_filter(-1.0)
450-
elif duration > self.ANIMATION_PAUSE * 3:
451-
self._torque_bar.update_filter(-0.2)
452-
elif duration > self.ANIMATION_PAUSE * 2:
453-
self._torque_bar.update_filter(1.0)
454-
elif duration > self.ANIMATION_PAUSE:
455-
self._torque_bar.update_filter(0.7)
456-
else:
457-
self._torque_bar.update_filter(0.0)
458-
459-
# background gradient for torque bar legibility
460-
rl.draw_rectangle_gradient_v(int(self._rect.x), int(self._rect.y + self._rect.height * 0.6),
461-
int(self._rect.width), int(self._rect.height * 0.2),
462-
rl.BLANK, rl.Color(0, 0, 0, int(255 * 0.9)))
463-
rl.draw_rectangle(int(self._rect.x), int(self._rect.y + self._rect.height * 0.8),
464-
int(self._rect.width), int(self._rect.height * 0.2),
465-
rl.Color(0, 0, 0, int(255 * 0.9)))
466-
467-
# scroll torque bar once we get to the bottom of content
468-
torque_y_offset = min(0.0, self._warning_label.rect.y + self._warning_label.rect.height -
469-
self._rect.height + self.TORQUE_BAR_HEIGHT)
470-
torque_rect = rl.Rectangle(
471-
self._rect.x,
472-
self._rect.y + torque_y_offset,
473-
self._rect.width,
474-
self._rect.height,
475-
)
476-
self._torque_bar.render(torque_rect)
477-
478210

479211
class TrainingGuide(Widget):
480212
def __init__(self, completed_callback=None):
@@ -483,17 +215,10 @@ def __init__(self, completed_callback=None):
483215
self._step = 0
484216

485217
self._steps = [
486-
TrainingGuideIntro(continue_callback=self._advance_step),
487-
TrainingGuideAttentionNotice1(continue_callback=self._advance_step),
488-
TrainingGuideAttentionNotice2(continue_callback=self._advance_step),
218+
TrainingGuideAttentionNotice(continue_callback=self._advance_step),
489219
TrainingGuidePreDMTutorial(continue_callback=self._advance_step),
490220
TrainingGuideDMTutorial(continue_callback=self._advance_step),
491221
TrainingGuideRecordFront(continue_callback=self._advance_step),
492-
TrainingGuideEngaging(continue_callback=self._advance_step),
493-
TrainingGuideDisengaging(continue_callback=self._advance_step),
494-
TrainingGuideConfidenceBall(continue_callback=self._advance_step),
495-
TrainingGuideSteeringArc(continue_callback=self._advance_step),
496-
TrainingGuideEnd(continue_callback=self._advance_step),
497222
]
498223

499224
def _advance_step(self):

0 commit comments

Comments
 (0)