Add a thermal guard that slows the robot before the Pi throttles
hermes_thermal reads the CPU temperature and throttle flags, publishes /health/*, and at 72 / 77 / 82 C scales the camera, face and detector rates down through their live parameters, restoring them as it cools one level at a time with a margin and a dwell so it does not flap. The face and detector gained live parameter callbacks for this, the bridge's robot://status carries a health block (temperature, level, throttle flags now and since boot), and a bringup test asserts the guard's normal rates equal the real ones. Live testing on the robot (forcing 73 / 78 / 85 C and back) caught a bug the unit tests missed: one logging line whose severity changed between warn and info raised in rclpy and killed the guard on its first cooling step, and the respawn hid it. Fixed with separate call sites; the tick now survives any error; a full heat-then-cool test drives the real node, and a mutation check confirmed it fails on the original bug. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AFN8nRRCiDiMN7ChBpHJhs
This commit is contained in:
@@ -10,7 +10,7 @@ pytest.importorskip('mcp')
|
||||
from starlette.testclient import TestClient # noqa: E402
|
||||
|
||||
from hermes_mcp.bridge import (Activity, BearerAuth, FacesBuffer, LatestFrame, build_app, build_mcp, # noqa: E402
|
||||
people_summary)
|
||||
HealthBuffer, people_summary)
|
||||
|
||||
TOKEN = 'x' * 32
|
||||
|
||||
@@ -172,3 +172,13 @@ def test_the_server_can_be_discovered_resources_and_prompts_are_not_empty():
|
||||
assert status['detects'] == ['faces'] and 'people' in status['not_detected']
|
||||
assert 'embeddings never leave it' in status['recognition']['registry']
|
||||
assert 'turn_head' not in status['tools']
|
||||
|
||||
|
||||
def test_status_reports_health_when_known_and_says_when_it_is_not():
|
||||
h = HealthBuffer()
|
||||
mcp = build_mcp(LatestFrame(), health=h)
|
||||
unknown = json.loads(asyncio.run(mcp.read_resource('robot://status'))[0].content)
|
||||
assert unknown['health'] == {'available': False}
|
||||
h.update(temperature_c=63.4, thermal_level='ok', throttled={'available': True})
|
||||
known = json.loads(asyncio.run(mcp.read_resource('robot://status'))[0].content)
|
||||
assert known['health']['temperature_c'] == 63.4 and known['health']['thermal_level'] == 'ok'
|
||||
|
||||
Reference in New Issue
Block a user