mirror of
https://github.com/MoreTore/openpilot.git
synced 2026-08-05 16:26:14 +08:00
e2e long yellow path (#25679)
* yellow brick road * live toggling * path color from acceleration * more yellow
This commit is contained in:
+33
-11
@@ -459,19 +459,41 @@ void NvgWindow::drawLaneLines(QPainter &painter, const UIState *s) {
|
||||
|
||||
// paint path
|
||||
QLinearGradient bg(0, height(), 0, height() / 4);
|
||||
const auto &orientation = (*s->sm)["modelV2"].getModelV2().getOrientation();
|
||||
float orientation_future = 0;
|
||||
if (orientation.getZ().size() > 16) {
|
||||
orientation_future = std::abs(orientation.getZ()[16]); // 2.5 seconds
|
||||
float start_hue, end_hue;
|
||||
if (scene.end_to_end_long) {
|
||||
const auto &acceleration = (*s->sm)["modelV2"].getModelV2().getAcceleration();
|
||||
float acceleration_future = 0;
|
||||
if (acceleration.getZ().size() > 16) {
|
||||
acceleration_future = acceleration.getX()[16]; // 2.5 seconds
|
||||
}
|
||||
start_hue = 60;
|
||||
// speed up: 120, slow down: 0
|
||||
end_hue = fmax(fmin(start_hue + acceleration_future * 30, 120), 0);
|
||||
|
||||
// FIXME: painter.drawPolygon can be slow if hue is not rounded
|
||||
end_hue = int(end_hue * 100 + 0.5) / 100;
|
||||
|
||||
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 {
|
||||
const auto &orientation = (*s->sm)["modelV2"].getModelV2().getOrientation();
|
||||
float orientation_future = 0;
|
||||
if (orientation.getZ().size() > 16) {
|
||||
orientation_future = std::abs(orientation.getZ()[16]); // 2.5 seconds
|
||||
}
|
||||
start_hue = 148;
|
||||
// straight: 112, in turns: 70
|
||||
end_hue = fmax(70, 112 - (orientation_future * 420));
|
||||
|
||||
// FIXME: painter.drawPolygon can be slow if hue is not rounded
|
||||
end_hue = int(end_hue * 100 + 0.5) / 100;
|
||||
|
||||
bg.setColorAt(0.0, QColor::fromHslF(start_hue / 360., 0.94, 0.51, 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));
|
||||
}
|
||||
// straight: 112, in turns: 70
|
||||
float curve_hue = fmax(70, 112 - (orientation_future * 420));
|
||||
// FIXME: painter.drawPolygon can be slow if hue is not rounded
|
||||
curve_hue = int(curve_hue * 100 + 0.5) / 100;
|
||||
|
||||
bg.setColorAt(0.0, QColor::fromHslF(148 / 360., 0.94, 0.51, 0.4));
|
||||
bg.setColorAt(0.75 / 1.5, QColor::fromHslF(curve_hue / 360., 1.0, 0.68, 0.35));
|
||||
bg.setColorAt(1.0, QColor::fromHslF(curve_hue / 360., 1.0, 0.68, 0.0));
|
||||
painter.setBrush(bg);
|
||||
painter.drawPolygon(scene.track_vertices);
|
||||
|
||||
|
||||
@@ -195,6 +195,7 @@ void ui_update_params(UIState *s) {
|
||||
auto params = Params();
|
||||
s->scene.is_metric = params.getBool("IsMetric");
|
||||
s->scene.map_on_left = params.getBool("NavSettingLeftSide");
|
||||
s->scene.end_to_end_long = params.getBool("EndToEndLong");
|
||||
}
|
||||
|
||||
void UIState::updateStatus() {
|
||||
|
||||
+1
-1
@@ -101,7 +101,7 @@ typedef struct UIScene {
|
||||
QPointF lead_vertices[2];
|
||||
|
||||
float light_sensor, accel_sensor, gyro_sensor;
|
||||
bool started, ignition, is_metric, map_on_left, longitudinal_control;
|
||||
bool started, ignition, is_metric, map_on_left, longitudinal_control, end_to_end_long;
|
||||
uint64_t started_frame;
|
||||
} UIScene;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user