This commit is contained in:
legop3
2026-07-17 14:38:47 -04:00
parent c9842d7ba5
commit 955f6f213d
9 changed files with 17 additions and 7 deletions
@@ -421,6 +421,10 @@ function createOvercurrentProtectionService(options = {}) {
if (state.driveBlocked) return 'stopped';
const anyLimited = MOTOR_KEYS.some((key) => state.motors[key].cap < 1);
if (anyLimited && anyOvercurrent) return 'limiting';
// The raw Roomba flag is useful operator information even while stress is
// still inside the transient grace region. Reporting it separately keeps
// HUD visibility immediate without falsely claiming output is being scaled.
if (anyOvercurrent) return 'overcurrent';
if (anyLimited) return 'recovering';
return 'idle';
}
@@ -50,7 +50,9 @@ test('a short stalled-wheel spike remains inside the grace region', () => {
assert.equal(snapshot.motors.leftWheel.stress, 0.025);
assert.equal(snapshot.motors.leftWheel.cap, 1);
assert.equal(snapshot.status, 'idle');
// The hardware event is visible immediately even though the grace region
// correctly leaves the command cap at full output.
assert.equal(snapshot.status, 'overcurrent');
});
test('persistent stalled-wheel overcurrent scales both wheels and then stops drive', () => {