Skip to content

Commit 825bdd2

Browse files
committed
fix radar message for meb
1 parent d275c65 commit 825bdd2

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

openpilot/tools/replay/lib/ui_helpers.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@ class UIParams:
2323
lidar_x, lidar_y, lidar_zoom = 384, 960, 6
2424
lidar_car_x, lidar_car_y = lidar_x / 2.0, lidar_y / 1.1
2525
car_hwidth = 1.7272 / 2 * lidar_zoom
26-
car_front = 2.6924 * lidar_zoom
27-
car_back = 1.8796 * lidar_zoom
26+
# front of the drawn car = the radar "front of car" reference (RADAR_TO_CAMERA ahead of the camera
27+
# origin), so a dRel=0 track lands on the front bumper. The rear fills out a nominal car length.
28+
avg_car_length = 4.5
29+
car_front = RADAR_TO_CAMERA * lidar_zoom
30+
car_back = (avg_car_length - RADAR_TO_CAMERA) * lidar_zoom
2831
car_color = 110
2932

3033

@@ -166,7 +169,6 @@ def plot_model(m, img, calibration, top_down):
166169

167170
x, y = lead.x[0], lead.y[0]
168171
x_std = lead.xStd[0]
169-
x -= RADAR_TO_CAMERA
170172

171173
_, py_top = to_topdown_pt(x + x_std, y)
172174
px, py_bottom = to_topdown_pt(x - x_std, y)
@@ -190,24 +192,29 @@ def plot_lead(rs, top_down):
190192
if not lead.present:
191193
continue
192194

193-
x = lead.dRel
195+
x = lead.dRel + RADAR_TO_CAMERA
194196
px_left, py = to_topdown_pt(x, -10)
195197
px_right, _ = to_topdown_pt(x, 10)
196198
top_down[1][px_left:px_right, py] = find_color(top_down[0], RED)
197199

198200

201+
def _draw_radar_dot(lid_overlay, px, py):
202+
# odd-size squares so the dot is centered exactly on (px, py), not offset half a pixel up-left
203+
lid_overlay[px - 4 : px + 5, py - 4 : py + 5] = 0
204+
lid_overlay[px - 2 : px + 3, py - 2 : py + 3] = 255
205+
206+
199207
def maybe_update_radar_points(lt, lid_overlay):
200208
ar_pts = []
201209
if lt is not None:
202210
ar_pts = {}
203211
for track in lt:
204212
ar_pts[track.trackId] = [track.dRel, track.yRel, track.vRel, track.aRel]
205213
for pt in ar_pts.values():
206-
# negative here since radar is left positive
207-
px, py = to_topdown_pt(pt[0], -pt[1])
214+
# negative y since radar is left positive
215+
px, py = to_topdown_pt(pt[0] + RADAR_TO_CAMERA, -pt[1])
208216
if px != -1:
209-
lid_overlay[px - 4 : px + 4, py - 4 : py + 4] = 0
210-
lid_overlay[px - 2 : px + 2, py - 2 : py + 2] = 255
217+
_draw_radar_dot(lid_overlay, px, py)
211218

212219

213220
def get_blank_lid_overlay(UP):

0 commit comments

Comments
 (0)