Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: DM icon shows engaged IF always-on #33183

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions selfdrive/ui/qt/onroad/annotated_camera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <algorithm>
#include <cmath>

#include "common/params.h"
#include "common/swaglog.h"
#include "selfdrive/ui/qt/onroad/buttons.h"
#include "selfdrive/ui/qt/util.h"
Expand All @@ -23,6 +24,12 @@ AnnotatedCameraWidget::AnnotatedCameraWidget(VisionStreamType type, QWidget* par
dm_img = loadPixmap("../assets/img_driver_face.png", {img_size + 5, img_size + 5});
}

// Checks if "Always-On Driver Monitoring" toggle is enabled in settings
bool AnnotatedCameraWidget::isDMAlwaysOn() const {
Params params;
return params.getBool("AlwaysOnDM");
}

ugtthis marked this conversation as resolved.
Show resolved Hide resolved
void AnnotatedCameraWidget::updateState(const UIState &s) {
const int SET_SPEED_NA = 255;
const SubMaster &sm = *(s.sm);
Expand Down Expand Up @@ -236,9 +243,12 @@ void AnnotatedCameraWidget::drawDriverState(QPainter &painter, const UIState *s)
const int arc_l = 133;
const float arc_t_default = 6.7;
const float arc_t_extend = 12.0;
QColor arc_color = QColor::fromRgbF(0.545 - 0.445 * s->engaged(),
0.545 + 0.4 * s->engaged(),
0.545 - 0.285 * s->engaged(),

bool show_dm_engaged = s->engaged() || isDMAlwaysOn();

QColor arc_color = QColor::fromRgbF(0.545 - 0.445 * show_dm_engaged,
0.545 + 0.4 * show_dm_engaged,
0.545 - 0.285 * show_dm_engaged,
ugtthis marked this conversation as resolved.
Show resolved Hide resolved
0.4 * (1.0 - dm_fade_state));
float delta_x = -scene.driver_pose_sins[1] * arc_l / 2;
float delta_y = -scene.driver_pose_sins[0] * arc_l / 2;
Expand Down
2 changes: 2 additions & 0 deletions selfdrive/ui/qt/onroad/annotated_camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class AnnotatedCameraWidget : public CameraWidget {
int skip_frame_count = 0;
bool wide_cam_requested = false;

bool isDMAlwaysOn() const;

protected:
void paintGL() override;
void initializeGL() override;
Expand Down
Loading