Random Events

This commit is contained in:
FrogAi
2024-01-12 22:39:30 -07:00
parent f71e0b629f
commit deb2b8d247
18 changed files with 56 additions and 5 deletions

View File

@@ -407,6 +407,8 @@ struct CarControl {
prompt @6; prompt @6;
promptRepeat @7; promptRepeat @7;
promptDistracted @8; promptDistracted @8;
firefox @9;
} }
} }

View File

@@ -24,6 +24,9 @@ enum FrogPilotEvents @0xf35cc4560bbf6ec2 {
torqueNNLoad @3; torqueNNLoad @3;
turningLeft @4; turningLeft @4;
turningRight @5; turningRight @5;
# Random Events
firefoxSteerSaturated @6;
} }
struct FrogPilotLateralPlan @0xda96579883444c35 { struct FrogPilotLateralPlan @0xda96579883444c35 {

View File

@@ -243,6 +243,7 @@ std::unordered_map<std::string, uint32_t> keys = {
{"CEStopLightsLead", PERSISTENT}, {"CEStopLightsLead", PERSISTENT},
{"Compass", PERSISTENT}, {"Compass", PERSISTENT},
{"ConditionalExperimental", PERSISTENT}, {"ConditionalExperimental", PERSISTENT},
{"CurrentRandomEvent", PERSISTENT},
{"CurveSensitivity", PERSISTENT}, {"CurveSensitivity", PERSISTENT},
{"CustomColors", PERSISTENT}, {"CustomColors", PERSISTENT},
{"CustomIcons", PERSISTENT}, {"CustomIcons", PERSISTENT},
@@ -317,6 +318,7 @@ std::unordered_map<std::string, uint32_t> keys = {
{"PreviousSpeedLimit", PERSISTENT}, {"PreviousSpeedLimit", PERSISTENT},
{"QOLControls", PERSISTENT}, {"QOLControls", PERSISTENT},
{"QOLVisuals", PERSISTENT}, {"QOLVisuals", PERSISTENT},
{"RandomEvents", PERSISTENT},
{"RelaxedFollow", PERSISTENT}, {"RelaxedFollow", PERSISTENT},
{"RelaxedJerk", PERSISTENT}, {"RelaxedJerk", PERSISTENT},
{"ReverseCruise", PERSISTENT}, {"ReverseCruise", PERSISTENT},

Binary file not shown.

View File

@@ -82,8 +82,11 @@ class Controls:
fire_the_babysitter = self.params.get_bool("FireTheBabysitter") fire_the_babysitter = self.params.get_bool("FireTheBabysitter")
mute_dm = fire_the_babysitter and self.params.get_bool("MuteDM") mute_dm = fire_the_babysitter and self.params.get_bool("MuteDM")
self.random_event_triggered = False
self.stopped_for_light_previously = False self.stopped_for_light_previously = False
self.random_event_timer = 0
ignore = self.sensor_packets + ['testJoystick'] ignore = self.sensor_packets + ['testJoystick']
if SIMULATION: if SIMULATION:
ignore += ['driverCameraState', 'managerState'] ignore += ['driverCameraState', 'managerState']
@@ -629,6 +632,14 @@ class Controls:
long_plan = self.sm['longitudinalPlan'] long_plan = self.sm['longitudinalPlan']
frogpilot_long_plan = self.sm['frogpilotLongitudinalPlan'] frogpilot_long_plan = self.sm['frogpilotLongitudinalPlan']
# Reset the Random Event flag
if self.random_event_triggered:
self.random_event_timer += 1
if self.random_event_timer >= 400:
self.random_event_triggered = False
self.random_event_timer = 0
self.params_memory.remove("CurrentRandomEvent")
CC = car.CarControl.new_message() CC = car.CarControl.new_message()
CC.enabled = self.enabled CC.enabled = self.enabled
@@ -730,8 +741,13 @@ class Controls:
turning = abs(lac_log.desiredLateralAccel) > 1.0 turning = abs(lac_log.desiredLateralAccel) > 1.0
good_speed = CS.vEgo > 5 good_speed = CS.vEgo > 5
max_torque = abs(self.last_actuators.steer) > 0.99 max_torque = abs(self.last_actuators.steer) > 0.99
if undershooting and turning and good_speed and max_torque: if undershooting and turning and good_speed and max_torque and not self.random_event_triggered:
lac_log.active and self.events.add(FrogPilotEventName.frogSteerSaturated if self.goat_scream else EventName.steerSaturated) if self.sm.frame % 10000 == 0:
lac_log.active and self.events.add(FrogPilotEventName.firefoxSteerSaturated)
self.params_memory.put_int("CurrentRandomEvent", 1)
self.random_event_triggered = True
else:
lac_log.active and self.events.add(FrogPilotEventName.frogSteerSaturated if self.goat_scream else EventName.steerSaturated)
elif lac_log.saturated: elif lac_log.saturated:
dpath_points = lat_plan.dPathPoints dpath_points = lat_plan.dPathPoints
if len(dpath_points): if len(dpath_points):
@@ -1004,6 +1020,8 @@ class Controls:
self.reverse_cruise_increase = self.params.get_bool("ReverseCruise") and quality_of_life self.reverse_cruise_increase = self.params.get_bool("ReverseCruise") and quality_of_life
self.set_speed_offset = self.params.get_int("SetSpeedOffset") * (1 if self.is_metric else CV.MPH_TO_KPH) if quality_of_life else 0 self.set_speed_offset = self.params.get_int("SetSpeedOffset") * (1 if self.is_metric else CV.MPH_TO_KPH) if quality_of_life else 0
self.random_events = self.params.get_bool("RandomEvents")
def main(): def main():
controls = Controls() controls = Controls()
controls.controlsd_thread() controls.controlsd_thread()

View File

@@ -1028,6 +1028,14 @@ EVENTS: Dict[int, Dict[str, Union[Alert, AlertCallbackType]]] = {
Priority.LOW, VisualAlert.none, AudibleAlert.none, .1, alert_rate=0.75), Priority.LOW, VisualAlert.none, AudibleAlert.none, .1, alert_rate=0.75),
}, },
# Random Events
FrogPilotEventName.firefoxSteerSaturated: {
ET.WARNING: Alert(
"Turn Exceeds Steering Limit",
"IE Has Stopped Responding...",
AlertStatus.userPrompt, AlertSize.mid,
Priority.LOW, VisualAlert.steerRequired, AudibleAlert.firefox, 4.),
},
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

View File

@@ -35,6 +35,7 @@ FrogPilotVisualsPanel::FrogPilotVisualsPanel(SettingsWindow *parent) : FrogPilot
{"HideSpeed", "Hide Speed", "Hide the speed indicator in the onroad UI.", ""}, {"HideSpeed", "Hide Speed", "Hide the speed indicator in the onroad UI.", ""},
{"ShowSLCOffset", "Show Speed Limit Offset", "Show the speed limit offset seperated from the speed limit in the onroad UI when using 'Speed Limit Controller'.", ""}, {"ShowSLCOffset", "Show Speed Limit Offset", "Show the speed limit offset seperated from the speed limit in the onroad UI when using 'Speed Limit Controller'.", ""},
{"RandomEvents", "Random Events", "Enjoy a bit of unpredictability with random events that can occur during certain driving conditions.", "../frogpilot/assets/toggle_icons/icon_random.png"},
{"ScreenBrightness", "Screen Brightness", "Customize your screen brightness.", "../frogpilot/assets/toggle_icons/icon_light.png"}, {"ScreenBrightness", "Screen Brightness", "Customize your screen brightness.", "../frogpilot/assets/toggle_icons/icon_light.png"},
{"SilentMode", "Silent Mode", "Mute openpilot sounds for a quieter driving experience.", "../frogpilot/assets/toggle_icons/icon_mute.png"}, {"SilentMode", "Silent Mode", "Mute openpilot sounds for a quieter driving experience.", "../frogpilot/assets/toggle_icons/icon_mute.png"},
{"WheelIcon", "Steering Wheel Icon", "Replace the default steering wheel icon with a custom design, adding a unique touch to your interface.", "../assets/offroad/icon_openpilot.png"}, {"WheelIcon", "Steering Wheel Icon", "Replace the default steering wheel icon with a custom design, adding a unique touch to your interface.", "../assets/offroad/icon_openpilot.png"},

View File

@@ -376,7 +376,8 @@ ExperimentalButton::ExperimentalButton(QWidget *parent) : experimental_mode(fals
{3, loadPixmap("../frogpilot/assets/wheel_images/frog.png", {img_size, img_size})}, {3, loadPixmap("../frogpilot/assets/wheel_images/frog.png", {img_size, img_size})},
{4, loadPixmap("../frogpilot/assets/wheel_images/rocket.png", {img_size, img_size})}, {4, loadPixmap("../frogpilot/assets/wheel_images/rocket.png", {img_size, img_size})},
{5, loadPixmap("../frogpilot/assets/wheel_images/hyundai.png", {img_size, img_size})}, {5, loadPixmap("../frogpilot/assets/wheel_images/hyundai.png", {img_size, img_size})},
{6, loadPixmap("../frogpilot/assets/wheel_images/stalin.png", {img_size, img_size})} {6, loadPixmap("../frogpilot/assets/wheel_images/stalin.png", {img_size, img_size})},
{7, loadPixmap("../frogpilot/assets/wheel_images/firefox.png", {img_size, img_size})}
}; };
} }
@@ -405,13 +406,20 @@ void ExperimentalButton::updateState(const UIState &s, bool leadInfo) {
} }
// FrogPilot variables // FrogPilot variables
firefoxRandomEventTriggered = scene.current_random_event == 1;
rotatingWheel = scene.rotating_wheel; rotatingWheel = scene.rotating_wheel;
wheelIcon = scene.wheel_icon; wheelIcon = scene.wheel_icon;
y_offset = leadInfo ? 10 : 0; y_offset = leadInfo ? 10 : 0;
if (firefoxRandomEventTriggered) {
static int rotationDegree = 0;
rotationDegree = (rotationDegree + 36) % 360;
steeringAngleDeg = rotationDegree;
wheelIcon = 7;
update();
// Update the icon so the steering wheel rotates in real time // Update the icon so the steering wheel rotates in real time
if (rotatingWheel && steeringAngleDeg != scene.steering_angle_deg) { } else if (rotatingWheel && steeringAngleDeg != scene.steering_angle_deg) {
steeringAngleDeg = scene.steering_angle_deg; steeringAngleDeg = scene.steering_angle_deg;
update(); update();
} }
@@ -431,7 +439,7 @@ void ExperimentalButton::paintEvent(QPaintEvent *event) {
QColor(0, 0, 0, 166)); QColor(0, 0, 0, 166));
if (!scene.show_driver_camera) { if (!scene.show_driver_camera) {
if (rotatingWheel) { if (rotatingWheel || firefoxRandomEventTriggered) {
drawIconRotate(p, QPoint(btn_size / 2, btn_size / 2 + y_offset), img, background_color, (isDown() || (!engageable && !scene.always_on_lateral_active)) ? 0.6 : 1.0, steeringAngleDeg); drawIconRotate(p, QPoint(btn_size / 2, btn_size / 2 + y_offset), img, background_color, (isDown() || (!engageable && !scene.always_on_lateral_active)) ? 0.6 : 1.0, steeringAngleDeg);
} else { } else {
drawIcon(p, QPoint(btn_size / 2, btn_size / 2 + y_offset), img, background_color, (isDown() || (!engageable && !scene.always_on_lateral_active)) ? 0.6 : 1.0); drawIcon(p, QPoint(btn_size / 2, btn_size / 2 + y_offset), img, background_color, (isDown() || (!engageable && !scene.always_on_lateral_active)) ? 0.6 : 1.0);

View File

@@ -85,6 +85,7 @@ private:
std::map<int, QPixmap> wheelImages; std::map<int, QPixmap> wheelImages;
bool firefoxRandomEventTriggered;
bool rotatingWheel; bool rotatingWheel;
int steeringAngleDeg; int steeringAngleDeg;
int wheelIcon; int wheelIcon;

View File

@@ -40,6 +40,8 @@ sound_list: Dict[int, Tuple[str, Optional[int], float]] = {
AudibleAlert.warningSoft: ("warning_soft.wav", None, MAX_VOLUME), AudibleAlert.warningSoft: ("warning_soft.wav", None, MAX_VOLUME),
AudibleAlert.warningImmediate: ("warning_immediate.wav", None, MAX_VOLUME), AudibleAlert.warningImmediate: ("warning_immediate.wav", None, MAX_VOLUME),
AudibleAlert.firefox: ("firefox.wav", None, MAX_VOLUME),
} }
def check_controls_timeout_alert(sm): def check_controls_timeout_alert(sm):

View File

@@ -330,6 +330,7 @@ void ui_update_params(UIState *s) {
scene.quality_of_life_visuals = params.getBool("QOLVisuals"); scene.quality_of_life_visuals = params.getBool("QOLVisuals");
scene.full_map = params.getBool("QOLVisuals") && scene.quality_of_life_visuals; scene.full_map = params.getBool("QOLVisuals") && scene.quality_of_life_visuals;
scene.random_events = params.getBool("RandomEvents");
scene.rotating_wheel = params.getBool("RotatingWheel"); scene.rotating_wheel = params.getBool("RotatingWheel");
scene.screen_brightness = params.getInt("ScreenBrightness"); scene.screen_brightness = params.getInt("ScreenBrightness");
scene.speed_limit_controller = params.getBool("SpeedLimitController"); scene.speed_limit_controller = params.getBool("SpeedLimitController");
@@ -410,6 +411,9 @@ void UIState::update() {
if (scene.conditional_experimental) { if (scene.conditional_experimental) {
scene.conditional_status = paramsMemory.getInt("CEStatus"); scene.conditional_status = paramsMemory.getInt("CEStatus");
} }
if (scene.random_events) {
scene.current_random_event = paramsMemory.getInt("CurrentRandomEvent");
}
} }
void UIState::setPrimeType(PrimeType type) { void UIState::setPrimeType(PrimeType type) {

View File

@@ -192,6 +192,7 @@ typedef struct UIScene {
bool mute_dm; bool mute_dm;
bool personalities_via_screen; bool personalities_via_screen;
bool quality_of_life_visuals; bool quality_of_life_visuals;
bool random_events;
bool road_name_ui; bool road_name_ui;
bool rotating_wheel; bool rotating_wheel;
bool show_driver_camera; bool show_driver_camera;
@@ -218,6 +219,7 @@ typedef struct UIScene {
int conditional_speed; int conditional_speed;
int conditional_speed_lead; int conditional_speed_lead;
int conditional_status; int conditional_status;
int current_random_event;
int custom_colors; int custom_colors;
int custom_signals; int custom_signals;
int desired_follow; int desired_follow;