Compare commits
5 Commits
b7f2978e66
...
6ade2c2dc6
| Author | SHA1 | Date | |
|---|---|---|---|
| 6ade2c2dc6 | |||
| e7d5f2bdfc | |||
| 734c60d2be | |||
| 517d6a3e91 | |||
| 6de3ebda08 |
@@ -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:
|
||||
|
||||
@@ -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'.")
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user