Browse Source

Ego Car vehicle fix.

refactor/modularize
RUSHIL AMBARISH KADU 8 months ago
parent
commit
4a49b775a1
  1. 28
      steps/src/drawUtils.js
  2. 3
      steps/src/p5/radarSketch.js

28
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();
}

3
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) {

Loading…
Cancel
Save