This commit is contained in:
Your Name
2024-04-27 13:43:16 -05:00
parent 21363ce751
commit ea1aad5ed1
128 changed files with 3533 additions and 1918 deletions

94
selfdrive/ui/ui.h Executable file → Normal file
View File

@@ -77,7 +77,12 @@ struct Alert {
const int controls_missing = (nanos_since_boot() - sm.rcv_time("controlsState")) / 1e9;
// Handle controls timeout
if (controls_frame < started_frame) {
if (std::ifstream("/data/community/crashes/error.txt")) {
alert = {"openpilot crashed", "Please post the error log in the FrogPilot Discord!",
"controlsWaiting", cereal::ControlsState::AlertSize::MID,
cereal::ControlsState::AlertStatus::NORMAL,
AudibleAlert::NONE};
} else if (controls_frame < started_frame) {
// car is started, but controlsState hasn't been seen at all
alert = {"openpilot Unavailable", "Waiting for controls to start",
"controlsWaiting", cereal::ControlsState::AlertSize::MID,
@@ -108,7 +113,9 @@ typedef enum UIStatus {
STATUS_ENGAGED,
// FrogPilot statuses
STATUS_LATERAL_ACTIVE,
STATUS_ALWAYS_ON_LATERAL_ACTIVE,
STATUS_TRAFFIC_MODE_ACTIVE,
} UIStatus;
enum PrimeType {
@@ -127,7 +134,8 @@ const QColor bg_colors [] = {
[STATUS_ENGAGED] = QColor(0x17, 0x86, 0x44, 0xf1),
// FrogPilot colors
[STATUS_LATERAL_ACTIVE] = QColor(0x0a, 0xba, 0xb5, 0xf1),
[STATUS_ALWAYS_ON_LATERAL_ACTIVE] = QColor(0x0a, 0xba, 0xb5, 0xf1),
[STATUS_TRAFFIC_MODE_ACTIVE] = QColor(0xc9, 0x22, 0x31, 0xf1),
};
static std::map<cereal::ControlsState::AlertStatus, QColor> alert_colors = {
@@ -163,6 +171,7 @@ typedef struct UIScene {
vec3 face_kpts_draw[std::size(default_face_kpts_3d)];
bool navigate_on_openpilot = false;
cereal::LongitudinalPersonality personality;
float light_sensor;
bool started, ignition, is_metric, map_on_left, longitudinal_control;
@@ -172,69 +181,117 @@ typedef struct UIScene {
// FrogPilot variables
bool acceleration_path;
bool adjacent_path;
bool always_on_lateral;
bool adjacent_path_metrics;
bool always_on_lateral_active;
bool big_map;
bool blind_spot_left;
bool blind_spot_path;
bool blind_spot_right;
bool compass;
bool conditional_experimental;
bool custom_onroad_ui;
bool custom_theme;
bool disable_smoothing_mtsc;
bool disable_smoothing_vtsc;
bool driver_camera;
bool dynamic_path_width;
bool enabled;
bool experimental_mode;
bool experimental_mode_via_screen;
bool fahrenheit;
bool fps_counter;
bool full_map;
bool has_auto_tune;
bool hide_alerts;
bool hide_lead_marker;
bool hide_map_icon;
bool hide_max_speed;
bool hide_speed;
bool hide_speed_ui;
bool holiday_themes;
bool lead_info;
bool live_valid;
bool map_open;
bool model_ui;
bool mute_dm;
bool personalities_via_screen;
bool quality_of_life_controls;
bool quality_of_life_visuals;
bool numerical_temp;
bool online;
bool onroad_distance_button;
bool parked;
bool pedals_on_ui;
bool random_events;
bool reverse;
bool reverse_cruise;
bool reverse_cruise_ui;
bool right_hand_drive;
bool road_name_ui;
bool rotating_wheel;
bool show_driver_camera;
bool screen_recorder;
bool show_aol_status_bar;
bool show_cem_status_bar;
bool show_jerk;
bool show_slc_offset;
bool show_fps;
bool show_slc_offset_ui;
bool show_tuning;
bool speed_limit_changed;
bool speed_limit_controller;
bool speed_limit_overridden;
bool standby_mode;
bool standstill;
bool tethering_enabled;
bool traffic_mode;
bool traffic_mode_active;
bool turn_signal_left;
bool turn_signal_right;
bool unlimited_road_ui_length;
bool use_kaofui_icons;
bool use_si;
bool use_vienna_slc_sign;
bool vtsc_controlling_curve;
bool wake_up_screen;
bool wheel_speed;
float acceleration;
float acceleration_jerk;
float acceleration_jerk_difference;
float adjusted_cruise;
float ego_jerk;
float ego_jerk_difference;
float friction;
float lane_detection_width;
float lane_line_width;
float lane_width_left;
float lane_width_right;
float lat_accel;
float path_edge_width;
float path_width;
float road_edge_width;
float speed_limit;
float speed_limit_offset;
float speed_limit_overridden_speed;
float unconfirmed_speed_limit;
int alert_size;
int bearing_deg;
int camera_view;
int conditional_speed;
int conditional_speed_lead;
int conditional_status;
int current_holiday_theme;
int current_random_event;
int custom_colors;
int custom_icons;
int custom_signals;
int desired_follow;
int driver_camera_timer;
int map_style;
int obstacle_distance;
int obstacle_distance_stock;
int screen_brightness;
int screen_brightness_onroad;
int screen_timeout;
int screen_timeout_onroad;
int steering_angle_deg;
int stopped_equivalence;
int wheel_icon;
QPolygonF track_adjacent_vertices[6];
QPolygonF track_edge_vertices;
@@ -265,6 +322,9 @@ public:
QTransform car_space_transform;
// FrogPilot variables
WifiManager *wifi = nullptr;
signals:
void uiUpdate(const UIState &s);
void offroadTransition(bool offroad);
@@ -279,7 +339,8 @@ private:
bool started_prev = false;
PrimeType prime_type = PrimeType::UNKNOWN;
WifiManager *wifi = nullptr;
// FrogPilot variables
Params paramsMemory{"/dev/shm/params"};
};
UIState *uiState();
@@ -314,7 +375,7 @@ signals:
void interactiveTimeout();
public slots:
void resetInteractiveTimeout(int timeout = -1);
void resetInteractiveTimeout(int timeout = -1, int timeout_onroad = -1);
void update(const UIState &s);
};
@@ -326,6 +387,9 @@ void update_model(UIState *s,
const cereal::ModelDataV2::Reader &model,
const cereal::UiPlan::Reader &plan);
void update_dmonitoring(UIState *s, const cereal::DriverStateV2::Reader &driverstate, float dm_fade_state, bool is_rhd);
void update_leads(UIState *s, const cereal::RadarState::Reader &radar_state, const cereal::XYZTData::Reader &line);
void update_leads(UIState *s, const cereal::ModelDataV2::Reader &model_data);
void update_line_data(const UIState *s, const cereal::XYZTData::Reader &line,
float y_off, float z_off, QPolygonF *pvd, int max_idx, bool allow_invert);
// FrogPilot functions
void ui_update_frogpilot_params(UIState *s);