Merge pull request 'dev' (#14) from dev into main

Reviewed-on: #14
This commit is contained in:
2026-01-09 19:21:14 +00:00
3 changed files with 11 additions and 20 deletions

View File

@@ -4,7 +4,6 @@ from pybricks.tools import wait, StopWatch
class ColorSensorDiagnostics:
def __init__(self, hub, colorsensorclass):
self.colorsensor = None
self.colorsensorclass = colorsensorclass
self.PORT_MAP = {
"A": Port.A,
"B": Port.B,
@@ -13,6 +12,7 @@ class ColorSensorDiagnostics:
"E": Port.E,
"F": Port.F,
}
self.colorsensorclass = colorsensorclass
def initializeColorSensor(self):
VALID_PORTS = {"A", "B", "C", "D", "E", "F"}
while True:

View File

@@ -8,11 +8,9 @@ from BatteryDiagnostics import BatteryDiagnostics
from MotorDiagnostics import MotorDiagnostics
from ColorSensorDiagnostics import ColorSensorDiagnostics
from DriveBaseDiagnostics import DriveBaseDiagnostics
from HubDiagnostics import HubDiagnostics
battery = BatteryDiagnostics(HUB)
motor = MotorDiagnostics(HUB, Motor)
colorsensor = ColorSensorDiagnostics(HUB, ColorSensor)
hubdiags = HubDiagnostics(HUB)
drivebase = DriveBaseDiagnostics(HUB, Motor, DriveBase)
CLEARCONFIRM = input("Clear the console before proceeding? Y/N (default: yes): ")
if(CLEARCONFIRM == "Y" or CLEARCONFIRM == "y" or CLEARCONFIRM == "yes" or CLEARCONFIRM == ""):
@@ -27,9 +25,8 @@ print("""
█████ █████ █████ ▒▒█████ █████ █████ █████ █████ █████ ▒▒█████████ ▒▒█████████
▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒
The free and open source diagnostics tool for the LEGO® Education SPIKE™ Prime robots, designed for FIRST Lego League.
Developed by Team 65266, Lego Dynamics.
Please set your window size to 90% on small screens for best results with the ASCII art.
The free and open source diagnostics tool for LEGO® Education SPIKE™ Prime robots, designed for FIRST Lego League.
Developed by Team 65266, Lego Dynamics.
"""
)
while True:
@@ -38,8 +35,6 @@ while True:
print("Enter 'b' for battery diagnostics")
print("Enter 'm' for motor diagnostics")
print("Enter 'cs' for color sensor diagnostics")
print("Enter 'h' for hub diagnostics")
print("Enter 'db' for drive base diagnostics")
print("Enter 'q' to quit")
choice = input("Your choice: ").strip().lower()
@@ -55,20 +50,17 @@ while True:
print("------------------------MOTOR DIAGNOSTICS------------------------")
motor.fullTest()
print("Motor diagnostics completed.")
elif choice == "h":
print("-------------------------HUB DIAGNOSTICS-------------------------")
hubdiags.printAll()
print("Hub diagnostics completed.")
elif choice == "q":
print("Diagnostics completed successfully. Exiting with code 0. Good luck in the robot game!")
print("Diagnostics completed successfully. Exiting program.")
break
elif choice == "db":
print("----------------------DRIVEBASE DIAGNOSTICS----------------------")
drivebase.printAll()
elif choice == "cs":
print("---------------------COLOR SENSOR DIAGNOSTICS---------------------")
colorsensor.printAll()
print("Color sensor diagnostics completed.")
elif choice == "db":
print("----------------------DRIVE BASE DIAGNOSTICS----------------------")
drivebase.printAll()
print("Drivebase diagnostics completed.")
else:
print("Invalid choice. Please enter 'b', 'm', or 'q'.")

View File

@@ -4,7 +4,6 @@ import umath
class MotorDiagnostics:
def __init__(self, hub, motorclass):
self.testmotor = None
self.motorclass = motorclass
self.port_map = {
"A": Port.A,
"B": Port.B,
@@ -13,7 +12,7 @@ class MotorDiagnostics:
"E": Port.E,
"F": Port.F,
}
self.motorclass = motorclass
def stdev(self, vals):
DATA = vals
if len(DATA) < 2:
@@ -37,7 +36,7 @@ class MotorDiagnostics:
STABILITY = max(0, 100 - (stdev_speed / desired) * 100)
# Normalize load: map 10 to 20 as baseline (around 0%), 200 as max (around 100%)
BASELINE = 15 # midpoint of idle range
BASELINE = 10 # midpoint of idle range
MAX_OBSERVED = 200 # heavy load/stall
NORMALIZED_LOAD = max(0, avg_load - BASELINE)
LOAD_PCT = min(100, (NORMALIZED_LOAD / (MAX_OBSERVED - BASELINE)) * 100)