wip
This commit is contained in:
318
selfdrive/ui/ui.cc
Executable file → Normal file
318
selfdrive/ui/ui.cc
Executable file → Normal file
@@ -13,8 +13,6 @@
|
||||
#include "common/watchdog.h"
|
||||
#include "system/hardware/hw.h"
|
||||
|
||||
#include "selfdrive/frogpilot/ui/frogpilot_functions.h"
|
||||
|
||||
#define BACKLIGHT_DT 0.05
|
||||
#define BACKLIGHT_TS 10.00
|
||||
|
||||
@@ -46,12 +44,15 @@ int get_path_length_idx(const cereal::XYZTData::Reader &line, const float path_h
|
||||
return max_idx;
|
||||
}
|
||||
|
||||
void update_leads(UIState *s, const cereal::RadarState::Reader &radar_state, const cereal::XYZTData::Reader &line) {
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
auto lead_data = (i == 0) ? radar_state.getLeadOne() : radar_state.getLeadTwo();
|
||||
if (lead_data.getStatus()) {
|
||||
float z = line.getZ()[get_path_length_idx(line, lead_data.getDRel())];
|
||||
calib_frame_to_full_frame(s, lead_data.getDRel(), -lead_data.getYRel(), z + 1.22, &s->scene.lead_vertices[i]);
|
||||
void update_leads(UIState *s, const cereal::ModelDataV2::Reader &model_data) {
|
||||
const cereal::XYZTData::Reader &line = model_data.getPosition();
|
||||
for (int i = 0; i < model_data.getLeadsV3().size() && i < 2; ++i) {
|
||||
const auto &lead = model_data.getLeadsV3()[i];
|
||||
if (lead.getProb() > 0.5) {
|
||||
float d_rel = lead.getX()[0];
|
||||
float y_rel = lead.getY()[0];
|
||||
float z = line.getZ()[get_path_length_idx(line, d_rel)];
|
||||
calib_frame_to_full_frame(s, d_rel, y_rel, z + 1.22, &s->scene.lead_vertices[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -99,7 +100,7 @@ void update_model(UIState *s,
|
||||
int max_idx = get_path_length_idx(lane_lines[0], max_distance);
|
||||
for (int i = 0; i < std::size(scene.lane_line_vertices); i++) {
|
||||
scene.lane_line_probs[i] = lane_line_probs[i];
|
||||
update_line_data(s, lane_lines[i], scene.model_ui ? scene.lane_line_width * scene.lane_line_probs[i] : 0.025 * scene.lane_line_probs[i], 0, &scene.lane_line_vertices[i], max_idx);
|
||||
update_line_data(s, lane_lines[i], (scene.model_ui ? scene.lane_line_width : 0.025) * scene.lane_line_probs[i], 0, &scene.lane_line_vertices[i], max_idx);
|
||||
}
|
||||
|
||||
// update road edges
|
||||
@@ -111,20 +112,31 @@ void update_model(UIState *s,
|
||||
}
|
||||
|
||||
// update path
|
||||
auto lead_one = (*s->sm)["radarState"].getRadarState().getLeadOne();
|
||||
if (lead_one.getStatus()) {
|
||||
const float lead_d = lead_one.getDRel() * 2.;
|
||||
max_distance = std::clamp((float)(lead_d - fmin(lead_d * 0.35, 10.)), 0.0f, max_distance);
|
||||
float path;
|
||||
if (scene.dynamic_path_width) {
|
||||
float multiplier = scene.enabled ? 1.0f : scene.always_on_lateral_active ? 0.75f : 0.50f;
|
||||
path = scene.path_width * multiplier;
|
||||
} else {
|
||||
path = scene.path_width;
|
||||
}
|
||||
|
||||
auto lead_count = model.getLeadsV3().size();
|
||||
if (lead_count > 0) {
|
||||
auto lead_one = model.getLeadsV3()[0];
|
||||
if (lead_one.getProb() > 0.5) {
|
||||
const float lead_d = lead_one.getX()[0] * 2.;
|
||||
max_distance = std::clamp((float)(lead_d - fmin(lead_d * 0.35, 10.)), 0.0f, max_distance);
|
||||
}
|
||||
}
|
||||
max_idx = get_path_length_idx(plan_position, max_distance);
|
||||
update_line_data(s, plan_position, scene.model_ui ? scene.path_width * (1 - scene.path_edge_width / 100) : 0.9, 1.22, &scene.track_vertices, max_idx, false);
|
||||
update_line_data(s, plan_position, scene.model_ui ? path * (1 - scene.path_edge_width / 100) : 0.9, 1.22, &scene.track_vertices, max_idx, false);
|
||||
|
||||
// update path edges
|
||||
update_line_data(s, plan_position, scene.model_ui ? scene.path_width : 0, 1.22, &scene.track_edge_vertices, max_idx, false);
|
||||
// Update path edges
|
||||
update_line_data(s, plan_position, scene.model_ui ? path : 0, 1.22, &scene.track_edge_vertices, max_idx, false);
|
||||
|
||||
// update adjacent paths
|
||||
// Update adjacent paths
|
||||
for (int i = 4; i <= 5; i++) {
|
||||
update_line_data(s, lane_lines[i], scene.blind_spot_path ? (i == 4 ? scene.lane_width_left : scene.lane_width_right) / 2 : 0, 0, &scene.track_adjacent_vertices[i], max_idx);
|
||||
update_line_data(s, lane_lines[i], (i == 4 ? scene.lane_width_left : scene.lane_width_right) / 2.0f, 0, &scene.track_adjacent_vertices[i], max_idx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,6 +171,8 @@ void update_dmonitoring(UIState *s, const cereal::DriverStateV2::Reader &drivers
|
||||
kpt_this = matvecmul3(r_xyz, kpt_this);
|
||||
scene.face_kpts_draw[kpi] = (vec3){{(float)kpt_this.v[0], (float)kpt_this.v[1], (float)(kpt_this.v[2] * (1.0-dm_fade_state) + 8 * dm_fade_state)}};
|
||||
}
|
||||
|
||||
scene.right_hand_drive = is_rhd;
|
||||
}
|
||||
|
||||
static void update_sockets(UIState *s) {
|
||||
@@ -211,67 +225,69 @@ static void update_state(UIState *s) {
|
||||
}
|
||||
if (sm.updated("carParams")) {
|
||||
scene.longitudinal_control = sm["carParams"].getCarParams().getOpenpilotLongitudinalControl();
|
||||
ui_update_frogpilot_params(s);
|
||||
}
|
||||
if (sm.updated("carState")) {
|
||||
auto carState = sm["carState"].getCarState();
|
||||
if (scene.blind_spot_path || scene.custom_signals) {
|
||||
scene.blind_spot_left = carState.getLeftBlindspot();
|
||||
scene.blind_spot_right = carState.getRightBlindspot();
|
||||
}
|
||||
if (scene.custom_signals) {
|
||||
scene.turn_signal_left = carState.getLeftBlinker();
|
||||
scene.turn_signal_right = carState.getRightBlinker();
|
||||
}
|
||||
if (scene.rotating_wheel) {
|
||||
scene.steering_angle_deg = carState.getSteeringAngleDeg();
|
||||
}
|
||||
if (scene.driver_camera) {
|
||||
scene.show_driver_camera = carState.getGearShifter() == cereal::CarState::GearShifter::REVERSE;
|
||||
}
|
||||
scene.acceleration = carState.getAEgo();
|
||||
scene.blind_spot_left = carState.getLeftBlindspot();
|
||||
scene.blind_spot_right = carState.getRightBlindspot();
|
||||
scene.parked = carState.getGearShifter() == cereal::CarState::GearShifter::PARK;
|
||||
scene.reverse = carState.getGearShifter() == cereal::CarState::GearShifter::REVERSE;
|
||||
scene.standstill = carState.getStandstill();
|
||||
scene.steering_angle_deg = carState.getSteeringAngleDeg();
|
||||
scene.turn_signal_left = carState.getLeftBlinker();
|
||||
scene.turn_signal_right = carState.getRightBlinker();
|
||||
}
|
||||
if (sm.updated("controlsState")) {
|
||||
auto controlsState = sm["controlsState"].getControlsState();
|
||||
scene.alert_size = controlsState.getAlertSize() == cereal::ControlsState::AlertSize::MID ? 350 : controlsState.getAlertSize() == cereal::ControlsState::AlertSize::SMALL ? 200 : 0;
|
||||
scene.enabled = controlsState.getEnabled();
|
||||
scene.experimental_mode = controlsState.getExperimentalMode();
|
||||
}
|
||||
if (sm.updated("deviceState")) {
|
||||
auto deviceState = sm["deviceState"].getDeviceState();
|
||||
scene.online = deviceState.getNetworkType() != cereal::DeviceState::NetworkType::NONE;
|
||||
}
|
||||
if (sm.updated("frogpilotCarControl")) {
|
||||
auto frogpilotCarControl = sm["frogpilotCarControl"].getFrogpilotCarControl();
|
||||
if (scene.always_on_lateral) {
|
||||
scene.always_on_lateral_active = !scene.enabled && frogpilotCarControl.getAlwaysOnLateral();
|
||||
}
|
||||
scene.always_on_lateral_active = !scene.enabled && frogpilotCarControl.getAlwaysOnLateral();
|
||||
scene.speed_limit_changed = scene.speed_limit_controller && frogpilotCarControl.getSpeedLimitChanged();
|
||||
scene.traffic_mode_active = frogpilotCarControl.getTrafficModeActive();
|
||||
}
|
||||
if (sm.updated("frogpilotLateralPlan")) {
|
||||
auto frogpilotLateralPlan = sm["frogpilotLateralPlan"].getFrogpilotLateralPlan();
|
||||
if (scene.blind_spot_path) {
|
||||
scene.lane_width_left = frogpilotLateralPlan.getLaneWidthLeft();
|
||||
scene.lane_width_right = frogpilotLateralPlan.getLaneWidthRight();
|
||||
}
|
||||
}
|
||||
if (sm.updated("frogpilotLongitudinalPlan")) {
|
||||
auto frogpilotLongitudinalPlan = sm["frogpilotLongitudinalPlan"].getFrogpilotLongitudinalPlan();
|
||||
if (scene.lead_info) {
|
||||
scene.desired_follow = frogpilotLongitudinalPlan.getDesiredFollowDistance();
|
||||
scene.obstacle_distance = frogpilotLongitudinalPlan.getSafeObstacleDistance();
|
||||
scene.obstacle_distance_stock = frogpilotLongitudinalPlan.getSafeObstacleDistanceStock();
|
||||
scene.stopped_equivalence = frogpilotLongitudinalPlan.getStoppedEquivalenceFactor();
|
||||
}
|
||||
if (scene.speed_limit_controller) {
|
||||
scene.speed_limit = frogpilotLongitudinalPlan.getSlcSpeedLimit();
|
||||
scene.speed_limit_offset = frogpilotLongitudinalPlan.getSlcSpeedLimitOffset();
|
||||
scene.speed_limit_overridden = frogpilotLongitudinalPlan.getSlcOverridden();
|
||||
scene.speed_limit_overridden_speed = frogpilotLongitudinalPlan.getSlcOverriddenSpeed();
|
||||
}
|
||||
scene.adjusted_cruise = frogpilotLongitudinalPlan.getAdjustedCruise();
|
||||
if (sm.updated("frogpilotPlan")) {
|
||||
auto frogpilotPlan = sm["frogpilotPlan"].getFrogpilotPlan();
|
||||
scene.acceleration_jerk = frogpilotPlan.getAccelerationJerk();
|
||||
scene.acceleration_jerk_difference = frogpilotPlan.getAccelerationJerkStock() - scene.acceleration_jerk;
|
||||
scene.adjusted_cruise = frogpilotPlan.getAdjustedCruise();
|
||||
scene.desired_follow = frogpilotPlan.getDesiredFollowDistance();
|
||||
scene.ego_jerk = frogpilotPlan.getEgoJerk();
|
||||
scene.ego_jerk_difference = frogpilotPlan.getEgoJerkStock() - scene.ego_jerk;
|
||||
scene.lane_width_left = frogpilotPlan.getLaneWidthLeft();
|
||||
scene.lane_width_right = frogpilotPlan.getLaneWidthRight();
|
||||
scene.obstacle_distance = frogpilotPlan.getSafeObstacleDistance();
|
||||
scene.obstacle_distance_stock = frogpilotPlan.getSafeObstacleDistanceStock();
|
||||
scene.speed_limit = frogpilotPlan.getSlcSpeedLimit();
|
||||
scene.speed_limit_offset = frogpilotPlan.getSlcSpeedLimitOffset();
|
||||
scene.speed_limit_overridden = frogpilotPlan.getSlcOverridden();
|
||||
scene.speed_limit_overridden_speed = frogpilotPlan.getSlcOverriddenSpeed();
|
||||
scene.stopped_equivalence = frogpilotPlan.getStoppedEquivalenceFactor();
|
||||
scene.unconfirmed_speed_limit = frogpilotPlan.getUnconfirmedSlcSpeedLimit();
|
||||
scene.vtsc_controlling_curve = frogpilotPlan.getVtscControllingCurve();
|
||||
}
|
||||
if (sm.updated("liveLocationKalman")) {
|
||||
auto liveLocationKalman = sm["liveLocationKalman"].getLiveLocationKalman();
|
||||
if (scene.compass) {
|
||||
auto orientation = liveLocationKalman.getCalibratedOrientationNED();
|
||||
if (orientation.getValid()) {
|
||||
scene.bearing_deg = RAD2DEG(orientation.getValue()[2]);
|
||||
}
|
||||
auto orientation = liveLocationKalman.getCalibratedOrientationNED();
|
||||
if (orientation.getValid()) {
|
||||
scene.bearing_deg = RAD2DEG(orientation.getValue()[2]);
|
||||
}
|
||||
}
|
||||
if (sm.updated("liveTorqueParameters")) {
|
||||
auto torque_params = sm["liveTorqueParameters"].getLiveTorqueParameters();
|
||||
scene.friction = torque_params.getFrictionCoefficientFiltered();
|
||||
scene.lat_accel = torque_params.getLatAccelFactorFiltered();
|
||||
scene.live_valid = torque_params.getLiveValid();
|
||||
}
|
||||
if (sm.updated("wideRoadCameraState")) {
|
||||
auto cam_state = sm["wideRoadCameraState"].getWideRoadCameraState();
|
||||
float scale = (cam_state.getSensor() == cereal::FrameData::ImageSensor::AR0231) ? 6.0f : 1.0f;
|
||||
@@ -290,72 +306,116 @@ void ui_update_params(UIState *s) {
|
||||
auto params = Params();
|
||||
s->scene.is_metric = params.getBool("IsMetric");
|
||||
s->scene.map_on_left = params.getBool("NavSettingLeftSide");
|
||||
}
|
||||
|
||||
// FrogPilot variables
|
||||
void ui_update_frogpilot_params(UIState *s) {
|
||||
Params params = Params();
|
||||
UIScene &scene = s->scene;
|
||||
|
||||
scene.always_on_lateral = params.getBool("AlwaysOnLateral");
|
||||
scene.camera_view = params.getInt("CameraView");
|
||||
scene.compass = params.getBool("Compass");
|
||||
std::string branch = params.get("GitBranch");
|
||||
bool isRelease = branch == "FrogPilot";
|
||||
|
||||
scene.conditional_experimental = params.getBool("ConditionalExperimental");
|
||||
scene.conditional_speed = params.getInt("CESpeed");
|
||||
scene.conditional_speed_lead = params.getInt("CESpeedLead");
|
||||
bool always_on_lateral = params.getBool("AlwaysOnLateral");
|
||||
scene.show_aol_status_bar = always_on_lateral && !params.getBool("HideAOLStatusBar");
|
||||
|
||||
scene.custom_onroad_ui = params.getBool("CustomUI");
|
||||
scene.adjacent_path = params.getBool("AdjacentPath") && scene.custom_onroad_ui;
|
||||
scene.blind_spot_path = params.getBool("BlindSpotPath") && scene.custom_onroad_ui;
|
||||
scene.lead_info = params.getBool("LeadInfo") && scene.custom_onroad_ui;
|
||||
scene.road_name_ui = params.getBool("RoadNameUI") && scene.custom_onroad_ui;
|
||||
scene.show_fps = params.getBool("ShowFPS") && scene.custom_onroad_ui;
|
||||
scene.use_si = params.getBool("UseSI") && scene.custom_onroad_ui;
|
||||
scene.use_vienna_slc_sign = params.getBool("UseVienna") && scene.custom_onroad_ui;
|
||||
scene.conditional_experimental = scene.longitudinal_control && params.getBool("ConditionalExperimental");
|
||||
scene.conditional_speed = scene.conditional_experimental ? params.getInt("CESpeed") : 0;
|
||||
scene.conditional_speed_lead = scene.conditional_experimental ? params.getInt("CESpeedLead") : 0;
|
||||
scene.show_cem_status_bar = scene.conditional_experimental && !params.getBool("HideCEMStatusBar");
|
||||
|
||||
scene.custom_theme = params.getBool("CustomTheme");
|
||||
scene.custom_colors = scene.custom_theme ? params.getInt("CustomColors") : 0;
|
||||
scene.custom_icons = scene.custom_theme ? params.getInt("CustomIcons") : 0;
|
||||
scene.custom_signals = scene.custom_theme ? params.getInt("CustomSignals") : 0;
|
||||
bool custom_onroad_ui = params.getBool("CustomUI");
|
||||
bool custom_paths = custom_onroad_ui && params.getBool("CustomPaths");
|
||||
bool developer_ui = !isRelease && custom_onroad_ui && params.getBool("DeveloperUI");
|
||||
scene.acceleration_path = custom_paths && params.getBool("AccelerationPath");
|
||||
scene.adjacent_path = custom_paths && params.getBool("AdjacentPath");
|
||||
scene.adjacent_path_metrics = scene.adjacent_path && params.getBool("AdjacentPathMetrics");
|
||||
scene.blind_spot_path = custom_paths && params.getBool("BlindSpotPath");
|
||||
scene.compass = custom_onroad_ui && params.getBool("Compass");
|
||||
scene.fps_counter = custom_onroad_ui && params.getBool("FPSCounter");
|
||||
scene.lead_info = scene.longitudinal_control && custom_onroad_ui && params.getBool("LeadInfo");
|
||||
scene.pedals_on_ui = custom_onroad_ui && params.getBool("PedalsOnUI");
|
||||
scene.road_name_ui = custom_onroad_ui && params.getBool("RoadNameUI");
|
||||
scene.rotating_wheel = custom_onroad_ui && params.getBool("RotatingWheel");
|
||||
scene.show_jerk = scene.longitudinal_control && developer_ui && params.getBool("ShowJerk");
|
||||
scene.show_tuning = scene.has_auto_tune && developer_ui && !(params.getBool("LateralTune") && params.getBool("NNFF")) && params.getBool("ShowTuning");
|
||||
scene.use_si = (scene.lead_info || developer_ui) && params.getBool("UseSI");
|
||||
scene.wheel_icon = custom_onroad_ui ? params.getInt("WheelIcon") : 0;
|
||||
|
||||
bool custom_theme = params.getBool("CustomTheme");
|
||||
scene.custom_colors = custom_theme ? params.getInt("CustomColors") : 0;
|
||||
scene.custom_icons = custom_theme ? params.getInt("CustomIcons") : 0;
|
||||
scene.custom_signals = custom_theme ? params.getInt("CustomSignals") : 0;
|
||||
scene.holiday_themes = custom_theme && params.getBool("HolidayThemes");
|
||||
scene.random_events = custom_theme && params.getBool("RandomEvents");
|
||||
|
||||
scene.disable_smoothing_mtsc = params.getBool("MTSCEnabled") && params.getBool("DisableMTSCSmoothing");
|
||||
scene.disable_smoothing_vtsc = params.getBool("VisionTurnControl") && params.getBool("DisableVTSCSmoothing");
|
||||
scene.experimental_mode_via_screen = scene.longitudinal_control && params.getBool("ExperimentalModeActivation") && params.getBool("ExperimentalModeViaTap");
|
||||
|
||||
bool lane_detection = params.getBool("NudgelessLaneChange") && params.getInt("LaneDetectionWidth") != 0;
|
||||
scene.lane_detection_width = lane_detection ? params.getInt("LaneDetectionWidth") * (scene.is_metric ? 1 : FOOT_TO_METER) / 10 : 9.0f;
|
||||
|
||||
scene.model_ui = params.getBool("ModelUI");
|
||||
scene.acceleration_path = params.getBool("AccelerationPath") && scene.model_ui;
|
||||
scene.lane_line_width = params.getInt("LaneLinesWidth") * (scene.is_metric ? 1 : INCH_TO_CM) / 200;
|
||||
scene.dynamic_path_width = scene.model_ui && params.getBool("DynamicPathWidth");
|
||||
scene.hide_lead_marker = scene.model_ui && params.getBool("HideLeadMarker");
|
||||
scene.lane_line_width = params.getInt("LaneLinesWidth") * (scene.is_metric ? 1.0f : INCH_TO_CM) / 200.0f;
|
||||
scene.path_edge_width = params.getInt("PathEdgeWidth");
|
||||
scene.path_width = params.getInt("PathWidth") / 10.0 * (scene.is_metric ? 1 : FOOT_TO_METER) / 2;
|
||||
scene.road_edge_width = params.getInt("RoadEdgesWidth") * (scene.is_metric ? 1 : INCH_TO_CM) / 200;
|
||||
scene.unlimited_road_ui_length = params.getBool("UnlimitedLength") && scene.model_ui;
|
||||
scene.path_width = params.getInt("PathWidth") / 10.0f * (scene.is_metric ? 1.0f : FOOT_TO_METER) / 2.0f;
|
||||
scene.road_edge_width = params.getInt("RoadEdgesWidth") * (scene.is_metric ? 1.0f : INCH_TO_CM) / 200.0f;
|
||||
scene.unlimited_road_ui_length = scene.model_ui && params.getBool("UnlimitedLength");
|
||||
|
||||
scene.driver_camera = params.getBool("DriverCamera");
|
||||
scene.experimental_mode_via_screen = params.getBool("ExperimentalModeViaScreen") && params.getBool("ExperimentalModeActivation");
|
||||
scene.mute_dm = params.getBool("MuteDM") && params.getBool("FireTheBabysitter");
|
||||
// scene.personalities_via_screen = (params.getInt("AdjustablePersonalities") == 2 || params.getInt("AdjustablePersonalities") == 3);
|
||||
scene.personalities_via_screen = false;
|
||||
bool quality_of_life_controls = params.getBool("QOLControls");
|
||||
scene.onroad_distance_button = scene.longitudinal_control && quality_of_life_controls && params.getBool("OnroadDistanceButton");
|
||||
scene.use_kaofui_icons = scene.onroad_distance_button && params.getBool("KaofuiIcons");
|
||||
scene.reverse_cruise = quality_of_life_controls && params.getBool("ReverseCruise");
|
||||
scene.reverse_cruise_ui = scene.reverse_cruise && params.getBool("ReverseCruiseUI");
|
||||
|
||||
scene.quality_of_life_controls = params.getBool("QOLControls");
|
||||
scene.reverse_cruise = params.getBool("ReverseCruise") && scene.quality_of_life_controls;
|
||||
bool quality_of_life_visuals = params.getBool("QOLVisuals");
|
||||
scene.big_map = quality_of_life_visuals && params.getBool("BigMap");
|
||||
scene.full_map = scene.big_map && params.getBool("FullMap");
|
||||
scene.camera_view = quality_of_life_visuals ? params.getInt("CameraView") : 0;
|
||||
scene.driver_camera = quality_of_life_visuals && params.getBool("DriverCamera");
|
||||
scene.hide_speed = quality_of_life_visuals && params.getBool("HideSpeed");
|
||||
scene.hide_speed_ui = scene.hide_speed && params.getBool("HideSpeedUI");
|
||||
scene.map_style = quality_of_life_visuals ? params.getInt("MapStyle") : 0;
|
||||
scene.numerical_temp = quality_of_life_visuals && params.getBool("NumericalTemp");
|
||||
scene.fahrenheit = scene.numerical_temp && params.getBool("Fahrenheit");
|
||||
scene.wheel_speed = quality_of_life_visuals && params.getBool("WheelSpeed");
|
||||
|
||||
scene.quality_of_life_visuals = params.getBool("QOLVisuals");
|
||||
scene.full_map = params.getBool("FullMap") && scene.quality_of_life_visuals;
|
||||
scene.hide_speed = params.getBool("HideSpeed") && scene.quality_of_life_visuals;
|
||||
scene.show_slc_offset = params.getBool("ShowSLCOffset") && scene.quality_of_life_visuals;
|
||||
bool screen_management = params.getBool("ScreenManagement");
|
||||
bool hide_ui_elements = screen_management && params.getBool("HideUIElements");
|
||||
scene.hide_alerts = hide_ui_elements && params.getBool("HideAlerts");
|
||||
scene.hide_map_icon = hide_ui_elements && params.getBool("HideMapIcon");
|
||||
scene.hide_max_speed = hide_ui_elements && params.getBool("HideMaxSpeed");
|
||||
scene.screen_brightness = screen_management ? params.getInt("ScreenBrightness") : 101;
|
||||
scene.screen_brightness_onroad = screen_management ? params.getInt("ScreenBrightnessOnroad") : 101;
|
||||
scene.screen_recorder = screen_management && params.getBool("ScreenRecorder");
|
||||
scene.screen_timeout = screen_management ? params.getInt("ScreenTimeout") : 30;
|
||||
scene.screen_timeout_onroad = screen_management ? params.getInt("ScreenTimeoutOnroad") : 10;
|
||||
scene.standby_mode = screen_management && params.getBool("StandbyMode");
|
||||
|
||||
scene.random_events = params.getBool("RandomEvents");
|
||||
scene.rotating_wheel = params.getBool("RotatingWheel");
|
||||
scene.screen_brightness = params.getInt("ScreenBrightness");
|
||||
scene.speed_limit_controller = params.getBool("SpeedLimitController");
|
||||
scene.wheel_icon = params.getInt("WheelIcon");
|
||||
scene.speed_limit_controller = scene.longitudinal_control && params.getBool("SpeedLimitController");
|
||||
scene.show_slc_offset = scene.speed_limit_controller && params.getBool("ShowSLCOffset");
|
||||
scene.show_slc_offset_ui = scene.speed_limit_controller && params.getBool("ShowSLCOffsetUI");
|
||||
scene.use_vienna_slc_sign = scene.speed_limit_controller && params.getBool("UseVienna");
|
||||
}
|
||||
|
||||
void UIState::updateStatus() {
|
||||
if (scene.started && sm->updated("controlsState")) {
|
||||
auto controls_state = (*sm)["controlsState"].getControlsState();
|
||||
auto state = controls_state.getState();
|
||||
auto previous_status = status;
|
||||
if (state == cereal::ControlsState::OpenpilotState::PRE_ENABLED || state == cereal::ControlsState::OpenpilotState::OVERRIDING) {
|
||||
status = STATUS_OVERRIDE;
|
||||
} else if (scene.always_on_lateral_active) {
|
||||
status = STATUS_LATERAL_ACTIVE;
|
||||
status = STATUS_ALWAYS_ON_LATERAL_ACTIVE;
|
||||
} else if (scene.traffic_mode_active && scene.enabled) {
|
||||
status = STATUS_TRAFFIC_MODE_ACTIVE;
|
||||
} else {
|
||||
status = controls_state.getEnabled() ? STATUS_ENGAGED : STATUS_DISENGAGED;
|
||||
}
|
||||
|
||||
scene.wake_up_screen = controls_state.getAlertStatus() != cereal::ControlsState::AlertStatus::NORMAL || status != previous_status;
|
||||
}
|
||||
|
||||
// Handle onroad/offroad transition
|
||||
@@ -375,8 +435,8 @@ UIState::UIState(QObject *parent) : QObject(parent) {
|
||||
sm = std::make_unique<SubMaster, const std::initializer_list<const char *>>({
|
||||
"modelV2", "controlsState", "liveCalibration", "radarState", "deviceState",
|
||||
"pandaStates", "carParams", "driverMonitoringState", "carState", "liveLocationKalman", "driverStateV2",
|
||||
"wideRoadCameraState", "managerState", "navInstruction", "navRoute", "uiPlan",
|
||||
"frogpilotCarControl", "frogpilotDeviceState", "frogpilotLateralPlan", "frogpilotLongitudinalPlan",
|
||||
"wideRoadCameraState", "managerState", "navInstruction", "navRoute", "uiPlan", "liveTorqueParameters",
|
||||
"frogpilotCarControl", "frogpilotDeviceState", "frogpilotPlan",
|
||||
});
|
||||
|
||||
Params params;
|
||||
@@ -393,8 +453,7 @@ UIState::UIState(QObject *parent) : QObject(parent) {
|
||||
|
||||
wifi = new WifiManager(this);
|
||||
|
||||
ui_update_params(this);
|
||||
setDefaultParams();
|
||||
ui_update_frogpilot_params(this);
|
||||
}
|
||||
|
||||
void UIState::update() {
|
||||
@@ -408,19 +467,15 @@ void UIState::update() {
|
||||
emit uiUpdate(*this);
|
||||
|
||||
// Update FrogPilot variables when they are changed
|
||||
Params paramsMemory{"/dev/shm/params"};
|
||||
if (paramsMemory.getBool("FrogPilotTogglesUpdated")) {
|
||||
std::thread updateFrogPilotParams(ui_update_params, this);
|
||||
updateFrogPilotParams.detach();
|
||||
ui_update_frogpilot_params(this);
|
||||
}
|
||||
|
||||
// FrogPilot live variables that need to be constantly checked
|
||||
if (scene.conditional_experimental) {
|
||||
scene.conditional_status = paramsMemory.getInt("CEStatus");
|
||||
}
|
||||
if (scene.random_events) {
|
||||
scene.current_random_event = paramsMemory.getInt("CurrentRandomEvent");
|
||||
}
|
||||
scene.conditional_status = scene.conditional_experimental ? paramsMemory.getInt("CEStatus") : 0;
|
||||
scene.current_holiday_theme = scene.holiday_themes ? paramsMemory.getInt("CurrentHolidayTheme") : 0;
|
||||
scene.current_random_event = scene.random_events ? paramsMemory.getInt("CurrentRandomEvent") : 0;
|
||||
scene.driver_camera_timer = (scene.driver_camera && scene.reverse) ? scene.driver_camera_timer + 1 : 0;
|
||||
}
|
||||
|
||||
void UIState::setPrimeType(PrimeType type) {
|
||||
@@ -459,9 +514,11 @@ void Device::setAwake(bool on) {
|
||||
}
|
||||
}
|
||||
|
||||
void Device::resetInteractiveTimeout(int timeout) {
|
||||
void Device::resetInteractiveTimeout(int timeout, int timeout_onroad) {
|
||||
if (timeout == -1) {
|
||||
timeout = 60;
|
||||
timeout = (ignition_on ? 10 : 30);
|
||||
} else {
|
||||
timeout = (ignition_on ? timeout_onroad : timeout);
|
||||
}
|
||||
interactive_timeout = timeout * UI_FREQ;
|
||||
}
|
||||
@@ -485,8 +542,11 @@ void Device::updateBrightness(const UIState &s) {
|
||||
int brightness = brightness_filter.update(clipped_brightness);
|
||||
if (!awake) {
|
||||
brightness = 0;
|
||||
} else if (s.scene.screen_brightness <= 100) {
|
||||
// Bring the screen brightness up to 5% upon screen tap
|
||||
} else if (s.scene.started && s.scene.standby_mode && !s.scene.wake_up_screen && interactive_timeout == 0) {
|
||||
brightness = 0;
|
||||
} else if (s.scene.started && s.scene.screen_brightness_onroad != 101) {
|
||||
brightness = interactive_timeout > 0 ? fmax(5, s.scene.screen_brightness_onroad) : s.scene.screen_brightness_onroad;
|
||||
} else if (s.scene.screen_brightness != 101) {
|
||||
brightness = fmax(5, s.scene.screen_brightness);
|
||||
}
|
||||
|
||||
@@ -499,16 +559,26 @@ void Device::updateBrightness(const UIState &s) {
|
||||
}
|
||||
|
||||
void Device::updateWakefulness(const UIState &s) {
|
||||
bool ignition_just_turned_off = !s.scene.ignition && ignition_on;
|
||||
bool ignition_state_changed = s.scene.ignition != ignition_on;
|
||||
ignition_on = s.scene.ignition;
|
||||
|
||||
if (ignition_just_turned_off) {
|
||||
resetInteractiveTimeout();
|
||||
if (ignition_on && s.scene.standby_mode) {
|
||||
if (s.scene.wake_up_screen) {
|
||||
resetInteractiveTimeout(s.scene.screen_timeout, s.scene.screen_timeout_onroad);
|
||||
}
|
||||
}
|
||||
|
||||
if (ignition_state_changed) {
|
||||
if (ignition_on && s.scene.screen_brightness_onroad == 0 && !s.scene.standby_mode) {
|
||||
resetInteractiveTimeout(0, 0);
|
||||
} else {
|
||||
resetInteractiveTimeout(s.scene.screen_timeout, s.scene.screen_timeout_onroad);
|
||||
}
|
||||
} else if (interactive_timeout > 0 && --interactive_timeout == 0) {
|
||||
emit interactiveTimeout();
|
||||
}
|
||||
|
||||
if (s.scene.screen_brightness != 0) {
|
||||
if (s.scene.screen_brightness_onroad != 0) {
|
||||
setAwake(s.scene.ignition || interactive_timeout > 0);
|
||||
} else {
|
||||
setAwake(interactive_timeout > 0);
|
||||
|
||||
Reference in New Issue
Block a user