This commit is contained in:
Your Name
2024-05-02 22:47:28 -05:00
parent e2cde8e886
commit 7ca074cd79
3 changed files with 40 additions and 34 deletions

View File

@@ -770,10 +770,10 @@ void AnnotatedCameraWidget::drawHud(QPainter &p) {
if (!(scene.hide_speed || bigMapOpen)) { if (!(scene.hide_speed || bigMapOpen)) {
// CLEARPILOT changes to 120 from ~176 // CLEARPILOT changes to 120 from ~176
// Maybe we want to hide this? // Maybe we want to hide this?
p.setFont(InterFont(120, QFont::Bold)); p.setFont(InterFont(140, QFont::Bold));
drawText(p, rect().center().x(), 210, speedStr); drawText(p, rect().center().x(), 210, speedStr);
// CLEARPILOT changes to 40 from 66 // CLEARPILOT changes to 40 from 66
p.setFont(InterFont(40)); p.setFont(InterFont(50));
drawText(p, rect().center().x(), 290, speedUnit, 200); drawText(p, rect().center().x(), 290, speedUnit, 200);
} }
@@ -824,14 +824,15 @@ void AnnotatedCameraWidget::drawLaneLines(QPainter &painter, const UIState *s) {
painter.save(); painter.save();
// CLEARPILOT: color channel code rewriten to allow custom colors // CLEARPILOT: color channel code rewriten to allow custom colors
// Define base RGB color and alpha // Center lane color
int base_red = 150; // Dark red component // This should be moved to ui.h
int base_green = 150; // Minimal green component int base_red = 150;
int base_blue = 150; // Minimal blue component int base_green = 150;
float path_alpha = 0.75; // 60% opacity int base_blue = 150;
float path_alpha = 0.30; // 60% opacity
float other_alpha = 0.75; // 60% opacity float other_alpha = 0.75; // 60% opacity
QColor baseColor(base_red, base_green, base_blue); QColor center_lane_color(base_red, base_green, base_blue);
SubMaster &sm = *(s->sm); SubMaster &sm = *(s->sm);
@@ -873,32 +874,38 @@ void AnnotatedCameraWidget::drawLaneLines(QPainter &painter, const UIState *s) {
acceleration.push_back(acceleration_const[i]); acceleration.push_back(acceleration_const[i]);
} }
for (int i = 0; i < max_len; ++i) { try {
if (scene.track_vertices[i].y() < 0 || scene.track_vertices[i].y() > height()) continue; for (int i = 0; i < max_len; ++i) {
if (scene.track_vertices[i].y() < 0 || scene.track_vertices[i].y() > height()) continue;
float lin_grad_point = (height() - scene.track_vertices[i].y()) / height(); float lin_grad_point = (height() - scene.track_vertices[i].y()) / height();
QColor base_color = QColor::fromRgb(base_red, base_green, base_blue); double _h, _s, _l; // Use double for compatibility with QColor::getHslF()
double _h, _s, _l; // Use double for compatibility with QColor::getHslF() center_lane_color.getHslF(&_h, &_s, &_l);
base_color.getHslF(&_h, &_s, &_l); // Extracting HSL values from the base color
// Calculate saturation and lightness based on acceleration // Calculate saturation and lightness based on acceleration
float adjusted_saturation = std::min(std::abs(acceleration[i] * 1.5f), 1.f); float adjusted_saturation = std::min(std::abs(acceleration[i] * 1.5f), 1.f);
float adjusted_lightness = util::map_val(adjusted_saturation, 0.f, 1.f, static_cast<float>(_l), 0.95f); // Using base lightness as a starting point float adjusted_lightness = util::map_val(adjusted_saturation, 0.f, 1.f, static_cast<float>(_l), 0.95f); // Using base lightness as a starting point
// Calculate dynamic alpha based on lin_grad_point // Calculate dynamic alpha based on lin_grad_point
float dynamic_alpha = util::map_val(lin_grad_point, 0.75f / 2.f, 0.75f, path_alpha, 0.f); float dynamic_alpha = util::map_val(lin_grad_point, 0.75f / 2.f, 0.75f, path_alpha, 0.f);
QColor final_color = QColor::fromHslF(static_cast<float>(_h / 360.f), adjusted_saturation, adjusted_lightness, dynamic_alpha); QColor final_color = QColor::fromHslF(static_cast<float>(_h / 360.f), adjusted_saturation, adjusted_lightness, dynamic_alpha);
bg.setColorAt(lin_grad_point, final_color); bg.setColorAt(lin_grad_point, final_color);
}
i += (i + 2) < max_len ? 1 : 0; // Skipping a point to optimize rendering i += (i + 2) < max_len ? 1 : 0; // Skipping a point to optimize rendering
}
} catch () {
// Default shading if for some reason the above code fails
bg = QLinearGradient(0, height(), 0, 0);
bg.setColorAt(0.0, QColor(center_lane_color.red(), center_lane_color.green(), center_lane_color.blue(), static_cast<int>(other_alpha * 255 * 0.4)));
bg.setColorAt(0.5, QColor(center_lane_color.red(), center_lane_color.green(), center_lane_color.blue(), static_cast<int>(other_alpha * 255 * 0.35)));
bg.setColorAt(1.0, QColor(center_lane_color.red(), center_lane_color.green(), center_lane_color.blue(), static_cast<int>(other_alpha * 255 * 0.0)));
} }
} else { } else {
bg.setColorAt(0.0, QColor(baseColor.red(), baseColor.green(), baseColor.blue(), static_cast<int>(other_alpha * 255 * 0.4))); bg.setColorAt(0.0, QColor(center_lane_color.red(), center_lane_color.green(), center_lane_color.blue(), static_cast<int>(other_alpha * 255 * 0.4)));
bg.setColorAt(0.5, QColor(baseColor.red(), baseColor.green(), baseColor.blue(), static_cast<int>(other_alpha * 255 * 0.35))); bg.setColorAt(0.5, QColor(center_lane_color.red(), center_lane_color.green(), center_lane_color.blue(), static_cast<int>(other_alpha * 255 * 0.35)));
bg.setColorAt(1.0, QColor(baseColor.red(), baseColor.green(), baseColor.blue(), static_cast<int>(other_alpha * 255 * 0.0))); bg.setColorAt(1.0, QColor(center_lane_color.red(), center_lane_color.green(), center_lane_color.blue(), static_cast<int>(other_alpha * 255 * 0.0)));
} }
painter.setBrush(bg); painter.setBrush(bg);

