From d0ba19fedb897443248ad0f096dc6ffdca983872 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Wed, 6 Jan 2021 18:19:10 +0800 Subject: [PATCH] fix problem with drawing path (#19670) --- selfdrive/ui/paint.cc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 18dd91191b..56738bf404 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -150,12 +150,9 @@ static void update_track_data(UIState *s, const cereal::ModelDataV2::XYZTData::R const UIScene *scene = &s->scene; const float off = 0.5; int max_idx = -1; - float lead_d; - if (s->sm->updated("radarState")) { - lead_d = scene->lead_data[0].getDRel()*2.; - } else { - lead_d = MAX_DRAW_DISTANCE; - } + const auto lead = scene->lead_data[0]; + float lead_d = lead.getStatus() ? lead.getDRel()*2. : MAX_DRAW_DISTANCE; + float path_length = (lead_d>0.)?lead_d-fmin(lead_d*0.35, 10.):MAX_DRAW_DISTANCE; path_length = fmin(path_length, scene->max_distance);