Skip to content

Commit

Permalink
ui/update_model: do not recalculate the max_idx If there is no lead (c…
Browse files Browse the repository at this point in the history
  • Loading branch information
deanlee authored Jan 4, 2022
1 parent a11bb81 commit f561d84
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions selfdrive/ui/ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ static void update_model(UIState *s, const cereal::ModelDataV2::Reader &model) {
auto model_position = model.getPosition();
float max_distance = std::clamp(model_position.getX()[TRAJECTORY_SIZE - 1],
MIN_DRAW_DISTANCE, MAX_DRAW_DISTANCE);
int max_idx = get_path_length_idx(model_position, max_distance);

// update lane lines
const auto lane_lines = model.getLaneLines();
const auto lane_line_probs = model.getLaneLineProbs();
int max_idx = get_path_length_idx(lane_lines[0], max_distance);
for (int i = 0; i < std::size(scene.lane_line_vertices); i++) {
scene.lane_line_probs[i] = lane_line_probs[i];
update_line_data(s, lane_lines[i], 0.025 * scene.lane_line_probs[i], 0, &scene.lane_line_vertices[i], max_idx);
Expand All @@ -94,8 +94,8 @@ static void update_model(UIState *s, const cereal::ModelDataV2::Reader &model) {
if (lead_one.getStatus()) {
const float lead_d = lead_one.getDRel() * 2.;
max_distance = std::clamp((float)(lead_d - fmin(lead_d * 0.35, 10.)), 0.0f, max_distance);
max_idx = get_path_length_idx(model_position, max_distance);
}
max_idx = get_path_length_idx(model_position, max_distance);
update_line_data(s, model_position, 0.5, 1.22, &scene.track_vertices, max_idx);
}

Expand Down

0 comments on commit f561d84

Please sign in to comment.