Skip to content

Commit

Permalink
ui: Draw feature statuses on camera view (commaai#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnyhaibin authored Sep 13, 2023
1 parent 9545f25 commit 35186a3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
22 changes: 21 additions & 1 deletion selfdrive/ui/qt/onroad.cc
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ void AnnotatedCameraWidget::updateState(const UIState &s) {
}

const auto lp = sm["longitudinalPlan"].getLongitudinalPlan();
slcState = lp.getSpeedLimitControlState();

if (sm.frame % (UI_FREQ / 2) == 0) {
const auto vtcState = lp.getVisionTurnControllerState();
Expand All @@ -568,7 +569,6 @@ void AnnotatedCameraWidget::updateState(const UIState &s) {

float speed_limit_slc = lp.getSpeedLimit() * (s.scene.is_metric ? MS_TO_KPH : MS_TO_MPH);
const float speed_limit_offset = lp.getSpeedLimitOffset() * (s.scene.is_metric ? MS_TO_KPH : MS_TO_MPH);
const auto slcState = lp.getSpeedLimitControlState();
const bool sl_force_active = s.scene.speed_limit_control_enabled &&
seconds_since_boot() < s.scene.last_speed_limit_sign_tap + 2.0;
const bool sl_inactive = !sl_force_active && (!s.scene.speed_limit_control_enabled ||
Expand Down Expand Up @@ -853,6 +853,11 @@ void AnnotatedCameraWidget::drawHud(QPainter &p) {
if (uiState()->scene.e2e_long_alert_ui && e2eState != 0) {
drawE2eStatus(p, UI_BORDER_SIZE * 2 + 190, 45, 150, 150, e2eState);
}

if (!hideBottomIcons) {
drawFeatureStatusText(p, UI_BORDER_SIZE * 2 + 370, rect().bottom() - 155 - uiState()->scene.rn_offset);
}

p.restore();
}

Expand Down Expand Up @@ -1453,6 +1458,21 @@ int AnnotatedCameraWidget::blinkerPulse(int frame) {
return blinker_state;
}

void AnnotatedCameraWidget::drawFeatureStatusText(QPainter &p, int x, int y) {
QString status_text;
const int text_height = 34;

p.setFont(InterFont(32, QFont::Bold));
p.setPen(whiteColor());

status_text.sprintf("GAC: %s\n", QString::number(uiState()->scene.gac_tr).toStdString().c_str());
p.drawText(x, y, status_text);

y += text_height;
status_text.sprintf("SLC: %s\n", QString::number(int(slcState)).toStdString().c_str());
p.drawText(x, y, status_text);
}


void AnnotatedCameraWidget::initializeGL() {
CameraWidget::initializeGL();
Expand Down
4 changes: 4 additions & 0 deletions selfdrive/ui/qt/onroad.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ class AnnotatedCameraWidget : public CameraWidget {
int blinkerPulse(int frame);
void updateButtonsLayout();

void drawFeatureStatusText(QPainter &p, int x, int y);

uint64_t last_update_params;

QVBoxLayout *main_layout;
Expand Down Expand Up @@ -229,6 +231,8 @@ class AnnotatedCameraWidget : public CameraWidget {
FirstOrderFilter fps_filter;
void rocketFuel(QPainter &p);

cereal::LongitudinalPlan::SpeedLimitControlState slcState;

// neokii
#ifdef ENABLE_DASHCAM
private:
Expand Down

0 comments on commit 35186a3

Please sign in to comment.