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,
];