From bcf4099d9022db7ad9846f8b33a44d235aa3edef Mon Sep 17 00:00:00 2001 From: Mitchell Goff Date: Mon, 5 Jun 2023 20:27:02 -0700 Subject: [PATCH] Test power usage for mapsd and navmodeld (#28378) * Test power usage for mapsd and navmodeld * Send LLK message from thread * Use threading.Event old-commit-hash: dd6f7116f70159c4f61e72f028abbdaeecc5eec9 --- system/hardware/tici/tests/test_power_draw.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/system/hardware/tici/tests/test_power_draw.py b/system/hardware/tici/tests/test_power_draw.py index df4852183e..4683bba1f9 100755 --- a/system/hardware/tici/tests/test_power_draw.py +++ b/system/hardware/tici/tests/test_power_draw.py @@ -2,9 +2,11 @@ import unittest import time import math +import threading from dataclasses import dataclass from tabulate import tabulate +import cereal.messaging as messaging from system.hardware import HARDWARE, TICI from system.hardware.tici.power_monitor import get_power from selfdrive.manager.process_config import managed_processes @@ -24,8 +26,22 @@ PROCS = [ Proc('modeld', 0.93, atol=0.2), Proc('dmonitoringmodeld', 0.4), Proc('encoderd', 0.23), + Proc('mapsd', 0.1), + Proc('navmodeld', 0.05), ] +def send_llk_msg(done): + pm = messaging.PubMaster(['liveLocationKalman']) + msg = messaging.new_message('liveLocationKalman') + msg.liveLocationKalman.positionGeodetic = {'value': [32.7174, -117.16277, 0], 'std': [0., 0., 0.], 'valid': True} + msg.liveLocationKalman.calibratedOrientationNED = {'value': [0., 0., 0.], 'std': [0., 0., 0.], 'valid': True} + msg.liveLocationKalman.status = 'valid' + + # Send liveLocationKalman at 20hz + while not done.is_set(): + pm.send('liveLocationKalman', msg) + time.sleep(1/20) + class TestPowerDraw(unittest.TestCase): @@ -46,6 +62,9 @@ class TestPowerDraw(unittest.TestCase): def test_camera_procs(self): baseline = get_power() + done = threading.Event() + thread = threading.Thread(target=send_llk_msg, args=(done,), daemon=True) + thread.start() prev = baseline used = {} @@ -57,6 +76,7 @@ class TestPowerDraw(unittest.TestCase): used[proc.name] = now - prev prev = now + done.set() manager_cleanup() tab = []