diff --git a/common/params.cc b/common/params.cc index 51cd4dd..14d2694 100644 --- a/common/params.cc +++ b/common/params.cc @@ -218,6 +218,7 @@ std::unordered_map keys = { {"AlwaysOnLateralMain", PERSISTENT}, {"ApiCache_DriveStats", PERSISTENT}, {"AverageCurvature", PERSISTENT}, + {"CameraView", PERSISTENT}, {"FrogPilotTogglesUpdated", PERSISTENT}, {"GasRegenCmd", PERSISTENT}, {"LateralTune", 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 5fea03c..e7ef0ee 100644 --- a/selfdrive/frogpilot/ui/visual_settings.cc +++ b/selfdrive/frogpilot/ui/visual_settings.cc @@ -3,12 +3,20 @@ FrogPilotVisualsPanel::FrogPilotVisualsPanel(SettingsWindow *parent) : FrogPilotListWidget(parent) { const std::vector> visualToggles { + {"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"}, }; for (const auto &[param, title, desc, icon] : visualToggles) { ParamControl *toggle; - toggle = new ParamControl(param, title, desc, icon, this); + 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 { + toggle = new ParamControl(param, title, desc, icon, this); + } addItem(toggle); toggles[param.toStdString()] = toggle; diff --git a/selfdrive/ui/qt/onroad.cc b/selfdrive/ui/qt/onroad.cc index a61d804..e678b47 100644 --- a/selfdrive/ui/qt/onroad.cc +++ b/selfdrive/ui/qt/onroad.cc @@ -651,11 +651,12 @@ void AnnotatedCameraWidget::paintGL() { } else if (v_ego > 15) { wide_cam_requested = false; } - wide_cam_requested = wide_cam_requested && sm["controlsState"].getControlsState().getExperimentalMode(); + wide_cam_requested = wide_cam_requested && sm["controlsState"].getControlsState().getExperimentalMode() || cameraView == 2; // 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 : + wide_cam_requested && cameraView != 1 ? VISION_STREAM_WIDE_ROAD : VISION_STREAM_ROAD); s->scene.wide_cam = CameraWidget::getStreamType() == VISION_STREAM_WIDE_ROAD; if (s->scene.calibration_valid) { @@ -740,6 +741,7 @@ void AnnotatedCameraWidget::initializeFrogPilotWidgets() { void AnnotatedCameraWidget::updateFrogPilotWidgets(QPainter &p) { alwaysOnLateral = scene.always_on_lateral_active; + 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 af6ebe5..dd3bf71 100644 --- a/selfdrive/ui/qt/onroad.h +++ b/selfdrive/ui/qt/onroad.h @@ -119,6 +119,7 @@ private: bool alwaysOnLateral; bool experimentalMode; + int cameraView; protected: void paintGL() override; diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 9d38679..1f8205d 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -249,6 +249,7 @@ void ui_update_params(UIState *s) { UIScene &scene = s->scene; scene.always_on_lateral = params.getBool("AlwaysOnLateral"); + scene.camera_view = params.getInt("CameraView"); } void UIState::updateStatus() { diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index 6be81e7..13893f7 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -173,6 +173,7 @@ typedef struct UIScene { bool always_on_lateral_active; bool enabled; bool experimental_mode; + int camera_view; } UIScene;