From 4a49b775a1b0dcc341b47e591ab8cdee63aa81f3 Mon Sep 17 00:00:00 2001 From: rakadu1 Date: Tue, 9 Sep 2025 11:47:56 +0530 Subject: [PATCH] Ego Car vehicle fix. --- steps/src/drawUtils.js | 28 ++++++++++++---------------- steps/src/p5/radarSketch.js | 3 ++- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/steps/src/drawUtils.js b/steps/src/drawUtils.js index 2919e56..17e3bc4 100644 --- a/steps/src/drawUtils.js +++ b/steps/src/drawUtils.js @@ -656,25 +656,21 @@ export function drawCovarianceEllipse( * Draws a simple representation of the ego vehicle at the origin (0,0). * @param {p5.Graphics} b - The p5.Graphics buffer to draw on. */ -function drawEgoVehicle(p, b) { - // Determine car color based on the current theme for better visibility. +export function drawEgoVehicle(p, plotScales) { const isDark = document.documentElement.classList.contains("dark"); - const carColor = isDark ? p.color(200, 200, 220) : p.color(100, 100, 110); + const carColor = isDark ? p.color(150, 150, 220) : p.color(150, 150, 220); - b.push(); // Start a new drawing state - - // Set drawing properties for the car body - b.fill(carColor); - b.noStroke(); - b.rectMode(p.CENTER); // Draw rectangles from their center point + p.push(); + p.fill(carColor); + p.noStroke(); + p.rectMode(p.CENTER); - // The car's dimensions in meters (width x length) - const carWidthMeters = 2; - const carLengthMeters = 4.5; + const carWidthMeters = 1.5; + const carLengthMeters = 3.5; - // These dimensions are in "radar space", not pixels. - // The buffer's existing scaling will handle the conversion automatically. - b.rect(0, 0, carWidthMeters, carLengthMeters, 0.5); // Main body with rounded corners + const carWidthPixels = carWidthMeters * plotScales.plotScaleX; + const carLengthPixels = carLengthMeters * plotScales.plotScaleY; - b.pop(); // Restore original drawing state + p.rect(0, -10, carWidthPixels, carLengthPixels, 5); + p.pop(); } \ No newline at end of file diff --git a/steps/src/p5/radarSketch.js b/steps/src/p5/radarSketch.js index 22a62bd..c84d6c4 100644 --- a/steps/src/p5/radarSketch.js +++ b/steps/src/p5/radarSketch.js @@ -19,6 +19,7 @@ import { drawPointCloud, // Import drawing utility functions drawTrajectories, + drawEgoVehicle, drawTrackMarkers, snrColors, handleCloseUpDisplay, @@ -88,7 +89,7 @@ export const radarSketch = function (p) { calculatePlotScales(); // Draw coordinate axes drawAxes(p, plotScales); - + drawEgoVehicle(p, plotScales) // Get current frame data const frameData = appState.vizData.radarFrames[appState.currentFrame]; if (frameData) {