View File

@@ -360,7 +360,7 @@ void ui_update_frogpilot_params(UIState *s) {
scene.hide_lead_marker = scene.model_ui && params.getBool("HideLeadMarker"); scene.hide_lead_marker = scene.model_ui && params.getBool("HideLeadMarker");
// CLEARPILOT // CLEARPILOT
scene.lane_line_width = /* params.getInt("LaneLinesWidth") */ 2 * (scene.is_metric ? 1.0f : INCH_TO_CM) / 200.0f; scene.lane_line_width = /* params.getInt("LaneLinesWidth") */ 2 * (scene.is_metric ? 1.0f : INCH_TO_CM) / 200.0f;
scene.path_edge_width = /* params.getInt("PathEdgeWidth"); */ 15; scene.path_edge_width = /* params.getInt("PathEdgeWidth"); */ 16;
scene.path_width = params.getInt("PathWidth") / 10.0f * (scene.is_metric ? 1.0f : FOOT_TO_METER) / 2.0f; 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.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.unlimited_road_ui_length = scene.model_ui && params.getBool("UnlimitedLength");

View File

@@ -18,7 +18,7 @@
#include "selfdrive/ui/qt/network/wifi_manager.h" #include "selfdrive/ui/qt/network/wifi_manager.h"
#include "system/hardware/hw.h" #include "system/hardware/hw.h"
const int UI_BORDER_SIZE = 20; // clearpilot const int UI_BORDER_SIZE = 16; // clearpilot
const int UI_HEADER_HEIGHT = 420; const int UI_HEADER_HEIGHT = 420;
const int UI_FREQ = 20; // Hz const int UI_FREQ = 20; // Hz
@@ -130,12 +130,11 @@ typedef enum UIStatus {
// Clearpilot custom colors // Clearpilot custom colors
const QColor bg_colors [] = { const QColor bg_colors [] = {
[STATUS_DISENGAGED] = QColor(0x17, 0x33, 0x49, 0xc8), [STATUS_DISENGAGED] = QColor(0x17, 0x33, 0x49, 0xc8),
[STATUS_OVERRIDE] = QColor(217, 214, 137, 0xd1), // When you nudge the steering wheel while engaged [STATUS_OVERRIDE] = QColor(64, 85, 245, 0xd1), // When you nudge the steering wheel while engaged
// [STATUS_ENGAGED] = QColor(218, 112, 36, 0xd1), // Orange [STATUS_ENGAGED] = QColor(64, 85, 245, 0xd1), // Orange
[STATUS_ENGAGED] = QColor(217, 214, 137, 0xd1), // Orange [STATUS_ALWAYS_ON_LATERAL_ACTIVE] = QColor(162, 221, 235, 0xd1), // Gray
[STATUS_ALWAYS_ON_LATERAL_ACTIVE] = QColor(158, 126, 111, 0xd1), // Gray
[STATUS_TRAFFIC_MODE_ACTIVE] = QColor(0xc9, 0x22, 0x31, 0xd1), // ? unused? [STATUS_TRAFFIC_MODE_ACTIVE] = QColor(0xc9, 0x22, 0x31, 0xd1), // ? unused?
[STATUS_EXPERIMENTAL_ACTIVE] = QColor(126, 32, 128, 0xd1), // Magenta [STATUS_EXPERIMENTAL_ACTIVE] = QColor(201, 41, 204, 0xd1), // Magenta
}; };
static std::map<cereal::ControlsState::AlertStatus, QColor> alert_colors = { static std::map<cereal::ControlsState::AlertStatus, QColor> alert_colors = {