diff --git a/common/params.cc b/common/params.cc index 3fe344c..16481d3 100644 --- a/common/params.cc +++ b/common/params.cc @@ -217,6 +217,7 @@ std::unordered_map keys = { {"AlwaysOnLateralMain", PERSISTENT}, {"ApiCache_DriveStats", PERSISTENT}, {"BlindSpotPath", PERSISTENT}, + {"CameraView", PERSISTENT}, {"CustomAlerts", PERSISTENT}, {"CustomUI", PERSISTENT}, {"DecelerationProfile", PERSISTENT}, diff --git a/selfdrive/frogpilot/assets/toggle_icons/icon_camera.png b/selfdrive/frogpilot/assets/toggle_icons/icon_camera.png new file mode 100644 index 0000000..b34afe3 Binary files /dev/null and b/selfdrive/frogpilot/assets/toggle_icons/icon_camera.png differ diff --git a/selfdrive/frogpilot/ui/visual_settings.cc b/selfdrive/frogpilot/ui/visual_settings.cc index 6ef5ecf..e2b1acf 100644 --- a/selfdrive/frogpilot/ui/visual_settings.cc +++ b/selfdrive/frogpilot/ui/visual_settings.cc @@ -11,6 +11,8 @@ FrogPilotVisualsPanel::FrogPilotVisualsPanel(SettingsWindow *parent) : FrogPilot {"WarningSoftVolume", "Warning Soft Volume", "Related alerts:\n\nBRAKE!, Risk of Collision\nTAKE CONTROL IMMEDIATELY", ""}, {"WarningImmediateVolume", "Warning Immediate Volume", "Related alerts:\n\nDISENGAGE IMMEDIATELY, Driver Distracted\nDISENGAGE IMMEDIATELY, Driver Unresponsive", ""}, + {"CameraView", "Camera View", "Choose your preferred camera view for the onroad UI. This is a visual change only and doesn't impact openpilot.", "../frogpilot/assets/toggle_icons/icon_camera.png"}, + {"CustomAlerts", "Custom Alerts", "Enable custom alerts for various logic or situational changes.", "../frogpilot/assets/toggle_icons/icon_green_light.png"}, {"CustomUI", "Custom Onroad UI", "Customize the Onroad UI with some additional visual functions.", "../assets/offroad/icon_road.png"}, @@ -40,6 +42,11 @@ FrogPilotVisualsPanel::FrogPilotVisualsPanel(SettingsWindow *parent) : FrogPilot toggle = new FrogPilotParamValueControl(param, title, desc, icon, 0, 100, std::map(), this, false, "%"); } + } else if (param == "CameraView") { + std::vector cameraOptions{tr("Auto"), tr("Standard"), tr("Wide"), tr("Driver")}; + FrogPilotButtonParamControl *preferredCamera = new FrogPilotButtonParamControl(param, title, desc, icon, cameraOptions); + toggle = preferredCamera; + } else if (param == "CustomAlerts") { FrogPilotParamManageControl *customAlertsToggle = new FrogPilotParamManageControl(param, title, desc, icon, this); QObject::connect(customAlertsToggle, &FrogPilotParamManageControl::manageButtonClicked, this, [this]() { diff --git a/selfdrive/ui/qt/onroad.cc b/selfdrive/ui/qt/onroad.cc index 99e28d5..6196fc3 100644 --- a/selfdrive/ui/qt/onroad.cc +++ b/selfdrive/ui/qt/onroad.cc @@ -659,7 +659,7 @@ void AnnotatedCameraWidget::paintGL() { // Wide or narrow cam dependent on speed bool has_wide_cam = available_streams.count(VISION_STREAM_WIDE_ROAD); - if (has_wide_cam) { + if (has_wide_cam && cameraView == 0) { float v_ego = sm["carState"].getCarState().getVEgo(); if ((v_ego < 10) || available_streams.size() == 1) { wide_cam_requested = true; @@ -670,7 +670,9 @@ void AnnotatedCameraWidget::paintGL() { // for replay of old routes, never go to widecam wide_cam_requested = wide_cam_requested && s->scene.calibration_wide_valid; } - CameraWidget::setStreamType(wide_cam_requested ? VISION_STREAM_WIDE_ROAD : VISION_STREAM_ROAD); + CameraWidget::setStreamType(cameraView == 3 ? VISION_STREAM_DRIVER : + cameraView == 2 || wide_cam_requested ? VISION_STREAM_WIDE_ROAD : + VISION_STREAM_ROAD); s->scene.wide_cam = CameraWidget::getStreamType() == VISION_STREAM_WIDE_ROAD; if (s->scene.calibration_valid) { @@ -758,6 +760,8 @@ void AnnotatedCameraWidget::updateFrogPilotWidgets(QPainter &p) { blindSpotLeft = scene.blind_spot_left; blindSpotRight = scene.blind_spot_right; + cameraView = scene.camera_view; + experimentalMode = scene.experimental_mode; if (alwaysOnLateral) { diff --git a/selfdrive/ui/qt/onroad.h b/selfdrive/ui/qt/onroad.h index feba8ba..d482850 100644 --- a/selfdrive/ui/qt/onroad.h +++ b/selfdrive/ui/qt/onroad.h @@ -124,6 +124,8 @@ private: bool blindSpotRight; bool experimentalMode; + int cameraView; + protected: void paintGL() override; void initializeGL() override; diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 7ca7958..f41313d 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -260,6 +260,7 @@ void ui_update_frogpilot_params(UIState *s) { UIScene &scene = s->scene; scene.always_on_lateral = params.getBool("AlwaysOnLateral"); + scene.camera_view = params.getInt("CameraView"); bool custom_onroad_ui = params.getBool("CustomUI"); scene.acceleration_path = custom_onroad_ui && params.getBool("AccelerationPath"); diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index b5610d0..49deb37 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -181,6 +181,8 @@ typedef struct UIScene { float lane_width_left; float lane_width_right; + int camera_view; + QPolygonF track_adjacent_vertices[6]; } UIScene;