camera controls better takeover

This commit is contained in:
legop3
2026-05-17 21:26:09 -04:00
parent 287d6291dd
commit 31f98a8e32
5 changed files with 24 additions and 15 deletions
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -11,7 +11,7 @@
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="apple-mobile-web-app-title" content="Roomba Rover" /> <meta name="apple-mobile-web-app-title" content="Roomba Rover" />
<title>Roomba Rover</title> <title>Roomba Rover</title>
<script type="module" crossorigin src="/assets/index-BBvqjYI_.js"></script> <script type="module" crossorigin src="/assets/index-X92JgDHr.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-CkqCBh_q.css"> <link rel="stylesheet" crossorigin href="/assets/index-CkqCBh_q.css">
</head> </head>
<body> <body>
@@ -95,7 +95,7 @@ function MobileJoystickPanel({ layout }) {
function MobileActionsColumnContent({ layout }) { function MobileActionsColumnContent({ layout }) {
const { const {
state: { roverId, camera, horn }, state: { roverId, camera, horn, manualDockAssist },
pipeline, pipeline,
actions: { setServoAngle, setNightVision, setAuxMotors, startHorn, stopHorn }, actions: { setServoAngle, setNightVision, setAuxMotors, startHorn, stopHorn },
} = useControlSystem(); } = useControlSystem();
@@ -115,6 +115,7 @@ function MobileActionsColumnContent({ layout }) {
: typeof cameraConfig?.homeAngle === 'number' : typeof cameraConfig?.homeAngle === 'number'
? cameraConfig.homeAngle ? cameraConfig.homeAngle
: (cameraMin + cameraMax) / 2; : (cameraMin + cameraMax) / 2;
const cameraDisabled = Boolean(disabled || manualDockAssist?.active);
const handleNightVisionToggle = useCallback( const handleNightVisionToggle = useCallback(
(nextOn) => { (nextOn) => {
@@ -174,6 +175,7 @@ function MobileActionsColumnContent({ layout }) {
min={cameraMin} min={cameraMin}
max={cameraMax} max={cameraMax}
step={0.5} step={0.5}
disabled={cameraDisabled}
onChange={setServoAngle} onChange={setServoAngle}
orientation="vertical" orientation="vertical"
label="Camera Tilt" label="Camera Tilt"
+3 -1
View File
@@ -43,7 +43,7 @@ function TopDownMapPanel() {
function DriveDockPanel() { function DriveDockPanel() {
const { const {
state: { roverId, keymap, camera, horn }, state: { roverId, keymap, camera, horn, manualDockAssist },
pipeline, pipeline,
actions: { setServoAngle, setNightVision, startHorn, stopHorn }, actions: { setServoAngle, setNightVision, startHorn, stopHorn },
} = useControlSystem(); } = useControlSystem();
@@ -68,6 +68,7 @@ function DriveDockPanel() {
const hornLabel = formatKeyLabel(keymap?.hornHonk?.[0]); const hornLabel = formatKeyLabel(keymap?.hornHonk?.[0]);
const upLabel = formatKeyLabel(keymap?.cameraUp?.[0]); const upLabel = formatKeyLabel(keymap?.cameraUp?.[0]);
const downLabel = formatKeyLabel(keymap?.cameraDown?.[0]); const downLabel = formatKeyLabel(keymap?.cameraDown?.[0]);
const cameraDisabled = Boolean(!roverId || manualDockAssist?.active);
return ( return (
<section className="panel-section grid h-full min-h-0 grid-rows-[minmax(0,1fr)_auto] gap-0.5"> <section className="panel-section grid h-full min-h-0 grid-rows-[minmax(0,1fr)_auto] gap-0.5">
@@ -97,6 +98,7 @@ function DriveDockPanel() {
value={value} value={value}
min={min} min={min}
max={max} max={max}
disabled={cameraDisabled}
onChange={setServoAngle} onChange={setServoAngle}
keyDownLabel={downLabel} keyDownLabel={downLabel}
keyUpLabel={upLabel} keyUpLabel={upLabel}
+9 -4
View File
@@ -279,15 +279,17 @@ export function ControlSystemProvider({ children }) {
}, [saveControlSettings]); }, [saveControlSettings]);
const setServoAngle = useCallback( const setServoAngle = useCallback(
(value) => { (value, options = {}) => {
if (!pipeline.servoConfig) return; if (!pipeline.servoConfig) return;
const force = Boolean(options?.force);
if (state.manualDockAssist?.active && !force) return;
const clamped = clampServoAngle(pipeline.servoConfig, value); const clamped = clampServoAngle(pipeline.servoConfig, value);
dispatch({ type: 'control/set-camera-angle', payload: clamped }); dispatch({ type: 'control/set-camera-angle', payload: clamped });
pipeline.sendServoAngle(clamped); pipeline.sendServoAngle(clamped);
servoAngleRef.current = clamped; servoAngleRef.current = clamped;
recordControlIntent(); recordControlIntent();
}, },
[pipeline, recordControlIntent], [pipeline, recordControlIntent, state.manualDockAssist?.active],
); );
const nudgeServo = useCallback( const nudgeServo = useCallback(
@@ -530,12 +532,15 @@ export function ControlSystemProvider({ children }) {
const prevActive = Boolean(state.manualDockAssist?.active); const prevActive = Boolean(state.manualDockAssist?.active);
if (prevActive === nextActive) return; if (prevActive === nextActive) return;
dispatch({ type: 'control/set-manual-dock-assist', payload: nextActive }); dispatch({ type: 'control/set-manual-dock-assist', payload: nextActive });
if (!nextActive) return; if (!nextActive) {
setServoAngle(0, { force: true });
return;
}
const minAngle = const minAngle =
typeof pipeline.servoConfig?.minAngle === 'number' typeof pipeline.servoConfig?.minAngle === 'number'
? pipeline.servoConfig.minAngle ? pipeline.servoConfig.minAngle
: -45; : -45;
setServoAngle(minAngle); setServoAngle(minAngle, { force: true });
pipeline.sendSong([{ note: 76, duration: 10 }, { note: 83, duration: 10 }], { slot: 0 }); pipeline.sendSong([{ note: 76, duration: 10 }, { note: 83, duration: 10 }], { slot: 0 });
recordControlIntent(); recordControlIntent();
}, },