Visuals - Custom Alerts - Green light alert

Get an alert when a traffic light changes from red to green.
This commit is contained in:
FrogAi
2024-07-23 00:29:11 -07:00
parent ea9d42aea3
commit acff272b4b
3 changed files with 19 additions and 1 deletions
+9 -1
View File
@@ -32,7 +32,7 @@ from openpilot.selfdrive.controls.lib.vehicle_model import VehicleModel
from openpilot.system.hardware import HARDWARE
from openpilot.selfdrive.frogpilot.controls.lib.frogpilot_variables import FrogPilotVariables
from openpilot.selfdrive.frogpilot.controls.lib.frogpilot_variables import CRUISING_SPEED, FrogPilotVariables
from openpilot.selfdrive.frogpilot.controls.lib.speed_limit_controller import SpeedLimitController
SOFT_DISABLE_TIME = 3 # seconds
@@ -201,6 +201,7 @@ class Controls:
self.resume_previously_pressed = False
self.speed_check = False
self.speed_limit_changed = False
self.stopped_for_light = False
self.update_toggles = False
self.display_timer = 0
@@ -913,6 +914,13 @@ class Controls:
if frogpilotPlan.forcingStop:
self.events.add(EventName.forcingStop)
if self.frogpilot_toggles.green_light_alert and not self.sm['longitudinalPlan'].hasLead and CS.standstill:
if frogpilotPlan.greenLight and self.stopped_for_light:
self.events.add(EventName.greenLight)
self.stopped_for_light = frogpilotPlan.redLight
else:
self.stopped_for_light = False
if not self.openpilot_crashed_triggered and os.path.isfile(os.path.join(sentry.CRASHES_DIR, 'error.txt')):
self.events.add(EventName.openpilotCrashed)
self.openpilot_crashed_triggered = True
+8
View File
@@ -994,6 +994,14 @@ EVENTS: dict[int, dict[str, Alert | AlertCallbackType]] = {
Priority.MID, VisualAlert.none, AudibleAlert.prompt, 1.),
},
EventName.greenLight: {
ET.PERMANENT: Alert(
"Light turned green",
"",
AlertStatus.frogpilot, AlertSize.small,
Priority.MID, VisualAlert.none, AudibleAlert.prompt, 3.),
},
EventName.noLaneAvailable: {
ET.PERMANENT: no_lane_available_alert,
},
@@ -318,6 +318,8 @@ class FrogPilotPlanner:
frogpilotPlan.forcingStop = self.forcing_stop
frogpilotPlan.greenLight = not self.model_stopped
frogpilotPlan.laneWidthLeft = self.lane_width_left
frogpilotPlan.laneWidthRight = self.lane_width_right