This commit is contained in:
legop3
2025-12-02 14:43:56 -05:00
parent 9bc5d2d06d
commit ace39d5a70
21 changed files with 238 additions and 18 deletions
+1
View File
@@ -19,6 +19,7 @@ const KEY_ACTIONS = [
{ id: 'auxAllForward', label: 'All Aux Forward', group: 'Aux Motors' },
{ id: 'cameraUp', label: 'Camera Up', group: 'Camera' },
{ id: 'cameraDown', label: 'Camera Down', group: 'Camera' },
{ id: 'nightVisionToggle', label: 'Toggle Night Vision', group: 'Camera' },
{ id: 'driveMacro', label: 'Drive Macro', group: 'Macros' },
{ id: 'dockMacro', label: 'Dock Macro', group: 'Macros' },
{ id: 'chatFocus', label: 'Toggle Chat', group: 'Chat' },
+13 -1
View File
@@ -133,11 +133,13 @@ function FloatingJoystick({ disabled, layout, radius, onMove, onStop }) {
function MobileJoystickPanel({ layout }) {
const {
state: { roverId, camera },
actions: { setDriveVector, registerInputState, stopAllMotion, setServoAngle },
pipeline,
actions: { setDriveVector, registerInputState, stopAllMotion, setServoAngle, toggleNightVision },
} = useControlSystem();
const disabled = !roverId;
const cameraConfig = camera?.config;
const cameraEnabled = Boolean(roverId && camera?.enabled && cameraConfig);
const nightVisionAvailable = Boolean(roverId && pipeline?.nightVision);
const cameraMin = typeof cameraConfig?.minAngle === 'number' ? cameraConfig.minAngle : -45;
const cameraMax = typeof cameraConfig?.maxAngle === 'number' ? cameraConfig.maxAngle : 45;
const cameraValue =
@@ -198,6 +200,16 @@ function MobileJoystickPanel({ layout }) {
<div className="flex flex-col gap-0.5 text-slate-100">
<DriveModeToggle size="compact" />
{nightVisionAvailable && (
<button
type="button"
onClick={() => toggleNightVision()}
disabled={disabled}
className="bg-amber-600 px-0.5 py-1 text-sm font-semibold text-amber-50 transition hover:bg-amber-500 disabled:opacity-40"
>
Toggle Night Vision
</button>
)}
{cameraEnabled && (
<div className="bg-zinc-950 p-0.5 text-xs">
<div className="flex items-center justify-between text-[0.75rem] text-slate-400">
+6
View File
@@ -254,6 +254,10 @@ export function ControlSystemProvider({ children }) {
[pipeline],
);
const toggleNightVision = useCallback(() => {
pipeline.sendNightVision('toggle');
}, [pipeline]);
const registerInputState = useCallback((source, data) => {
dispatch({ type: 'control/register-input-state', payload: { source, state: data } });
}, []);
@@ -274,6 +278,7 @@ export function ControlSystemProvider({ children }) {
stopAllMotion,
sendOiCommand,
setSensorStream,
toggleNightVision,
updateKeyBinding,
resetKeyBindings,
registerInputState,
@@ -292,6 +297,7 @@ export function ControlSystemProvider({ children }) {
stopAllMotion,
sendOiCommand,
setSensorStream,
toggleNightVision,
updateKeyBinding,
resetKeyBindings,
registerInputState,
+21
View File
@@ -19,6 +19,11 @@ export function useCommandPipeline() {
return rosterEntry.cameraServo;
}, [rosterEntry]);
const nightVision = useMemo(() => {
if (!rosterEntry?.nightVision || !rosterEntry.nightVision.enabled) return null;
return rosterEntry.nightVision;
}, [rosterEntry]);
const emitCommand = useCallback(
(payload, cb) => {
if (!roverId) return;
@@ -134,29 +139,45 @@ export function useCommandPipeline() {
[roverId, sendOiCommand, sendDriveDirect, sendAuxMotors, sendServoAngle],
);
const sendNightVision = useCallback(
(action = 'toggle') => {
if (!roverId || !nightVision) return null;
emitCommand({
type: 'nightVision',
data: { nightVision: { action } },
});
return action;
},
[emitCommand, nightVision, roverId],
);
return useMemo(
() => ({
roverId,
rosterEntry,
servoConfig,
nightVision,
emitCommand,
enableSensorStream,
sendDriveDirect,
sendAuxMotors,
sendServoAngle,
sendOiCommand,
sendNightVision,
runMacroSteps,
}),
[
roverId,
rosterEntry,
servoConfig,
nightVision,
emitCommand,
enableSensorStream,
sendDriveDirect,
sendAuxMotors,
sendServoAngle,
sendOiCommand,
sendNightVision,
runMacroSteps,
],
);
+1
View File
@@ -36,6 +36,7 @@ export const DEFAULT_KEYMAP = {
auxAllForward: [","],
cameraUp: ['u'],
cameraDown: ['j'],
nightVisionToggle: ['e'],
driveMacro: ['f'],
dockMacro: ['g'],
chatFocus: ['enter'],
@@ -86,6 +86,7 @@ export default function KeyboardInputManager() {
runMacro,
stopAllMotion,
registerInputState,
toggleNightVision,
},
} = useControlSystem();
const { focusChat, blurChat, isChatFocused } = useChat();
@@ -208,6 +209,8 @@ export default function KeyboardInputManager() {
} else if (newlyPressed.some((token) => keymap.dockMacro?.has(token))) {
setMode('dock');
runMacro('seek-dock');
} else if (newlyPressed.some((token) => keymap.nightVisionToggle?.has(token))) {
toggleNightVision();
}
}