Skip to content

Commit

Permalink
UI: better lag logging (commaai#24042)
Browse files Browse the repository at this point in the history
* UI: better lag logging

* remove print
  • Loading branch information
adeebshihadeh authored Mar 25, 2022
1 parent 4802c86 commit 67e3a2c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
11 changes: 8 additions & 3 deletions selfdrive/ui/qt/onroad.cc
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,11 @@ void OnroadHud::drawIcon(QPainter &p, int x, int y, QPixmap &img, QBrush bg, flo
}

// NvgWindow

NvgWindow::NvgWindow(VisionStreamType type, QWidget* parent) : fps_filter(UI_FREQ, 3, 1. / UI_FREQ), CameraViewWidget("camerad", type, true, parent) {

}

void NvgWindow::initializeGL() {
CameraViewWidget::initializeGL();
qInfo() << "OpenGL version:" << QString((const char*)glGetString(GL_VERSION));
Expand Down Expand Up @@ -376,9 +381,9 @@ void NvgWindow::paintGL() {

double cur_draw_t = millis_since_boot();
double dt = cur_draw_t - prev_draw_t;
if (dt > 66) {
// warn on sub 15fps
LOGW("slow frame time: %.2f", dt);
double fps = fps_filter.update(1. / dt * 1000);
if (fps < 15) {
LOGW("slow frame rate: %.2f fps", fps);
}
prev_draw_t = cur_draw_t;
}
Expand Down
5 changes: 4 additions & 1 deletion selfdrive/ui/qt/onroad.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <QStackedLayout>
#include <QWidget>

#include "selfdrive/common/util.h"
#include "selfdrive/ui/qt/widgets/cameraview.h"
#include "selfdrive/ui/ui.h"

Expand Down Expand Up @@ -66,7 +67,7 @@ class NvgWindow : public CameraViewWidget {
Q_OBJECT

public:
explicit NvgWindow(VisionStreamType type, QWidget* parent = 0) : CameraViewWidget("camerad", type, true, parent) {}
explicit NvgWindow(VisionStreamType type, QWidget* parent = 0);

protected:
void paintGL() override;
Expand All @@ -77,7 +78,9 @@ class NvgWindow : public CameraViewWidget {
void drawLead(QPainter &painter, const cereal::ModelDataV2::LeadDataV3::Reader &lead_data, const QPointF &vd);
inline QColor redColor(int alpha = 255) { return QColor(201, 34, 49, alpha); }
inline QColor whiteColor(int alpha = 255) { return QColor(255, 255, 255, alpha); }

double prev_draw_t = 0;
FirstOrderFilter fps_filter;
};

// container for all onroad widgets
Expand Down

0 comments on commit 67e3a2c

Please sign in to comment.