Skip to content

Commit

Permalink
Requested changes, moved conditional to function call
Browse files Browse the repository at this point in the history
  • Loading branch information
Willebrew committed Oct 8, 2024
1 parent 2bf1b1e commit c018aac
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
35 changes: 18 additions & 17 deletions tools/replay/lib/rp_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
(240, "orange", (255, 146, 0)),
(255, "white", (255, 255, 255)),
(110, "carColor", (255,0,127)),
(0, "background", (0, 0, 0)),]
(0, "background", (0, 0, 0))]


class UIParams:
Expand Down Expand Up @@ -70,24 +70,25 @@ def plot_lead(rs, lid_overlay):


def maybe_update_radar_points(lt, lid_overlay):
if lt is not None and hasattr(lt, 'trackList'):
ar_pts = []
if lt is not None:
ar_pts = {}
for track in lt.trackList:
for track in lt:
ar_pts[track.trackId] = [track.dRel, track.yRel, track.vRel, track.aRel, track.oncoming, track.stationary]
for ids, pt in ar_pts.items():
# negative here since radar is left positive
px, py = to_topdown_pt(pt[0], -pt[1])
if px != -1:
if pt[-1]:
color = rerunColorPalette[4][0]
elif pt[-2]:
color = rerunColorPalette[3][0]
else:
color = rerunColorPalette[5][0]
if int(ids) == 1:
lid_overlay[px - 2:px + 2, py - 10:py + 10] = rerunColorPalette[1][0]
else:
lid_overlay[px - 2:px + 2, py - 2:py + 2] = color
for ids, pt in ar_pts.items():
# negative here since radar is left positive
px, py = to_topdown_pt(pt[0], -pt[1])
if px != -1:
if pt[-1]:
color = rerunColorPalette[4][0]
elif pt[-2]:
color = rerunColorPalette[3][0]
else:
color = rerunColorPalette[5][0]
if int(ids) == 1:
lid_overlay[px - 2:px + 2, py - 10:py + 10] = rerunColorPalette[1][0]
else:
lid_overlay[px - 2:px + 2, py - 2:py + 2] = color


def get_blank_lid_overlay(UP):
Expand Down
3 changes: 2 additions & 1 deletion tools/replay/rp_visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ def visualize(addr):
if sm.recv_frame['radarState']:
plot_lead(sm['radarState'], lid_overlay)
liveTracksTime = sm.logMonoTime['liveTracks']
maybe_update_radar_points(sm['liveTracks'], lid_overlay)
if sm['liveTracks'] is not None and hasattr(sm['liveTracks'], 'trackList'):
maybe_update_radar_points(sm['liveTracks'], lid_overlay)
rr.set_time_nanos("TIMELINE", liveTracksTime)
rr.log("tracks", rr.SegmentationImage(np.flip(np.rot90(lid_overlay, k=-1), axis=1)))

Expand Down

0 comments on commit c018aac

Please sign in to comment.