mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-15 22:32:11 +08:00
Green light alert
Added toggle to alert the user when a red light turns to green.
This commit is contained in:
@@ -120,6 +120,7 @@ struct CarEvent @0x9b1657f34caf3ad3 {
|
||||
# FrogPilot events
|
||||
blockUser @123;
|
||||
goatSteerSaturated @125;
|
||||
greenLight @126;
|
||||
|
||||
radarCanErrorDEPRECATED @15;
|
||||
communityFeatureDisallowedDEPRECATED @62;
|
||||
|
||||
@@ -42,6 +42,7 @@ struct FrogPilotPlan @0x80ae746ee2596b11 {
|
||||
laneWidthRight @9 :Float32;
|
||||
minAcceleration @10 :Float32;
|
||||
maxAcceleration @11 :Float32;
|
||||
redLight @12 :Bool;
|
||||
safeObstacleDistance @13 :Int16;
|
||||
safeObstacleDistanceStock @14 :Int16;
|
||||
stoppedEquivalenceFactor @19 :Int16;
|
||||
|
||||
@@ -277,6 +277,7 @@ std::unordered_map<std::string, uint32_t> keys = {
|
||||
{"FullMap", PERSISTENT},
|
||||
{"GasRegenCmd", PERSISTENT},
|
||||
{"GoatScream", PERSISTENT},
|
||||
{"GreenLightAlert", PERSISTENT},
|
||||
{"HideAOLStatusBar", PERSISTENT},
|
||||
{"HideCEMStatusBar", PERSISTENT},
|
||||
{"HideDisableOpenpilotLongitudinal", PERSISTENT},
|
||||
|
||||
@@ -33,7 +33,7 @@ from openpilot.selfdrive.controls.lib.vehicle_model import VehicleModel
|
||||
from openpilot.system.hardware import HARDWARE
|
||||
from openpilot.system.version import get_short_branch
|
||||
|
||||
from openpilot.selfdrive.frogpilot.controls.lib.frogpilot_functions import CRUISING_SPEED
|
||||
from openpilot.selfdrive.frogpilot.controls.lib.frogpilot_functions import CRUISING_SPEED, PROBABILITY, MovingAverageCalculator
|
||||
|
||||
SOFT_DISABLE_TIME = 3 # seconds
|
||||
LDW_MIN_SPEED = 31 * CV.MPH_TO_MS
|
||||
@@ -183,6 +183,10 @@ class Controls:
|
||||
self.always_on_lateral = self.params.get_bool("AlwaysOnLateral")
|
||||
self.always_on_lateral_main = self.always_on_lateral and self.params.get_bool("AlwaysOnLateralMain")
|
||||
|
||||
self.previously_enabled = False
|
||||
|
||||
self.green_light_mac = MovingAverageCalculator()
|
||||
|
||||
self.update_frogpilot_params()
|
||||
|
||||
def set_initial_state(self):
|
||||
@@ -892,6 +896,17 @@ class Controls:
|
||||
self.events.add(EventName.blockUser)
|
||||
return
|
||||
|
||||
if self.green_light_alert:
|
||||
green_light = not self.sm['frogpilotPlan'].redLight
|
||||
green_light &= not CS.gasPressed
|
||||
green_light &= not self.sm['longitudinalPlan'].hasLead
|
||||
green_light &= self.previously_enabled
|
||||
green_light &= CS.standstill
|
||||
|
||||
self.green_light_mac.add_data(green_light)
|
||||
if self.green_light_mac.get_moving_average() >= PROBABILITY:
|
||||
self.events.add(EventName.greenLight)
|
||||
|
||||
def update_frogpilot_variables(self, CS):
|
||||
self.driving_gear = CS.gearShifter not in (GearShifter.neutral, GearShifter.park, GearShifter.reverse, GearShifter.unknown)
|
||||
|
||||
@@ -912,6 +927,9 @@ class Controls:
|
||||
else:
|
||||
self.params.put_bool_nonblocking("ExperimentalMode", not self.experimental_mode)
|
||||
|
||||
self.previously_enabled |= (self.enabled or self.FPCC.alwaysOnLateral) and CS.vEgo > CRUISING_SPEED
|
||||
self.previously_enabled &= self.driving_gear
|
||||
|
||||
fpcc_send = messaging.new_message('frogpilotCarControl')
|
||||
fpcc_send.valid = CS.canValid
|
||||
fpcc_send.frogpilotCarControl = self.FPCC
|
||||
@@ -926,6 +944,7 @@ class Controls:
|
||||
self.frogpilot_variables.conditional_experimental_mode = self.CP.openpilotLongitudinalControl and self.params.get_bool("ConditionalExperimental")
|
||||
|
||||
custom_alerts = self.params.get_bool("CustomAlerts")
|
||||
self.green_light_alert = custom_alerts and self.params.get_bool("GreenLightAlert")
|
||||
|
||||
custom_theme = self.params.get_bool("CustomTheme")
|
||||
custom_sounds = self.params.get_int("CustomSounds") if custom_theme else 0
|
||||
|
||||
@@ -975,6 +975,14 @@ EVENTS: dict[int, dict[str, Alert | AlertCallbackType]] = {
|
||||
AlertStatus.userPrompt, AlertSize.mid,
|
||||
Priority.LOW, VisualAlert.steerRequired, AudibleAlert.goat, 2.),
|
||||
},
|
||||
|
||||
EventName.greenLight: {
|
||||
ET.PERMANENT: Alert(
|
||||
"Light turned green",
|
||||
"",
|
||||
AlertStatus.frogpilot, AlertSize.small,
|
||||
Priority.MID, VisualAlert.none, AudibleAlert.prompt, 3.),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ class FrogPilotPlanner:
|
||||
|
||||
self.v_cruise = self.update_v_cruise(carState, controlsState, controlsState.enabled, liveLocationKalman, modelData, road_curvature, v_cruise, v_ego)
|
||||
|
||||
if self.conditional_experimental_mode and self.CP.openpilotLongitudinalControl:
|
||||
if self.conditional_experimental_mode and self.CP.openpilotLongitudinalControl or self.green_light_alert:
|
||||
self.cem.update(carState, controlsState.enabled, frogpilotNavigation, modelData, radarState, road_curvature, self.t_follow, v_ego)
|
||||
|
||||
def update_follow_values(self, jerk, radarState, t_follow, v_ego, v_lead):
|
||||
@@ -162,6 +162,8 @@ class FrogPilotPlanner:
|
||||
frogpilotPlan.tFollow = float(self.t_follow)
|
||||
frogpilotPlan.vCruise = float(self.v_cruise)
|
||||
|
||||
frogpilotPlan.redLight = self.cem.red_light_detected
|
||||
|
||||
pm.send('frogpilotPlan', frogpilot_plan_send)
|
||||
|
||||
def update_frogpilot_params(self):
|
||||
@@ -172,6 +174,7 @@ class FrogPilotPlanner:
|
||||
self.cem.update_frogpilot_params()
|
||||
|
||||
custom_alerts = self.params.get_bool("CustomAlerts")
|
||||
self.green_light_alert = custom_alerts and self.params.get_bool("GreenLightAlert")
|
||||
|
||||
self.custom_personalities = self.params.get_bool("CustomPersonalities")
|
||||
self.aggressive_jerk = self.params.get_float("AggressiveJerk")
|
||||
|
||||
@@ -15,6 +15,7 @@ FrogPilotVisualsPanel::FrogPilotVisualsPanel(SettingsWindow *parent) : FrogPilot
|
||||
{"WarningImmediateVolume", tr("Warning Immediate Volume"), tr("Related alerts:\n\nDISENGAGE IMMEDIATELY, Driver Distracted\nDISENGAGE IMMEDIATELY, Driver Unresponsive"), ""},
|
||||
|
||||
{"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."), ""},
|
||||
|
||||
{"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 = {};
|
||||
std::set<QString> customAlertsKeys = {"GreenLightAlert"};
|
||||
std::set<QString> customOnroadUIKeys = {"CustomPaths", "DeveloperUI", "FPSCounter", "LeadInfo"};
|
||||
std::set<QString> customThemeKeys = {"CustomColors", "CustomIcons", "CustomSignals", "CustomSounds"};
|
||||
std::set<QString> modelUIKeys = {"DynamicPathWidth", "HideLeadMarker", "LaneLinesWidth", "PathEdgeWidth", "PathWidth", "RoadEdgesWidth", "UnlimitedLength"};
|
||||
|
||||
Reference in New Issue
Block a user