From 541006041bf2e213a7c273ec3212438df010dd50 Mon Sep 17 00:00:00 2001 From: Atharv Nagavarapu <30nagava@elmbrookstudents.org> Date: Fri, 19 Dec 2025 22:40:48 +0000 Subject: [PATCH] Delete diagnostics/BatteryDiagnostics.py --- diagnostics/BatteryDiagnostics.py | 49 ------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 diagnostics/BatteryDiagnostics.py diff --git a/diagnostics/BatteryDiagnostics.py b/diagnostics/BatteryDiagnostics.py deleted file mode 100644 index 682793f..0000000 --- a/diagnostics/BatteryDiagnostics.py +++ /dev/null @@ -1,49 +0,0 @@ -from pybricks.tools import wait -import umath -class BatteryDiagnostics: - def __init__(self, hub): - self.voltage = 0 - self.current = 0 - self.hub = hub - def printVoltage(self): - self.voltage = self.hub.battery.voltage() - if self.voltage > 7800: - print(f"Battery voltage is sufficient: {self.voltage}") - elif self.voltage < 7800 : - print(f"Charging needed: {self.voltage}") - def printCurrent(self): - self.current = self.hub.battery.current() - print("Battery current:", self.current) - def printAll(self): - timeelapsed = 0 - voltageList = [] - currentList = [] - while True: - print("\n\n\n\n\n") - self.printVoltage() - voltageList.append(self.voltage) - self.printCurrent() - currentList.append(self.current) - wait(50) - timeelapsed += 50 - - if(timeelapsed >= 3000): - break - print("--------------FINAL RESULTS OF BATTERY DIAGNOSTICS---------------") - print("Voltage deviation:", self.stdev(voltageList)) - print("Current deviation:", self.stdev(currentList)) - def stdev(self, vals): - DATA = vals - if len(DATA) < 2: - return 0 - # Calculate the mean - MEAN = sum(DATA) / len(DATA) - - # Calculate the variance (sum of squared differences from the mean, divided by n-1 for sample standard deviation) - VARIANCE = sum([(x - MEAN) ** 2 for x in DATA]) / float(len(DATA) - 1) - - # Calculate the standard deviation (square root of the variance) - STD_DEV_MANUAL = umath.sqrt(VARIANCE) - - - return (STD_DEV_MANUAL) \ No newline at end of file