Skip to content

Commit ad7f3d2

Browse files
selfdrived: prep for mici (#36633)
* selfdrived: prep for mici * tizi reverts * more revert * lil more: * invert it * cleanup
1 parent 4ef0d3e commit ad7f3d2

File tree

2 files changed

+87
-3
lines changed

2 files changed

+87
-3
lines changed

selfdrive/selfdrived/events.py

Lines changed: 84 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from openpilot.selfdrive.locationd.calibrationd import MIN_SPEED_FILTER
1414
from openpilot.system.micd import SAMPLE_RATE, SAMPLE_BUFFER
1515
from openpilot.selfdrive.ui.feedback.feedbackd import FEEDBACK_MAX_DURATION
16+
from openpilot.system.hardware import HARDWARE
1617

1718
AlertSize = log.SelfdriveState.AlertSize
1819
AlertStatus = log.SelfdriveState.AlertStatus
@@ -150,6 +151,8 @@ class NoEntryAlert(Alert):
150151
def __init__(self, alert_text_2: str,
151152
alert_text_1: str = "openpilot Unavailable",
152153
visual_alert: car.CarControl.HUDControl.VisualAlert=VisualAlert.none):
154+
if HARDWARE.get_device_type() == 'mici':
155+
alert_text_1, alert_text_2 = alert_text_2, alert_text_1
153156
super().__init__(alert_text_1, alert_text_2, AlertStatus.normal,
154157
AlertSize.mid, Priority.LOW, visual_alert,
155158
AudibleAlert.refuse, 3.)
@@ -195,8 +198,13 @@ def __init__(self, alert_text_1: str, alert_text_2: str = "", duration: float =
195198

196199
class StartupAlert(Alert):
197200
def __init__(self, alert_text_1: str, alert_text_2: str = "Always keep hands on wheel and eyes on road", alert_status=AlertStatus.normal):
201+
alert_size = AlertSize.mid
202+
if HARDWARE.get_device_type() == 'mici':
203+
if alert_text_2 == "Always keep hands on wheel and eyes on road":
204+
alert_text_2 = ""
205+
alert_size = AlertSize.small
198206
super().__init__(alert_text_1, alert_text_2,
199-
alert_status, AlertSize.mid,
207+
alert_status, alert_size,
200208
Priority.LOWER, VisualAlert.none, AudibleAlert.none, 5.),
201209

202210

@@ -246,10 +254,19 @@ def below_steer_speed_alert(CP: car.CarParams, CS: car.CarState, sm: messaging.S
246254
Priority.LOW, VisualAlert.none, AudibleAlert.prompt, 0.4)
247255

248256

257+
def steer_saturated_alert(CP: car.CarParams, CS: car.CarState, sm: messaging.SubMaster, metric: bool, soft_disable_time: int, personality) -> Alert:
258+
steer_text2 = "Steer Left" if sm['carControl'].actuators.torque > 0 else "Steer Right"
259+
return Alert(
260+
"Take Control",
261+
steer_text2,
262+
AlertStatus.userPrompt, AlertSize.mid,
263+
Priority.LOW, VisualAlert.steerRequired, AudibleAlert.promptRepeat, 2.)
264+
265+
249266
def calibration_incomplete_alert(CP: car.CarParams, CS: car.CarState, sm: messaging.SubMaster, metric: bool, soft_disable_time: int, personality) -> Alert:
250-
first_word = 'Recalibration' if sm['liveCalibration'].calStatus == log.LiveCalibrationData.Status.recalibrating else 'Calibration'
267+
first_word = 'Recalibrating' if sm['liveCalibration'].calStatus == log.LiveCalibrationData.Status.recalibrating else 'Calibrating'
251268
return Alert(
252-
f"{first_word} in Progress: {sm['liveCalibration'].calPerc:.0f}%",
269+
f"{first_word}: {sm['liveCalibration'].calPerc:.0f}%",
253270
f"Drive Above {get_display_speed(MIN_SPEED_FILTER, metric)}",
254271
AlertStatus.normal, AlertSize.mid,
255272
Priority.LOWEST, VisualAlert.none, AudibleAlert.none, .2)
@@ -1013,6 +1030,70 @@ def invalid_lkas_setting_alert(CP: car.CarParams, CS: car.CarState, sm: messagin
10131030
}
10141031

10151032

1033+
if HARDWARE.get_device_type() == 'mici':
1034+
EVENTS.update({
1035+
EventName.preDriverDistracted: {
1036+
ET.PERMANENT: Alert(
1037+
"Pay Attention",
1038+
"",
1039+
AlertStatus.normal, AlertSize.small,
1040+
Priority.LOW, VisualAlert.none, AudibleAlert.none, 2),
1041+
},
1042+
EventName.promptDriverDistracted: {
1043+
ET.PERMANENT: Alert(
1044+
"Pay Attention",
1045+
"Driver Distracted",
1046+
AlertStatus.userPrompt, AlertSize.mid,
1047+
Priority.MID, VisualAlert.steerRequired, AudibleAlert.promptDistracted, 1),
1048+
},
1049+
EventName.resumeRequired: {
1050+
ET.WARNING: Alert(
1051+
"Press Resume",
1052+
"",
1053+
AlertStatus.userPrompt, AlertSize.small,
1054+
Priority.LOW, VisualAlert.none, AudibleAlert.none, .2),
1055+
},
1056+
EventName.preLaneChangeLeft: {
1057+
ET.WARNING: Alert(
1058+
"Steer Left",
1059+
"Confirm Lane Change",
1060+
AlertStatus.normal, AlertSize.mid,
1061+
Priority.LOW, VisualAlert.none, AudibleAlert.none, .1),
1062+
},
1063+
EventName.preLaneChangeRight: {
1064+
ET.WARNING: Alert(
1065+
"Steer Right",
1066+
"Confirm Lane Change",
1067+
AlertStatus.normal, AlertSize.mid,
1068+
Priority.LOW, VisualAlert.none, AudibleAlert.none, .1),
1069+
},
1070+
EventName.laneChangeBlocked: {
1071+
ET.WARNING: Alert(
1072+
"Car in Blindspot",
1073+
"",
1074+
AlertStatus.userPrompt, AlertSize.small,
1075+
Priority.LOW, VisualAlert.none, AudibleAlert.prompt, .1),
1076+
},
1077+
EventName.steerSaturated: {
1078+
ET.WARNING: steer_saturated_alert,
1079+
},
1080+
EventName.calibrationIncomplete: {
1081+
ET.PERMANENT: calibration_incomplete_alert,
1082+
ET.SOFT_DISABLE: soft_disable_alert("Calibration Incomplete"),
1083+
ET.NO_ENTRY: NoEntryAlert("Calibrating"),
1084+
},
1085+
EventName.reverseGear: {
1086+
ET.PERMANENT: Alert(
1087+
"Reverse",
1088+
"",
1089+
AlertStatus.normal, AlertSize.full,
1090+
Priority.LOWEST, VisualAlert.none, AudibleAlert.none, .2, creation_delay=0.5),
1091+
ET.USER_DISABLE: ImmediateDisableAlert("Reverse"),
1092+
ET.NO_ENTRY: NoEntryAlert("Reverse"),
1093+
},
1094+
})
1095+
1096+
10161097
if __name__ == '__main__':
10171098
# print all alerts by type and priority
10181099
from cereal.services import SERVICE_LIST

selfdrive/selfdrived/selfdrived.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from openpilot.selfdrive.selfdrived.alertmanager import AlertManager, set_offroad_alert
2323

2424
from openpilot.system.version import get_build_metadata
25+
from openpilot.system.hardware import HARDWARE
2526

2627
REPLAY = "REPLAY" in os.environ
2728
SIMULATION = "SIMULATION" in os.environ
@@ -123,6 +124,8 @@ def __init__(self, CP=None):
123124

124125
# Determine startup event
125126
self.startup_event = EventName.startup if build_metadata.openpilot.comma_remote and build_metadata.tested_channel else EventName.startupMaster
127+
if HARDWARE.get_device_type() == 'mici':
128+
self.startup_event = None
126129
if not car_recognized:
127130
self.startup_event = EventName.startupNoCar
128131
elif car_recognized and self.CP.passive:

0 commit comments

Comments
 (0)