Driver camera view when in reverse
Added toggle to show the driver camera when in the reverse gear.
This commit is contained in:
@@ -251,6 +251,7 @@ std::unordered_map<std::string, uint32_t> keys = {
|
|||||||
{"DisableOpenpilotLongitudinal", PERSISTENT},
|
{"DisableOpenpilotLongitudinal", PERSISTENT},
|
||||||
{"DisengageVolume", PERSISTENT},
|
{"DisengageVolume", PERSISTENT},
|
||||||
{"DragonPilotTune", PERSISTENT},
|
{"DragonPilotTune", PERSISTENT},
|
||||||
|
{"DriverCamera", PERSISTENT},
|
||||||
{"DriveStats", PERSISTENT},
|
{"DriveStats", PERSISTENT},
|
||||||
{"DynamicPathWidth", PERSISTENT},
|
{"DynamicPathWidth", PERSISTENT},
|
||||||
{"EngageVolume", PERSISTENT},
|
{"EngageVolume", PERSISTENT},
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ FrogPilotVisualsPanel::FrogPilotVisualsPanel(SettingsWindow *parent) : FrogPilot
|
|||||||
{"BlindSpotPath", "Blind Spot Path", "Visualize your blind spots with a red path when another vehicle is detected nearby.", ""},
|
{"BlindSpotPath", "Blind Spot Path", "Visualize your blind spots with a red path when another vehicle is detected nearby.", ""},
|
||||||
{"LeadInfo", "Lead Info and Logics", "Get detailed information about the vehicle ahead, including speed and distance, and the logic behind your following distance.", ""},
|
{"LeadInfo", "Lead Info and Logics", "Get detailed information about the vehicle ahead, including speed and distance, and the logic behind your following distance.", ""},
|
||||||
|
|
||||||
|
{"DriverCamera", "Driver Camera On Reverse", "Show the driver's camera feed when you shift to reverse.", "../assets/img_driver_face_static.png"},
|
||||||
|
|
||||||
{"ModelUI", "Model UI", "Personalize how the model's visualizations appear on your screen.", "../assets/offroad/icon_calibration.png"},
|
{"ModelUI", "Model UI", "Personalize how the model's visualizations appear on your screen.", "../assets/offroad/icon_calibration.png"},
|
||||||
{"DynamicPathWidth", "Dynamic Path Width", "Have the path width dynamically adjust based on the current engagement state of openpilot.", ""},
|
{"DynamicPathWidth", "Dynamic Path Width", "Have the path width dynamically adjust based on the current engagement state of openpilot.", ""},
|
||||||
{"LaneLinesWidth", "Lane Lines", "Adjust the visual thickness of lane lines on your display.\n\nDefault matches the MUTCD average of 4 inches.", ""},
|
{"LaneLinesWidth", "Lane Lines", "Adjust the visual thickness of lane lines on your display.\n\nDefault matches the MUTCD average of 4 inches.", ""},
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ void OnroadAlerts::updateAlert(const Alert &a) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void OnroadAlerts::paintEvent(QPaintEvent *event) {
|
void OnroadAlerts::paintEvent(QPaintEvent *event) {
|
||||||
if (alert.size == cereal::ControlsState::AlertSize::NONE) {
|
if (alert.size == cereal::ControlsState::AlertSize::NONE || scene.show_driver_camera && alert.status != cereal::ControlsState::AlertStatus::CRITICAL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
static std::map<cereal::ControlsState::AlertSize, const int> alert_heights = {
|
static std::map<cereal::ControlsState::AlertSize, const int> alert_heights = {
|
||||||
@@ -256,7 +256,10 @@ void ExperimentalButton::updateState(const UIState &s, bool leadInfo) {
|
|||||||
void ExperimentalButton::paintEvent(QPaintEvent *event) {
|
void ExperimentalButton::paintEvent(QPaintEvent *event) {
|
||||||
QPainter p(this);
|
QPainter p(this);
|
||||||
QPixmap img = experimental_mode ? experimental_img : engage_img;
|
QPixmap img = experimental_mode ? experimental_img : engage_img;
|
||||||
|
|
||||||
|
if (!scene.show_driver_camera) {
|
||||||
drawIcon(p, QPoint(btn_size / 2, btn_size / 2 + y_offset), img, QColor(0, 0, 0, 166), (isDown() || !(engageable || scene.always_on_lateral_active)) ? 0.6 : 1.0);
|
drawIcon(p, QPoint(btn_size / 2, btn_size / 2 + y_offset), img, QColor(0, 0, 0, 166), (isDown() || !(engageable || scene.always_on_lateral_active)) ? 0.6 : 1.0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -328,7 +331,7 @@ void AnnotatedCameraWidget::updateState(const UIState &s) {
|
|||||||
has_eu_speed_limit = (nav_alive && speed_limit_sign == cereal::NavInstruction::SpeedLimitSign::VIENNA);
|
has_eu_speed_limit = (nav_alive && speed_limit_sign == cereal::NavInstruction::SpeedLimitSign::VIENNA);
|
||||||
is_metric = s.scene.is_metric;
|
is_metric = s.scene.is_metric;
|
||||||
speedUnit = s.scene.is_metric ? tr("km/h") : tr("mph");
|
speedUnit = s.scene.is_metric ? tr("km/h") : tr("mph");
|
||||||
hideBottomIcons = (cs.getAlertSize() != cereal::ControlsState::AlertSize::NONE || customSignals && (turnSignalLeft || turnSignalRight));
|
hideBottomIcons = (cs.getAlertSize() != cereal::ControlsState::AlertSize::NONE || customSignals && (turnSignalLeft || turnSignalRight)) || showDriverCamera;
|
||||||
status = s.status;
|
status = s.status;
|
||||||
|
|
||||||
// update engageability/experimental mode button
|
// update engageability/experimental mode button
|
||||||
@@ -361,6 +364,7 @@ void AnnotatedCameraWidget::drawHud(QPainter &p) {
|
|||||||
QString speedStr = QString::number(std::nearbyint(speed));
|
QString speedStr = QString::number(std::nearbyint(speed));
|
||||||
QString setSpeedStr = is_cruise_set ? QString::number(std::nearbyint(setSpeed)) : "–";
|
QString setSpeedStr = is_cruise_set ? QString::number(std::nearbyint(setSpeed)) : "–";
|
||||||
|
|
||||||
|
if (!showDriverCamera) {
|
||||||
// Draw outer box + border to contain set speed and speed limit
|
// Draw outer box + border to contain set speed and speed limit
|
||||||
const int sign_margin = 12;
|
const int sign_margin = 12;
|
||||||
const int us_sign_height = 186;
|
const int us_sign_height = 186;
|
||||||
@@ -436,12 +440,15 @@ void AnnotatedCameraWidget::drawHud(QPainter &p) {
|
|||||||
p.setPen(blackColor());
|
p.setPen(blackColor());
|
||||||
p.drawText(sign_rect, Qt::AlignCenter, speedLimitStr);
|
p.drawText(sign_rect, Qt::AlignCenter, speedLimitStr);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// current speed
|
// current speed
|
||||||
|
if (!showDriverCamera) {
|
||||||
p.setFont(InterFont(176, QFont::Bold));
|
p.setFont(InterFont(176, QFont::Bold));
|
||||||
drawText(p, rect().center().x(), 210, speedStr);
|
drawText(p, rect().center().x(), 210, speedStr);
|
||||||
p.setFont(InterFont(66));
|
p.setFont(InterFont(66));
|
||||||
drawText(p, rect().center().x(), 290, speedUnit, 200);
|
drawText(p, rect().center().x(), 290, speedUnit, 200);
|
||||||
|
}
|
||||||
|
|
||||||
p.restore();
|
p.restore();
|
||||||
}
|
}
|
||||||
@@ -807,7 +814,7 @@ void AnnotatedCameraWidget::paintGL() {
|
|||||||
// for replay of old routes, never go to widecam
|
// for replay of old routes, never go to widecam
|
||||||
wide_cam_requested = wide_cam_requested && s->scene.calibration_wide_valid;
|
wide_cam_requested = wide_cam_requested && s->scene.calibration_wide_valid;
|
||||||
}
|
}
|
||||||
CameraWidget::setStreamType(cameraView == 3 ? VISION_STREAM_DRIVER :
|
CameraWidget::setStreamType(cameraView == 3 || showDriverCamera ? VISION_STREAM_DRIVER :
|
||||||
cameraView == 2 || wide_cam_requested ? VISION_STREAM_WIDE_ROAD :
|
cameraView == 2 || wide_cam_requested ? VISION_STREAM_WIDE_ROAD :
|
||||||
VISION_STREAM_ROAD);
|
VISION_STREAM_ROAD);
|
||||||
|
|
||||||
@@ -826,7 +833,7 @@ void AnnotatedCameraWidget::paintGL() {
|
|||||||
painter.setRenderHint(QPainter::Antialiasing);
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
painter.setPen(Qt::NoPen);
|
painter.setPen(Qt::NoPen);
|
||||||
|
|
||||||
if (s->scene.world_objects_visible) {
|
if (s->scene.world_objects_visible && !showDriverCamera) {
|
||||||
update_model(s, model, sm["uiPlan"].getUiPlan());
|
update_model(s, model, sm["uiPlan"].getUiPlan());
|
||||||
drawLaneLines(painter, s);
|
drawLaneLines(painter, s);
|
||||||
|
|
||||||
@@ -936,9 +943,12 @@ void AnnotatedCameraWidget::updateFrogPilotWidgets(QPainter &p) {
|
|||||||
|
|
||||||
mapOpen = scene.map_open;
|
mapOpen = scene.map_open;
|
||||||
|
|
||||||
|
showDriverCamera = scene.show_driver_camera;
|
||||||
|
|
||||||
turnSignalLeft = scene.turn_signal_left;
|
turnSignalLeft = scene.turn_signal_left;
|
||||||
turnSignalRight = scene.turn_signal_right;
|
turnSignalRight = scene.turn_signal_right;
|
||||||
|
|
||||||
|
if (!showDriverCamera) {
|
||||||
if (leadInfo) {
|
if (leadInfo) {
|
||||||
drawLeadInfo(p);
|
drawLeadInfo(p);
|
||||||
}
|
}
|
||||||
@@ -955,6 +965,7 @@ void AnnotatedCameraWidget::updateFrogPilotWidgets(QPainter &p) {
|
|||||||
} else if (animationTimer->isActive()) {
|
} else if (animationTimer->isActive()) {
|
||||||
animationTimer->stop();
|
animationTimer->stop();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
map_settings_btn_bottom->setEnabled(map_settings_btn->isEnabled());
|
map_settings_btn_bottom->setEnabled(map_settings_btn->isEnabled());
|
||||||
if (map_settings_btn_bottom->isEnabled()) {
|
if (map_settings_btn_bottom->isEnabled()) {
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ private:
|
|||||||
bool experimentalMode;
|
bool experimentalMode;
|
||||||
bool leadInfo;
|
bool leadInfo;
|
||||||
bool mapOpen;
|
bool mapOpen;
|
||||||
|
bool showDriverCamera;
|
||||||
bool turnSignalLeft;
|
bool turnSignalLeft;
|
||||||
bool turnSignalRight;
|
bool turnSignalRight;
|
||||||
|
|
||||||
|
|||||||
@@ -217,6 +217,9 @@ void CameraWidget::updateFrameMat() {
|
|||||||
if (active_stream_type == VISION_STREAM_DRIVER) {
|
if (active_stream_type == VISION_STREAM_DRIVER) {
|
||||||
if (stream_width > 0 && stream_height > 0) {
|
if (stream_width > 0 && stream_height > 0) {
|
||||||
frame_mat = get_driver_view_transform(w, h, stream_width, stream_height);
|
frame_mat = get_driver_view_transform(w, h, stream_width, stream_height);
|
||||||
|
if (uiState()->scene.show_driver_camera) {
|
||||||
|
frame_mat.v[0] *= -1.0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Project point at "infinity" to compute x and y offsets
|
// Project point at "infinity" to compute x and y offsets
|
||||||
|
|||||||
@@ -228,6 +228,9 @@ static void update_state(UIState *s) {
|
|||||||
scene.turn_signal_left = carState.getLeftBlinker();
|
scene.turn_signal_left = carState.getLeftBlinker();
|
||||||
scene.turn_signal_right = carState.getRightBlinker();
|
scene.turn_signal_right = carState.getRightBlinker();
|
||||||
}
|
}
|
||||||
|
if (scene.driver_camera) {
|
||||||
|
scene.show_driver_camera = carState.getGearShifter() == cereal::CarState::GearShifter::REVERSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (sm.updated("controlsState")) {
|
if (sm.updated("controlsState")) {
|
||||||
auto controlsState = sm["controlsState"].getControlsState();
|
auto controlsState = sm["controlsState"].getControlsState();
|
||||||
@@ -302,6 +305,8 @@ void ui_update_frogpilot_params(UIState *s) {
|
|||||||
scene.custom_icons = custom_theme ? params.getInt("CustomIcons") : 0;
|
scene.custom_icons = custom_theme ? params.getInt("CustomIcons") : 0;
|
||||||
scene.custom_signals = custom_theme ? params.getInt("CustomSignals") : 0;
|
scene.custom_signals = custom_theme ? params.getInt("CustomSignals") : 0;
|
||||||
|
|
||||||
|
scene.driver_camera = params.getBool("DriverCamera");
|
||||||
|
|
||||||
scene.model_ui = params.getBool("ModelUI");
|
scene.model_ui = params.getBool("ModelUI");
|
||||||
scene.dynamic_path_width = scene.model_ui && params.getBool("DynamicPathWidth");
|
scene.dynamic_path_width = scene.model_ui && params.getBool("DynamicPathWidth");
|
||||||
scene.lane_line_width = params.getInt("LaneLinesWidth") * (scene.is_metric ? 1.0f : INCH_TO_CM) / 200.0f;
|
scene.lane_line_width = params.getInt("LaneLinesWidth") * (scene.is_metric ? 1.0f : INCH_TO_CM) / 200.0f;
|
||||||
|
|||||||
@@ -178,12 +178,14 @@ typedef struct UIScene {
|
|||||||
bool blind_spot_path;
|
bool blind_spot_path;
|
||||||
bool blind_spot_right;
|
bool blind_spot_right;
|
||||||
bool conditional_experimental;
|
bool conditional_experimental;
|
||||||
|
bool driver_camera;
|
||||||
bool dynamic_path_width;
|
bool dynamic_path_width;
|
||||||
bool enabled;
|
bool enabled;
|
||||||
bool experimental_mode;
|
bool experimental_mode;
|
||||||
bool lead_info;
|
bool lead_info;
|
||||||
bool map_open;
|
bool map_open;
|
||||||
bool model_ui;
|
bool model_ui;
|
||||||
|
bool show_driver_camera;
|
||||||
bool turn_signal_left;
|
bool turn_signal_left;
|
||||||
bool turn_signal_right;
|
bool turn_signal_right;
|
||||||
bool unlimited_road_ui_length;
|
bool unlimited_road_ui_length;
|
||||||
|
|||||||
Reference in New Issue
Block a user