mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 09:31:20 -04:00
ugh
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -11,7 +11,7 @@
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
||||
<meta name="apple-mobile-web-app-title" content="Multi Roomba Rover" />
|
||||
<title>Multi Roomba Rover</title>
|
||||
<script type="module" crossorigin src="/assets/index-DCabXYAC.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-COFUfdDa.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-lg9md4T4.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -5,6 +5,19 @@ const { sendAlert } = require('./alertService');
|
||||
const ALERT_COLOR = '#00bcd4';
|
||||
const { handleAck } = require('./commandService');
|
||||
|
||||
function coerceBool(value) {
|
||||
if (typeof value === 'boolean') return value;
|
||||
if (typeof value === 'number') return value !== 0;
|
||||
if (typeof value === 'string') {
|
||||
const normalized = value.trim().toLowerCase();
|
||||
if (normalized === 'true') return true;
|
||||
if (normalized === 'false') return false;
|
||||
if (normalized === '1') return true;
|
||||
if (normalized === '0') return false;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
const HEARTBEAT_INTERVAL_MS = 15000;
|
||||
|
||||
function handleMessage(roverId, msg) {
|
||||
@@ -16,13 +29,15 @@ function handleMessage(roverId, msg) {
|
||||
case 'sensor':
|
||||
roverManager.handleSensorFrame(roverId, msg);
|
||||
break;
|
||||
case 'event':
|
||||
if (msg.event === 'nightVision.state' && typeof msg.data?.nightVisionOn === 'boolean') {
|
||||
roverManager.setNightVisionState(roverId, msg.data.nightVisionOn);
|
||||
case 'event': {
|
||||
const nightVisionOn = coerceBool(msg.data?.nightVisionOn);
|
||||
if (msg.event === 'nightVision.state' && nightVisionOn != null) {
|
||||
roverManager.setNightVisionState(roverId, nightVisionOn);
|
||||
break;
|
||||
}
|
||||
sendAlert({ color: ALERT_COLOR, title: `${roverId} event`, message: msg.event });
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -73,8 +88,9 @@ roverWSS.on('connection', (ws) => {
|
||||
} else if (msg.type === 'ack') {
|
||||
handleAck(msg);
|
||||
} else if (msg.type === 'event') {
|
||||
if (msg.event === 'nightVision.state' && typeof msg.data?.nightVisionOn === 'boolean') {
|
||||
roverManager.setNightVisionState(roverId, msg.data.nightVisionOn);
|
||||
const nightVisionOn = coerceBool(msg.data?.nightVisionOn);
|
||||
if (msg.event === 'nightVision.state' && nightVisionOn != null) {
|
||||
roverManager.setNightVisionState(roverId, nightVisionOn);
|
||||
} else {
|
||||
sendAlert({ color: ALERT_COLOR, title: `${roverId}`, message: msg.event });
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import { formatKeyLabel } from '../controls/keymapUtils.js';
|
||||
import TopDownMap from './TopDownMap.jsx';
|
||||
import RoverRoster from './RoverRoster.jsx';
|
||||
import DriveDockAction, { useDriveDockState } from './DriveDockAction.jsx';
|
||||
import NightVisionControl from './NightVisionControl.jsx';
|
||||
|
||||
export function RoverRosterPanel({ title = 'Rovers' }) {
|
||||
const { session, requestControl } = useSession();
|
||||
@@ -76,11 +77,14 @@ export default function ControlSummary() {
|
||||
export function InlineCameraTilt({ keymap }) {
|
||||
const {
|
||||
state: { roverId, camera },
|
||||
actions: { setServoAngle },
|
||||
pipeline,
|
||||
actions: { setServoAngle, setNightVision },
|
||||
} = useControlSystem();
|
||||
|
||||
const config = camera?.config;
|
||||
const enabled = Boolean(roverId && camera?.enabled && config);
|
||||
const nightVisionAvailable = Boolean(roverId && pipeline?.nightVision);
|
||||
const nightVisionState = pipeline?.nightVisionState;
|
||||
const min = typeof config?.minAngle === 'number' ? config.minAngle : -30;
|
||||
const max = typeof config?.maxAngle === 'number' ? config.maxAngle : 30;
|
||||
const value =
|
||||
@@ -111,40 +115,54 @@ export function InlineCameraTilt({ keymap }) {
|
||||
draggingRef.current = false;
|
||||
};
|
||||
|
||||
if (!enabled) return null;
|
||||
if (!enabled && !nightVisionAvailable) return null;
|
||||
const upLabel = formatKeyLabel(keymap?.cameraUp?.[0]);
|
||||
const downLabel = formatKeyLabel(keymap?.cameraDown?.[0]);
|
||||
const nightVisionLabel = formatKeyLabel(keymap?.nightVisionToggle?.[0]);
|
||||
|
||||
return (
|
||||
<div className="surface space-y-0.5 px-1 py-1 text-sm text-slate-200">
|
||||
<div className="flex items-center justify-between text-xs text-slate-300">
|
||||
<span>Camera tilt</span>
|
||||
<span className="font-mono text-slate-100">{formatDegrees(value)}</span>
|
||||
</div>
|
||||
<div>
|
||||
<input
|
||||
type="range"
|
||||
className="w-full accent-emerald-400"
|
||||
min={min}
|
||||
max={max}
|
||||
step={0.5}
|
||||
value={pendingAngle}
|
||||
onChange={handleSlider}
|
||||
onMouseUp={commitSlider}
|
||||
onTouchEnd={commitSlider}
|
||||
onPointerUp={commitSlider}
|
||||
{enabled && (
|
||||
<>
|
||||
<div className="flex items-center justify-between text-xs text-slate-300">
|
||||
<span>Camera tilt</span>
|
||||
<span className="font-mono text-slate-100">{formatDegrees(value)}</span>
|
||||
</div>
|
||||
<div>
|
||||
<input
|
||||
type="range"
|
||||
className="w-full accent-emerald-400"
|
||||
min={min}
|
||||
max={max}
|
||||
step={0.5}
|
||||
value={pendingAngle}
|
||||
onChange={handleSlider}
|
||||
onMouseUp={commitSlider}
|
||||
onTouchEnd={commitSlider}
|
||||
onPointerUp={commitSlider}
|
||||
/>
|
||||
<div className="mt-0 flex items-center justify-between text-[0.7rem] text-slate-400">
|
||||
<span className="flex items-center gap-0.5">
|
||||
{downLabel ? <KeyPill label={downLabel} /> : null}
|
||||
{formatDegrees(min)}
|
||||
</span>
|
||||
<span className="flex items-center gap-0.5">
|
||||
{formatDegrees(max)}
|
||||
{upLabel ? <KeyPill label={upLabel} /> : null}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
{nightVisionAvailable && (
|
||||
<NightVisionControl
|
||||
nightVisionOn={nightVisionState?.nightVisionOn}
|
||||
disabled={!roverId}
|
||||
onToggle={setNightVision}
|
||||
keyLabel={nightVisionLabel}
|
||||
className={enabled ? 'mt-1' : ''}
|
||||
/>
|
||||
<div className="mt-0 flex items-center justify-between text-[0.7rem] text-slate-400">
|
||||
<span className="flex items-center gap-0.5">
|
||||
{downLabel ? <KeyPill label={downLabel} /> : null}
|
||||
{formatDegrees(min)}
|
||||
</span>
|
||||
<span className="flex items-center gap-0.5">
|
||||
{formatDegrees(max)}
|
||||
{upLabel ? <KeyPill label={upLabel} /> : null}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user