// New Generation Bumper Indicators
// Purpose: Projects the rover's two physical bumper halves across the bottom of the video.
// Scope: Visualizes server telemetry only; it does not infer collisions or change control behavior.
import { useId } from 'react';
import {
shallowObjectEqual,
useVisualTelemetrySelector,
} from '../../../../context/TelemetryContext.jsx';
import { LEFT_BUMPER_PATH, RIGHT_BUMPER_PATH } from '../BottomSensorHud/geometry.js';
import './styles.css';
const EMPTY_BUMPERS = Object.freeze({ bumpLeft: false, bumpRight: false });
function selectBumpers(frame) {
const contact = frame?.sensors?.bumpsAndWheelDrops;
if (!contact) return EMPTY_BUMPERS;
return {
bumpLeft: Boolean(contact.bumpLeft),
bumpRight: Boolean(contact.bumpRight),
};
}
function ActiveBumperArc({ pathId, path, label }) {
return (
{/*
The broad rounded stroke uses the same visual idea as TopDownMap's
ArcSegment, while this wider quadratic path is shaped for the camera
viewport instead of the circular top-down rover geometry.
*/}
{label}
);
}
export default function BumperIndicators({ roverId }) {
const telemetry = useVisualTelemetrySelector(roverId, selectBumpers, shallowObjectEqual);
const instanceId = useId().replaceAll(':', '');
if (!telemetry.bumpLeft && !telemetry.bumpRight) return null;
return (
{telemetry.bumpLeft ? (
) : null}
{telemetry.bumpRight ? (
) : null}
);
}