diff --git a/server/src/services/commandService.js b/server/src/services/commandService.js index 79c22335..fd974caa 100644 --- a/server/src/services/commandService.js +++ b/server/src/services/commandService.js @@ -64,7 +64,8 @@ io.on('connection', (socket) => { if (!roverId) { throw new Error('roverId required'); } - if (!roverManager.canDrive(roverId, socket)) { + const isSongCommand = type === 'song'; + if (!isSongCommand && !roverManager.canDrive(roverId, socket)) { throw new Error('Not your turn or no control'); } const payload = data ? { ...data } : {}; diff --git a/webui/src/components/VideoTile.jsx b/webui/src/components/VideoTile.jsx index f558f539..e90c4a2d 100644 --- a/webui/src/components/VideoTile.jsx +++ b/webui/src/components/VideoTile.jsx @@ -104,22 +104,12 @@ export default function VideoTile({ return Math.max(0, Math.min(1, 1 - Math.min(driveCap, auxCap))); }, [limiterCaps]); const limiterActive = Boolean(overcurrentLimiter?.isActive); - const limiterLabels = useMemo(() => { - if (!limiterCaps) return []; - const labels = []; - const driveCap = Number.isFinite(limiterCaps?.drive?.cap) ? limiterCaps.drive.cap : 1; - const auxCap = Number.isFinite(limiterCaps?.aux?.cap) ? limiterCaps.aux.cap : 1; - if (Boolean(limiterGroups?.drive) || driveCap < 0.999) labels.push('Drive wheels'); - if (Boolean(limiterGroups?.aux) || auxCap < 0.999) labels.push('Aux motors'); - return labels; - }, [limiterCaps, limiterGroups]); - const overlayActive = Boolean(overcurrentMotors.length || limiterActive); - const overlayLabelsRaw = overcurrentMotors.length - ? overcurrentMotors.map((name) => OVERCURRENT_LABELS[name] || name) - : limiterLabels.length - ? limiterLabels + const overlayMotors = overcurrentMotors.length + ? overcurrentMotors + : limiterActive + ? ['limiter'] : []; - const overlayLabels = overlayLabelsRaw.length ? overlayLabelsRaw : ['Overcurrent']; + const overlayFill = limiterFill ?? (overcurrentMotors.length ? 1 : 0); const scheduleRestart = useCallback(() => { clearTimeout(restartTimer.current); @@ -446,12 +436,7 @@ export default function VideoTile({ labelScale={hudLabelScale} /> - + {showVerticalBattery && batteryVisual.available ? ( @@ -749,11 +734,12 @@ const OVERCURRENT_LABELS = { rightWheel: 'Right wheel', mainBrush: 'Main brush', sideBrush: 'Side brush', + limiter: 'Overcurrent limit', }; -function OvercurrentOverlay({ labels, fill = 0, visible = false, compact = false }) { - if (!visible) return null; - const safeLabels = Array.isArray(labels) && labels.length ? labels : ['Overcurrent']; +function OvercurrentOverlay({ motors, fill = 0, compact = false }) { + if (!motors?.length) return null; + const safeLabels = motors.map((name) => OVERCURRENT_LABELS[name] || name); const containerClass = compact ? 'p-2' : 'p-4'; const textClass = compact ? 'text-lg' : 'text-4xl'; const subTextClass = compact ? 'text-xs' : 'text-xl';