mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-11-30 00:33:41 +08:00
test_power_draw: wait for each stage's power to settle (#39403)
This commit is contained in:
@@ -17,7 +17,8 @@ from openpilot.common.hardware.comma.power_monitor import get_power
|
||||
from openpilot.system.manager.process_config import managed_processes
|
||||
from openpilot.system.manager.manager import manager_cleanup
|
||||
|
||||
SAMPLE_TIME = 2 # seconds to sample power
|
||||
SAMPLE_TIME = 5 # seconds to sample power
|
||||
MAX_SPREAD = 0.1 # W, reject a sample window containing a ramp or spike
|
||||
MAX_WARMUP_TIME = 30 # seconds to wait for SAMPLE_TIME consecutive valid samples
|
||||
|
||||
@dataclass
|
||||
@@ -37,7 +38,7 @@ PROCS = [
|
||||
Proc(['camerad'], 1.65, atol=0.4, msgs=['narrowRoadCameraState', 'wideRoadCameraState', 'cabinCameraState']),
|
||||
Proc(['modeld'], 1.5, atol=0.2, msgs=['modelV2']),
|
||||
Proc(['dmonitoringmodeld'], 0.65, atol=0.35, msgs=['driverStateV2']),
|
||||
Proc(['encoderd'], 0.23, msgs=[]),
|
||||
Proc(['encoderd'], 0.23, msgs=['narrowRoadEncodeData', 'wideRoadEncodeData']),
|
||||
]
|
||||
|
||||
|
||||
@@ -68,7 +69,7 @@ class TestPowerDraw(OpenpilotTestCase):
|
||||
msg_counts[msg] += count
|
||||
return msg_counts
|
||||
|
||||
def get_power_with_warmup_for_target(self, proc, prev):
|
||||
def get_settled_power(self, proc):
|
||||
socks = {msg: messaging.sub_sock(msg) for msg in proc.msgs}
|
||||
for sock in socks.values():
|
||||
messaging.drain_sock_raw(sock)
|
||||
@@ -88,16 +89,15 @@ class TestPowerDraw(OpenpilotTestCase):
|
||||
continue
|
||||
|
||||
msg_counts = self.tabulate_msg_counts(msgs_and_power)
|
||||
now = np.mean([m[0] for m in msgs_and_power])
|
||||
powers = [sample for sample, _ in msgs_and_power]
|
||||
if self.valid_msg_count(proc, msg_counts) and np.ptp(powers) < MAX_SPREAD:
|
||||
return np.mean(powers), msg_counts, time.monotonic() - start_time - SAMPLE_TIME
|
||||
|
||||
if self.valid_msg_count(proc, msg_counts) and self.valid_power_draw(proc, now - prev):
|
||||
break
|
||||
|
||||
return now, msg_counts, time.monotonic() - start_time - SAMPLE_TIME
|
||||
raise AssertionError(f"Power or message rate did not settle for {proc.name or 'baseline'}")
|
||||
|
||||
@mock_messages(['deviceMotion'])
|
||||
def test_camera_procs(self, subtests):
|
||||
baseline = get_power()
|
||||
baseline, _, _ = self.get_settled_power(Proc([], 0., msgs=[]))
|
||||
|
||||
prev = baseline
|
||||
used = {}
|
||||
@@ -107,7 +107,7 @@ class TestPowerDraw(OpenpilotTestCase):
|
||||
for proc in PROCS:
|
||||
for p in proc.procs:
|
||||
managed_processes[p].start()
|
||||
now, local_msg_counts, warmup_time[proc.name] = self.get_power_with_warmup_for_target(proc, prev)
|
||||
now, local_msg_counts, warmup_time[proc.name] = self.get_settled_power(proc)
|
||||
msg_counts.update(local_msg_counts)
|
||||
|
||||
used[proc.name] = now - prev
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"protected_inventory_sha256": "ea4603dfd15d2c18449e86ded33e9e81af5ea0d5730cbadde6853124ba2353a7", "schema_version": 1}
|
||||
{"protected_inventory_sha256": "51d7585cb188b516b8eca609c2013b24ab1cef7f999a2909f941740ab6dc54ab", "schema_version": 1}
|
||||
|
||||
Reference in New Issue
Block a user