mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-22 08:43:54 +08:00
Lead departing alert
Added toggle to enable an alert when the lead vehicle starts to depart.
This commit is contained in:
@@ -122,6 +122,7 @@ struct CarEvent @0x9b1657f34caf3ad3 {
|
||||
goatSteerSaturated @125;
|
||||
greenLight @126;
|
||||
holidayActive @127;
|
||||
leadDeparting @129;
|
||||
|
||||
radarCanErrorDEPRECATED @15;
|
||||
communityFeatureDisallowedDEPRECATED @62;
|
||||
|
||||
@@ -292,6 +292,7 @@ std::unordered_map<std::string, uint32_t> keys = {
|
||||
{"IncreaseThermalLimits", PERSISTENT},
|
||||
{"LaneLinesWidth", PERSISTENT},
|
||||
{"LateralTune", PERSISTENT},
|
||||
{"LeadDepartingAlert", PERSISTENT},
|
||||
{"LeadInfo", PERSISTENT},
|
||||
{"LongitudinalTune", PERSISTENT},
|
||||
{"LongPitch", PERSISTENT},
|
||||
|
||||
@@ -186,6 +186,8 @@ class Controls:
|
||||
self.holiday_theme_alerted = False
|
||||
self.previously_enabled = False
|
||||
|
||||
self.previous_lead_distance = 0
|
||||
|
||||
self.green_light_mac = MovingAverageCalculator()
|
||||
|
||||
self.update_frogpilot_params()
|
||||
@@ -912,6 +914,20 @@ class Controls:
|
||||
self.events.add(EventName.holidayActive)
|
||||
self.holiday_theme_alerted = True
|
||||
|
||||
if self.lead_departing_alert and self.sm.frame % 50 == 0:
|
||||
lead = self.sm['radarState'].leadOne
|
||||
lead_distance = lead.dRel
|
||||
|
||||
lead_departing = lead_distance - self.previous_lead_distance > 0.5 and self.previous_lead_distance != 0 and CS.standstill
|
||||
self.previous_lead_distance = lead_distance
|
||||
|
||||
lead_departing &= not CS.gasPressed
|
||||
lead_departing &= lead.vLead > 1
|
||||
lead_departing &= self.driving_gear
|
||||
|
||||
if lead_departing:
|
||||
self.events.add(EventName.leadDeparting)
|
||||
|
||||
def update_frogpilot_variables(self, CS):
|
||||
self.driving_gear = CS.gearShifter not in (GearShifter.neutral, GearShifter.park, GearShifter.reverse, GearShifter.unknown)
|
||||
|
||||
@@ -950,6 +966,7 @@ class Controls:
|
||||
|
||||
custom_alerts = self.params.get_bool("CustomAlerts")
|
||||
self.green_light_alert = custom_alerts and self.params.get_bool("GreenLightAlert")
|
||||
self.lead_departing_alert = custom_alerts and self.params.get_bool("LeadDepartingAlert")
|
||||
|
||||
custom_theme = self.params.get_bool("CustomTheme")
|
||||
custom_sounds = self.params.get_int("CustomSounds") if custom_theme else 0
|
||||
|
||||
@@ -1010,6 +1010,14 @@ EVENTS: dict[int, dict[str, Alert | AlertCallbackType]] = {
|
||||
EventName.holidayActive: {
|
||||
ET.PERMANENT: holiday_alert,
|
||||
},
|
||||
|
||||
EventName.leadDeparting: {
|
||||
ET.PERMANENT: Alert(
|
||||
"Lead departed",
|
||||
"",
|
||||
AlertStatus.frogpilot, AlertSize.small,
|
||||
Priority.MID, VisualAlert.none, AudibleAlert.prompt, 3.),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ FrogPilotVisualsPanel::FrogPilotVisualsPanel(SettingsWindow *parent) : FrogPilot
|
||||
|
||||
{"CustomAlerts", tr("Custom Alerts"), tr("Enable custom alerts for openpilot events."), "../frogpilot/assets/toggle_icons/icon_green_light.png"},
|
||||
{"GreenLightAlert", tr("Green Light Alert"), tr("Get an alert when a traffic light changes from red to green."), ""},
|
||||
{"LeadDepartingAlert", tr("Lead Departing Alert"), tr("Get an alert when the lead vehicle starts departing when at a standstill."), ""},
|
||||
|
||||
{"CustomUI", tr("Custom Onroad UI"), tr("Customize the Onroad UI."), "../assets/offroad/icon_road.png"},
|
||||
{"DeveloperUI", tr("Developer UI"), tr("Get various detailed information of what openpilot is doing behind the scenes."), ""},
|
||||
|
||||
@@ -24,7 +24,7 @@ private:
|
||||
void updateToggles();
|
||||
|
||||
std::set<QString> alertVolumeControlKeys = {"DisengageVolume", "EngageVolume", "PromptDistractedVolume", "PromptVolume", "RefuseVolume", "WarningImmediateVolume", "WarningSoftVolume"};
|
||||
std::set<QString> customAlertsKeys = {"GreenLightAlert"};
|
||||
std::set<QString> customAlertsKeys = {"GreenLightAlert", "LeadDepartingAlert"};
|
||||
std::set<QString> customOnroadUIKeys = {"CustomPaths", "DeveloperUI", "FPSCounter", "LeadInfo"};
|
||||
std::set<QString> customThemeKeys = {"CustomColors", "CustomIcons", "CustomSignals", "CustomSounds", "HolidayThemes"};
|
||||
std::set<QString> modelUIKeys = {"DynamicPathWidth", "HideLeadMarker", "LaneLinesWidth", "PathEdgeWidth", "PathWidth", "RoadEdgesWidth", "UnlimitedLength"};
|
||||
|
||||
Reference in New Issue
Block a user