ui: more granular accel gradient in experimental mode (#27391)

* add accel

* debugging

* use uiPlan for acceleration

* draw on same frame, ui color enhancements

* adjustments

* not needed

* add back alerts and wide cam

* use linear accel -> saturation (red -> green transition is more gradual, should be easier to understand)

* 1.5x was good from the non-linear previous commit

* fix crash?

* revert draw on same frame

* bump lightness add lightness mod with comment for future use (reverting in next commit)

* revert (but keep lightness bump)

* max accel isn't blueish (#3DFF3D)

* clean up

* revert lightness

* remove experiment

* try a different domain

* doesn't work

This reverts commit 7a398b0392.

* clean that up

* actually should be 0.75

* some clean up

* debug timing

* fix

* debug

* round

* revert wide

* not used

* clean up

* remove slow qDebug

* this too

* draw max constant points, ensure we draw first and last

* clean up

* more clean up

* draft

* Revert "draft"

This reverts commit 59db097611.

* Revert "Revert "draft""

This reverts commit ee86c385b3.

* simplify

* clean that up

* and all that

* and more

* aaaand that

* aaaand that

* track vert is created in update_line_data, it us the sum of two equal
len lists

* keep debugging stuff around

* keep debugging stuff around

* remove prints

* rm that

* moreee

* use existing helper 😄

* clean up

* make it const

* F

---------

Co-authored-by: Bruce Wayne <harald.the.engineer@gmail.com>
Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
pull/28119/head
Shane Smiskol 2 years ago committed by GitHub
parent b3a3040d09
commit 884e36bc9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 40
      selfdrive/ui/qt/onroad.cc

@ -511,24 +511,34 @@ void AnnotatedCameraWidget::drawLaneLines(QPainter &painter, const UIState *s) {
} }
// paint path // paint path
QLinearGradient bg(0, height(), 0, height() / 4); QLinearGradient bg(0, height(), 0, 0);
float start_hue, end_hue;
if (sm["controlsState"].getControlsState().getExperimentalMode()) { if (sm["controlsState"].getControlsState().getExperimentalMode()) {
const auto &acceleration = sm["modelV2"].getModelV2().getAcceleration(); const QVector<QPointF> right_points = scene.track_vertices.mid(0, scene.track_vertices.length() / 2);
float acceleration_future = 0;
if (acceleration.getZ().size() > 16) { for (int i = 0; i < right_points.length(); i++) {
acceleration_future = acceleration.getX()[16]; // 2.5 seconds const auto &acceleration = sm["uiPlan"].getUiPlan().getAccel();
} if (i >= acceleration.size()) break;
start_hue = 60;
// speed up: 120, slow down: 0 // Some points are out of frame
end_hue = fmax(fmin(start_hue + acceleration_future * 45, 148), 0); if (right_points[i].y() < 0 || right_points[i].y() > height()) continue;
// Flip so 0 is bottom of frame
float lin_grad_point = (height() - right_points[i].y()) / height();
// FIXME: painter.drawPolygon can be slow if hue is not rounded // speed up: 120, slow down: 0
end_hue = int(end_hue * 100 + 0.5) / 100; float path_hue = fmax(fmin(60 + acceleration[i] * 35, 120), 0);
// FIXME: painter.drawPolygon can be slow if hue is not rounded
path_hue = int(path_hue * 100 + 0.5) / 100;
float saturation = fmin(fabs(acceleration[i] * 1.5), 1);
float lightness = util::map_val(saturation, 0.0f, 1.0f, 0.95f, 0.62f); // lighter when grey
float alpha = util::map_val(lin_grad_point, 0.75f / 2.f, 0.75f, 0.4f, 0.0f); // matches previous alpha fade
bg.setColorAt(lin_grad_point, QColor::fromHslF(path_hue / 360., saturation, lightness, alpha));
// Skip a point, unless next is last
i += (i + 2) < right_points.length() ? 1 : 0;
}
bg.setColorAt(0.0, QColor::fromHslF(start_hue / 360., 0.97, 0.56, 0.4));
bg.setColorAt(0.5, QColor::fromHslF(end_hue / 360., 1.0, 0.68, 0.35));
bg.setColorAt(1.0, QColor::fromHslF(end_hue / 360., 1.0, 0.68, 0.0));
} else { } else {
bg.setColorAt(0.0, QColor::fromHslF(148 / 360., 0.94, 0.51, 0.4)); bg.setColorAt(0.0, QColor::fromHslF(148 / 360., 0.94, 0.51, 0.4));
bg.setColorAt(0.5, QColor::fromHslF(112 / 360., 1.0, 0.68, 0.35)); bg.setColorAt(0.5, QColor::fromHslF(112 / 360., 1.0, 0.68, 0.35));

Loading…
Cancel
Save