mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-22 08:43:54 +08:00
Gas / Brake Pedal Indicators
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 6.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
@@ -5,8 +5,10 @@ FrogPilotAnnotatedCameraWidget::FrogPilotAnnotatedCameraWidget(QWidget *parent)
|
||||
|
||||
QSize iconSize(img_size / 4, img_size / 4);
|
||||
|
||||
brakePedalImg = loadPixmap("../../frogpilot/assets/other_images/brake_pedal.png", {btn_size, btn_size});
|
||||
curveSpeedIcon = loadPixmap("../../frogpilot/assets/other_images/curve_speed.png", {btn_size, btn_size});
|
||||
curveSpeedIconFlipped = curveSpeedIcon.transformed(QTransform().scale(-1, 1));
|
||||
gasPedalImg = loadPixmap("../../frogpilot/assets/other_images/gas_pedal.png", {btn_size, btn_size});
|
||||
pausedIcon = loadPixmap("../../frogpilot/assets/other_images/paused_icon.png", {widget_size, widget_size});
|
||||
speedIcon = loadPixmap("../../frogpilot/assets/other_images/speed_icon.png", {widget_size, widget_size});
|
||||
stopSignImg = loadPixmap("../../frogpilot/assets/other_images/stop_sign.png", {btn_size, btn_size});
|
||||
@@ -143,10 +145,12 @@ void FrogPilotAnnotatedCameraWidget::updateState(const UIState &s, const FrogPil
|
||||
speedConversionMetrics = MS_TO_MPH;
|
||||
}
|
||||
|
||||
accelerationEgo = carState.getAEgo();
|
||||
blindspotLeft = carState.getLeftBlindspot();
|
||||
blindspotRight = carState.getRightBlindspot();
|
||||
blinkerLeft = carState.getLeftBlinker();
|
||||
blinkerRight = carState.getRightBlinker();
|
||||
brakeLights = frogpilotCarState.getBrakeLights();
|
||||
cscControllingSpeed = frogpilotPlan.getCscControllingSpeed();
|
||||
cscSpeed = frogpilotPlan.getCscSpeed();
|
||||
cscTraining = frogpilotPlan.getCscTraining();
|
||||
@@ -227,6 +231,10 @@ void FrogPilotAnnotatedCameraWidget::paintFrogPilotWidgets(QPainter &p, UIState
|
||||
paintLongitudinalPaused(p);
|
||||
}
|
||||
|
||||
if (frogpilot_toggles.value("pedals_on_ui").toBool()) {
|
||||
paintPedalIcons(p);
|
||||
}
|
||||
|
||||
if (frogpilot_toggles.value("radar_tracks").toBool()) {
|
||||
paintRadarTracks(p);
|
||||
}
|
||||
@@ -488,6 +496,32 @@ void FrogPilotAnnotatedCameraWidget::paintLongitudinalPaused(QPainter &p) {
|
||||
p.restore();
|
||||
}
|
||||
|
||||
void FrogPilotAnnotatedCameraWidget::paintPedalIcons(QPainter &p) {
|
||||
p.save();
|
||||
|
||||
float brakeOpacity = 1.0f;
|
||||
float gasOpacity = 1.0f;
|
||||
|
||||
if (frogpilot_toggles.value("dynamic_pedals_on_ui").toBool()) {
|
||||
brakeOpacity = frogpilot_scene.standstill ? 1.0f : accelerationEgo < -0.25f ? std::max(0.25f, std::abs(accelerationEgo)) : 0.25f;
|
||||
gasOpacity = std::max(0.25f, accelerationEgo);
|
||||
} else if (frogpilot_toggles.value("static_pedals_on_ui").toBool()) {
|
||||
brakeOpacity = frogpilot_scene.standstill || brakeLights || accelerationEgo < -0.25f ? 1.0f : 0.25f;
|
||||
gasOpacity = accelerationEgo > 0.25 ? 1.0f : 0.25f;
|
||||
}
|
||||
|
||||
int startX = experimentalButtonPosition.x();
|
||||
int startY = experimentalButtonPosition.y() + btn_size + UI_BORDER_SIZE;
|
||||
|
||||
p.setOpacity(brakeOpacity);
|
||||
p.drawPixmap(startX, startY, brakePedalImg);
|
||||
|
||||
p.setOpacity(gasOpacity);
|
||||
p.drawPixmap(startX + btn_size / 2, startY, gasPedalImg);
|
||||
|
||||
p.restore();
|
||||
}
|
||||
|
||||
void FrogPilotAnnotatedCameraWidget::paintRadarTracks(QPainter &p) {
|
||||
if (radar_tracks.empty()) {
|
||||
return;
|
||||
|
||||
@@ -53,6 +53,7 @@ private:
|
||||
void paintCurveSpeedControl(QPainter &p);
|
||||
void paintCurveSpeedControlTraining(QPainter &p);
|
||||
void paintLongitudinalPaused(QPainter &p);
|
||||
void paintPedalIcons(QPainter &p);
|
||||
void paintRadarTracks(QPainter &p);
|
||||
void paintRoadName(QPainter &p);
|
||||
void paintStandstillTimer(QPainter &p);
|
||||
@@ -64,6 +65,7 @@ private:
|
||||
bool blindspotRight;
|
||||
bool blinkerLeft;
|
||||
bool blinkerRight;
|
||||
bool brakeLights;
|
||||
bool cscControllingSpeed;
|
||||
bool cscTraining;
|
||||
bool experimentalMode;
|
||||
@@ -78,6 +80,7 @@ private:
|
||||
int signalWidth;
|
||||
int totalFrames;
|
||||
|
||||
float accelerationEgo;
|
||||
float cscSpeed;
|
||||
float distanceConversion;
|
||||
float roadCurvature;
|
||||
@@ -95,8 +98,10 @@ private:
|
||||
QElapsedTimer glowTimer;
|
||||
QElapsedTimer standstillTimer;
|
||||
|
||||
QPixmap brakePedalImg;
|
||||
QPixmap curveSpeedIcon;
|
||||
QPixmap curveSpeedIconFlipped;
|
||||
QPixmap gasPedalImg;
|
||||
QPixmap pausedIcon;
|
||||
QPixmap speedIcon;
|
||||
QPixmap stopSignImg;
|
||||
|
||||
Reference in New Issue
Block a user