laser locking and idle

This commit is contained in:
legop3
2026-06-27 18:06:24 -04:00
parent 0cfc16528b
commit 4ee4f7d06e
9 changed files with 256 additions and 152 deletions
@@ -9,6 +9,7 @@ const neatoService = require('../neatoService');
const liftService = require('../liftService');
const {
HEADLIGHT_DISABLE_ACTION,
LASER_DISABLE_ACTION,
DOCK_COMMAND_BASE64,
} = require('./constants');
@@ -79,6 +80,29 @@ async function disableAllRoverHeadlights() {
return { action: 'disableRoverHeadlights', attempted, failed };
}
async function disableAllRoverLasers() {
const attempted = [];
const failed = [];
roverManager.rovers.forEach((record) => {
if (!record?.ws || !record?.meta?.laser?.enabled) return;
const roverId = String(record.id);
try {
// Idle cleanup is allowed to send an explicit off command even when
// other laser commands are policy-blocked. The point of this action is
// to leave the rover in a non-emitting state when nobody is actively
// driving it.
issueCommand(roverId, {
type: 'laser',
laser: { action: LASER_DISABLE_ACTION },
});
attempted.push(roverId);
} catch (err) {
failed.push({ roverId, error: err.message });
}
});
return { action: 'disableRoverLasers', attempted, failed };
}
async function sendNeatoHome() {
try {
await neatoService.sendHome();
@@ -101,6 +125,7 @@ const idleActions = [
turnOffRoomControls,
// dockAllRovers,
disableAllRoverHeadlights,
disableAllRoverLasers,
sendNeatoHome,
raiseLift,
];
@@ -3,10 +3,12 @@
// Scope: Centralizes immutable configuration for trigger windows and rover command payloads.
const IDLE_TIMEOUT_MS = 2 * 60 * 1000;
const HEADLIGHT_DISABLE_ACTION = 'off';
const LASER_DISABLE_ACTION = 'off';
const DOCK_COMMAND_BASE64 = Buffer.from([143]).toString('base64');
module.exports = {
IDLE_TIMEOUT_MS,
HEADLIGHT_DISABLE_ACTION,
LASER_DISABLE_ACTION,
DOCK_COMMAND_BASE64,
};