diff --git a/selfdrive/ui/qt/onroad.cc b/selfdrive/ui/qt/onroad.cc index 971eb673e2..b4c39cafb5 100644 --- a/selfdrive/ui/qt/onroad.cc +++ b/selfdrive/ui/qt/onroad.cc @@ -605,7 +605,6 @@ void AnnotatedCameraWidget::paintGL() { SubMaster &sm = *(s->sm); const double start_draw_t = millis_since_boot(); const cereal::ModelDataV2::Reader &model = sm["modelV2"].getModelV2(); - const cereal::RadarState::Reader &radar_state = sm["radarState"].getRadarState(); // draw camera frame { @@ -654,17 +653,13 @@ void AnnotatedCameraWidget::paintGL() { painter.setRenderHint(QPainter::Antialiasing); painter.setPen(Qt::NoPen); - if (s->worldObjectsVisible()) { - if (sm.rcv_frame("modelV2") > s->scene.started_frame) { - update_model(s, model, sm["uiPlan"].getUiPlan()); - if (sm.rcv_frame("radarState") > s->scene.started_frame) { - update_leads(s, radar_state, model.getPosition()); - } - } - + if (s->scene.world_objects_visible) { + update_model(s, model, sm["uiPlan"].getUiPlan()); 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_two = radar_state.getLeadTwo(); if (lead_one.getStatus()) { diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 7b2d24b53a..906de7d1ee 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -207,6 +207,12 @@ static void update_state(UIState *s) { scene.light_sensor = std::max(100.0f - scale * cam_state.getExposureValPercent(), 0.0f); } 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) { @@ -233,6 +239,7 @@ void UIState::updateStatus() { scene.started_frame = sm->frame; } started_prev = scene.started; + scene.world_objects_visible = false; emit offroadTransition(!scene.started); } } diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index d9a03344b6..86cd70f028 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -158,6 +158,7 @@ typedef struct UIScene { float light_sensor; bool started, ignition, is_metric, map_on_left, longitudinal_control; + bool world_objects_visible = false; uint64_t started_frame; } UIScene; @@ -167,9 +168,6 @@ class UIState : public QObject { public: UIState(QObject* parent = 0); void updateStatus(); - inline bool worldObjectsVisible() const { - return sm->rcv_frame("liveCalibration") > scene.started_frame; - } inline bool engaged() const { return scene.started && (*sm)["controlsState"].getControlsState().getEnabled(); }