ui/onroad: avoid drawing invalid lanes and leads (#29666)

pull/30727/head
Dean Lee 2 years ago committed by GitHub
parent 2a1403a46b
commit 33987d4cc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      selfdrive/ui/qt/onroad.cc
  2. 7
      selfdrive/ui/ui.cc
  3. 4
      selfdrive/ui/ui.h

@ -605,7 +605,6 @@ void AnnotatedCameraWidget::paintGL() {
SubMaster &sm = *(s->sm); SubMaster &sm = *(s->sm);
const double start_draw_t = millis_since_boot(); const double start_draw_t = millis_since_boot();
const cereal::ModelDataV2::Reader &model = sm["modelV2"].getModelV2(); const cereal::ModelDataV2::Reader &model = sm["modelV2"].getModelV2();
const cereal::RadarState::Reader &radar_state = sm["radarState"].getRadarState();
// draw camera frame // draw camera frame
{ {
@ -654,17 +653,13 @@ void AnnotatedCameraWidget::paintGL() {
painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::Antialiasing);
painter.setPen(Qt::NoPen); painter.setPen(Qt::NoPen);
if (s->worldObjectsVisible()) { if (s->scene.world_objects_visible) {
if (sm.rcv_frame("modelV2") > s->scene.started_frame) {
update_model(s, model, sm["uiPlan"].getUiPlan()); update_model(s, model, sm["uiPlan"].getUiPlan());
if (sm.rcv_frame("radarState") > s->scene.started_frame) {
update_leads(s, radar_state, model.getPosition());
}
}
drawLaneLines(painter, s); drawLaneLines(painter, s);
if (s->scene.longitudinal_control) { if (s->scene.longitudinal_control && sm.rcv_frame("radarState") > s->scene.started_frame) {
auto radar_state = sm["radarState"].getRadarState();
update_leads(s, radar_state, model.getPosition());
auto lead_one = radar_state.getLeadOne(); auto lead_one = radar_state.getLeadOne();
auto lead_two = radar_state.getLeadTwo(); auto lead_two = radar_state.getLeadTwo();
if (lead_one.getStatus()) { if (lead_one.getStatus()) {

@ -207,6 +207,12 @@ static void update_state(UIState *s) {
scene.light_sensor = std::max(100.0f - scale * cam_state.getExposureValPercent(), 0.0f); scene.light_sensor = std::max(100.0f - scale * cam_state.getExposureValPercent(), 0.0f);
} }
scene.started = sm["deviceState"].getDeviceState().getStarted() && scene.ignition; scene.started = sm["deviceState"].getDeviceState().getStarted() && scene.ignition;
scene.world_objects_visible = scene.world_objects_visible ||
(scene.started &&
sm.rcv_frame("liveCalibration") > scene.started_frame &&
sm.rcv_frame("modelV2") > scene.started_frame &&
sm.rcv_frame("uiPlan") > scene.started_frame);
} }
void ui_update_params(UIState *s) { void ui_update_params(UIState *s) {
@ -233,6 +239,7 @@ void UIState::updateStatus() {
scene.started_frame = sm->frame; scene.started_frame = sm->frame;
} }
started_prev = scene.started; started_prev = scene.started;
scene.world_objects_visible = false;
emit offroadTransition(!scene.started); emit offroadTransition(!scene.started);
} }
} }

@ -158,6 +158,7 @@ typedef struct UIScene {
float light_sensor; float light_sensor;
bool started, ignition, is_metric, map_on_left, longitudinal_control; bool started, ignition, is_metric, map_on_left, longitudinal_control;
bool world_objects_visible = false;
uint64_t started_frame; uint64_t started_frame;
} UIScene; } UIScene;
@ -167,9 +168,6 @@ class UIState : public QObject {
public: public:
UIState(QObject* parent = 0); UIState(QObject* parent = 0);
void updateStatus(); void updateStatus();
inline bool worldObjectsVisible() const {
return sm->rcv_frame("liveCalibration") > scene.started_frame;
}
inline bool engaged() const { inline bool engaged() const {
return scene.started && (*sm)["controlsState"].getControlsState().getEnabled(); return scene.started && (*sm)["controlsState"].getControlsState().getEnabled();
} }

Loading…
Cancel
Save