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

old-commit-hash: 33987d4cc9
pull/32199/head
Dean Lee 2 years ago committed by GitHub
parent 8aa5e117e0
commit 62525a60ee
  1. 15
      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);
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()) {

@ -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);
}
}

@ -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();
}

Loading…
Cancel
Save