mirror of
https://github.com/TimeCrafters/CenterStage
synced 2025-12-15 16:52:35 +00:00
WIP: RevHubTestSuite: Initial implementation of Servo, Analog, Digital, and I2C port tests
This commit is contained in:
@@ -116,6 +116,15 @@ public class RevHubTestSuiteRobot extends Robot {
|
||||
|
||||
/* ------------------------------------------------ Motor Configuration ------------------------------------------------ */
|
||||
configureMotors();
|
||||
|
||||
/* ------------------------------------------------ Digital Sensor Configuration ------------------------------------------------ */
|
||||
configureDigitalSensors();
|
||||
}
|
||||
|
||||
protected void clearStaleData() {
|
||||
// for (LynxModule hub : lynxModules) {
|
||||
// hub.clearBulkCache();
|
||||
// }
|
||||
}
|
||||
|
||||
private void configureMotors() {
|
||||
@@ -130,9 +139,13 @@ public class RevHubTestSuiteRobot extends Robot {
|
||||
}
|
||||
}
|
||||
|
||||
protected void clearStaleData() {
|
||||
// for (LynxModule hub : lynxModules) {
|
||||
// hub.clearBulkCache();
|
||||
// }
|
||||
private void configureDigitalSensors() {
|
||||
for(DigitalChannel sensor : controlHubDigitalSensors) {
|
||||
sensor.setMode(DigitalChannel.Mode.INPUT);
|
||||
}
|
||||
|
||||
for(DigitalChannel sensor : expansionHubDigitalSensors) {
|
||||
sensor.setMode(DigitalChannel.Mode.INPUT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,19 @@
|
||||
package org.timecrafters.diagnostics.rev_hub_test_suite.states;
|
||||
|
||||
import com.qualcomm.robotcore.hardware.AnalogInput;
|
||||
import com.qualcomm.robotcore.hardware.Gamepad;
|
||||
|
||||
import org.timecrafters.diagnostics.rev_hub_test_suite.RevHubTestSuiteRobot;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class RevHubTestSuiteAnalogTestsState extends RevTestSuiteTestState {
|
||||
private final ArrayList<AnalogInput> sensors;
|
||||
private int sensor_index = 0;
|
||||
public RevHubTestSuiteAnalogTestsState(RevHubTestSuiteRobot robot) {
|
||||
super(robot);
|
||||
|
||||
sensors = robot.testingControlHub ? robot.controlHubAnalogSensors : robot.expansionHubAnalogSensors;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -14,5 +23,49 @@ public class RevHubTestSuiteAnalogTestsState extends RevTestSuiteTestState {
|
||||
if (testComplete)
|
||||
return;
|
||||
|
||||
if (sensor_index >= sensors.size()) {
|
||||
nextStage();
|
||||
report("-"); // Add newline
|
||||
}
|
||||
|
||||
if (stage.ordinal() > STAGE.ANALOG_SENSOR.ordinal()) {
|
||||
testComplete = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void telemetry() {
|
||||
engine.telemetry.addLine("ANALOG SENSOR PORT TESTING");
|
||||
engine.telemetry.addLine();
|
||||
|
||||
if (sensor_index < 4) {
|
||||
AnalogInput sensor = sensors.get(sensor_index);
|
||||
|
||||
engine.telemetry.addData("Analog Sensor", "Port: %d, V: %.2f/%.2f (%.2f%%)", sensor_index, sensor.getVoltage(), sensor.getMaxVoltage(), (sensor.getVoltage() / sensor.getMaxVoltage()) * 100.0);
|
||||
engine.telemetry.addLine();
|
||||
|
||||
engine.telemetry.addLine("MANUAL TEST");
|
||||
engine.telemetry.addLine("PRESS `A` if Analog Sensor " + sensor_index + " value is OKAY.");
|
||||
engine.telemetry.addLine();
|
||||
engine.telemetry.addLine("PRESS `Y` if Analog Sensor " + sensor_index + " value is NOT OKAY.");
|
||||
engine.telemetry.addLine();
|
||||
}
|
||||
|
||||
super.telemetry();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buttonUp(Gamepad gamepad, String button) {
|
||||
if (gamepad == engine.gamepad1) {
|
||||
if (button.equals("a")) {
|
||||
report("PASSED: Analog Sensor " + sensor_index + " OKAY");
|
||||
|
||||
sensor_index++;
|
||||
} else if (button.equals("y")) {
|
||||
report("FAILED: Analog Sensor " + sensor_index + " NOT OKAY");
|
||||
|
||||
sensor_index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,73 @@
|
||||
package org.timecrafters.diagnostics.rev_hub_test_suite.states;
|
||||
|
||||
import com.qualcomm.robotcore.hardware.AnalogInput;
|
||||
import com.qualcomm.robotcore.hardware.DigitalChannel;
|
||||
import com.qualcomm.robotcore.hardware.Gamepad;
|
||||
|
||||
import org.timecrafters.diagnostics.rev_hub_test_suite.RevHubTestSuiteRobot;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class RevHubTestSuiteDigitalTestsState extends RevTestSuiteTestState {
|
||||
private final ArrayList<DigitalChannel> sensors;
|
||||
private int sensor_index = 0;
|
||||
public RevHubTestSuiteDigitalTestsState(RevHubTestSuiteRobot robot) {
|
||||
super(robot);
|
||||
|
||||
sensors = robot.testingControlHub ? robot.controlHubDigitalSensors : robot.expansionHubDigitalSensors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exec() {
|
||||
super.exec();
|
||||
|
||||
if (testComplete)
|
||||
return;
|
||||
|
||||
if (sensor_index >= sensors.size()) {
|
||||
nextStage();
|
||||
report("-"); // Add newline
|
||||
}
|
||||
|
||||
if (stage.ordinal() > STAGE.DIGITAL_SENSOR.ordinal()) {
|
||||
testComplete = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void telemetry() {
|
||||
engine.telemetry.addLine("DIGITAL SENSOR PORT TESTING");
|
||||
engine.telemetry.addLine();
|
||||
|
||||
if (sensor_index < 4) {
|
||||
DigitalChannel sensor = sensors.get(sensor_index);
|
||||
|
||||
engine.telemetry.addData("Digital Sensor", "Port: %d, State: %s", sensor_index, (sensor.getState() ? "ON" : "OFF"));
|
||||
engine.telemetry.addLine();
|
||||
|
||||
engine.telemetry.addLine("MANUAL TEST");
|
||||
engine.telemetry.addLine("PRESS `A` if Digital Sensor " + sensor_index + " value is OKAY.");
|
||||
engine.telemetry.addLine();
|
||||
engine.telemetry.addLine("PRESS `Y` if Digital Sensor " + sensor_index + " value is NOT OKAY.");
|
||||
engine.telemetry.addLine();
|
||||
}
|
||||
|
||||
|
||||
super.telemetry();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buttonUp(Gamepad gamepad, String button) {
|
||||
if (gamepad == engine.gamepad1) {
|
||||
if (button.equals("a")) {
|
||||
report("PASSED: Digital Sensor " + sensor_index + " OKAY");
|
||||
|
||||
sensor_index++;
|
||||
} else if (button.equals("y")) {
|
||||
report("FAILED: Digital Sensor " + sensor_index + " NOT OKAY");
|
||||
|
||||
sensor_index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,76 @@
|
||||
package org.timecrafters.diagnostics.rev_hub_test_suite.states;
|
||||
|
||||
import com.qualcomm.hardware.rev.Rev2mDistanceSensor;
|
||||
import com.qualcomm.robotcore.hardware.DigitalChannel;
|
||||
import com.qualcomm.robotcore.hardware.Gamepad;
|
||||
|
||||
import org.firstinspires.ftc.robotcore.external.navigation.DistanceUnit;
|
||||
import org.timecrafters.diagnostics.rev_hub_test_suite.RevHubTestSuiteRobot;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import dev.cyberarm.engine.V2.CyberarmState;
|
||||
|
||||
public class RevHubTestSuiteI2CTestsState extends RevTestSuiteTestState {
|
||||
private final ArrayList<Rev2mDistanceSensor> sensors;
|
||||
private int sensor_index = 0;
|
||||
public RevHubTestSuiteI2CTestsState(RevHubTestSuiteRobot robot) {
|
||||
super(robot);
|
||||
|
||||
sensors = robot.testingControlHub ? robot.controlHubI2cSensors : robot.expansionHubI2cSensors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exec() {
|
||||
super.exec();
|
||||
|
||||
if (testComplete)
|
||||
return;
|
||||
|
||||
if (sensor_index >= sensors.size()) {
|
||||
nextStage();
|
||||
report("-"); // Add newline
|
||||
}
|
||||
|
||||
if (stage.ordinal() > STAGE.I2C_SENSOR.ordinal()) {
|
||||
testComplete = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void telemetry() {
|
||||
engine.telemetry.addLine("I2C SENSOR PORT TESTING");
|
||||
engine.telemetry.addLine();
|
||||
|
||||
if (sensor_index < 4) {
|
||||
Rev2mDistanceSensor sensor = sensors.get(sensor_index);
|
||||
|
||||
engine.telemetry.addData("I2C Sensor", "Port: %d, Dist: %.2fMM", sensor_index, sensor.getDistance(DistanceUnit.MM));
|
||||
engine.telemetry.addLine();
|
||||
|
||||
engine.telemetry.addLine("MANUAL TEST");
|
||||
engine.telemetry.addLine("PRESS `A` if I2C Sensor " + sensor_index + " value is OKAY.");
|
||||
engine.telemetry.addLine();
|
||||
engine.telemetry.addLine("PRESS `Y` if I2C Sensor " + sensor_index + " value is NOT OKAY.");
|
||||
engine.telemetry.addLine();
|
||||
}
|
||||
|
||||
|
||||
super.telemetry();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buttonUp(Gamepad gamepad, String button) {
|
||||
if (gamepad == engine.gamepad1) {
|
||||
if (button.equals("a")) {
|
||||
report("PASSED: Digital Sensor " + sensor_index + " OKAY");
|
||||
|
||||
sensor_index++;
|
||||
} else if (button.equals("y")) {
|
||||
report("FAILED: Digital Sensor " + sensor_index + " NOT OKAY");
|
||||
|
||||
sensor_index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,6 +275,7 @@ public class RevHubTestSuiteMotorTestsState extends RevTestSuiteTestState {
|
||||
public void telemetry() {
|
||||
engine.telemetry.addLine("MOTOR CONTROLLER TESTING");
|
||||
engine.telemetry.addLine();
|
||||
|
||||
if (motor_index < 4) {
|
||||
MotorEx motor = motors.get(motor_index);
|
||||
|
||||
|
||||
@@ -77,6 +77,9 @@ public class RevHubTestSuiteServoTestsState extends RevTestSuiteTestState {
|
||||
}
|
||||
|
||||
public void telemetry() {
|
||||
engine.telemetry.addLine("SERVO CONTROLLER TESTING");
|
||||
engine.telemetry.addLine();
|
||||
|
||||
if (stage == STAGE.SERVO_SWEEP) {
|
||||
engine.telemetry.addLine("MANUAL TEST");
|
||||
engine.telemetry.addLine("PRESS `A` if Servo " + servo_index + " is ROTATING.");
|
||||
|
||||
Reference in New Issue
Block a user