|
13 | 13 | from openpilot.selfdrive.locationd.calibrationd import MIN_SPEED_FILTER |
14 | 14 | from openpilot.system.micd import SAMPLE_RATE, SAMPLE_BUFFER |
15 | 15 | from openpilot.selfdrive.ui.feedback.feedbackd import FEEDBACK_MAX_DURATION |
| 16 | +from openpilot.system.hardware import HARDWARE |
16 | 17 |
|
17 | 18 | AlertSize = log.SelfdriveState.AlertSize |
18 | 19 | AlertStatus = log.SelfdriveState.AlertStatus |
@@ -150,6 +151,8 @@ class NoEntryAlert(Alert): |
150 | 151 | def __init__(self, alert_text_2: str, |
151 | 152 | alert_text_1: str = "openpilot Unavailable", |
152 | 153 | 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 |
153 | 156 | super().__init__(alert_text_1, alert_text_2, AlertStatus.normal, |
154 | 157 | AlertSize.mid, Priority.LOW, visual_alert, |
155 | 158 | AudibleAlert.refuse, 3.) |
@@ -195,8 +198,13 @@ def __init__(self, alert_text_1: str, alert_text_2: str = "", duration: float = |
195 | 198 |
|
196 | 199 | class StartupAlert(Alert): |
197 | 200 | 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 |
198 | 206 | super().__init__(alert_text_1, alert_text_2, |
199 | | - alert_status, AlertSize.mid, |
| 207 | + alert_status, alert_size, |
200 | 208 | Priority.LOWER, VisualAlert.none, AudibleAlert.none, 5.), |
201 | 209 |
|
202 | 210 |
|
@@ -246,10 +254,19 @@ def below_steer_speed_alert(CP: car.CarParams, CS: car.CarState, sm: messaging.S |
246 | 254 | Priority.LOW, VisualAlert.none, AudibleAlert.prompt, 0.4) |
247 | 255 |
|
248 | 256 |
|
| 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 | + |
249 | 266 | 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' |
251 | 268 | return Alert( |
252 | | - f"{first_word} in Progress: {sm['liveCalibration'].calPerc:.0f}%", |
| 269 | + f"{first_word}: {sm['liveCalibration'].calPerc:.0f}%", |
253 | 270 | f"Drive Above {get_display_speed(MIN_SPEED_FILTER, metric)}", |
254 | 271 | AlertStatus.normal, AlertSize.mid, |
255 | 272 | Priority.LOWEST, VisualAlert.none, AudibleAlert.none, .2) |
@@ -1013,6 +1030,70 @@ def invalid_lkas_setting_alert(CP: car.CarParams, CS: car.CarState, sm: messagin |
1013 | 1030 | } |
1014 | 1031 |
|
1015 | 1032 |
|
| 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 | + |
1016 | 1097 | if __name__ == '__main__': |
1017 | 1098 | # print all alerts by type and priority |
1018 | 1099 | from cereal.services import SERVICE_LIST |
|
0 commit comments