mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 09:31:20 -04:00
guhb
This commit is contained in:
@@ -8,6 +8,7 @@ const roverManager = require('./roverManager');
|
||||
const { issueCommand } = require('./commandService');
|
||||
const { publishEvent } = require('./eventBus');
|
||||
const { sendAlert } = require('./alertService');
|
||||
const { getMode, MODES } = require('./modeManager');
|
||||
|
||||
const config = loadConfig();
|
||||
const visionConfig = config.vision?.humanDetection || {};
|
||||
@@ -55,6 +56,11 @@ let latestPositiveFrame = null; // { cameraId, confidence, ts, buffer }
|
||||
let cooldownUntil = 0;
|
||||
let hasClearedSinceLastDiscord = true;
|
||||
|
||||
function isDetectionActiveMode() {
|
||||
const mode = getMode();
|
||||
return mode !== MODES.ADMIN && mode !== MODES.LOCKDOWN;
|
||||
}
|
||||
|
||||
function ensureCameraState(cameraId) {
|
||||
if (!cameraState.has(cameraId)) {
|
||||
cameraState.set(cameraId, {
|
||||
@@ -135,6 +141,10 @@ function sendDiscordDetectionAlert(now) {
|
||||
}
|
||||
|
||||
function evaluateEpisode(now = Date.now()) {
|
||||
if (!isDetectionActiveMode()) {
|
||||
markCleared(now);
|
||||
return;
|
||||
}
|
||||
if (episodeStartAt != null && lastAnyPositiveAt != null && now - lastAnyPositiveAt > CLEAR_WINDOW_MS) {
|
||||
markCleared(now);
|
||||
return;
|
||||
@@ -271,6 +281,7 @@ if (!startWorker()) {
|
||||
}
|
||||
|
||||
roomCameraStreamEvents.on('frame', ({ id, buffer, ts }) => {
|
||||
if (!isDetectionActiveMode()) return;
|
||||
if (!id || !buffer) return;
|
||||
submitFrame(String(id), buffer, ts);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user