WIP: RevHubTestSuite: Fixed Expansion Hub items not properly getting selected in the test states.

This commit is contained in:
2023-10-03 20:50:40 -05:00
parent d4b2496a02
commit 8c7017bf13
8 changed files with 65 additions and 39 deletions

View File

@@ -25,13 +25,14 @@ public class RevHubTestSuiteEngine extends CyberarmEngine {
addState(new RevHubTestSuiteHubSelectionState(robot));
addState(new RevHubTestSuiteMotorTestsState(robot));
addState(new RevHubTestSuiteServoTestsState(robot));
addState(new RevHubTestSuiteAnalogTestsState(robot));
addState(new RevHubTestSuiteDigitalTestsState(robot));
// addState(new RevHubTestSuiteMotorTestsState(robot));
// addState(new RevHubTestSuiteServoTestsState(robot));
// addState(new RevHubTestSuiteAnalogTestsState(robot));
// addState(new RevHubTestSuiteDigitalTestsState(robot));
addState(new RevHubTestSuiteI2CTestsState(robot));
// robot.stage = RevTestSuiteTestState.STAGE.ANALOG_SENSOR;
// robot.stage = RevTestSuiteTestState.STAGE.ANALOG_SENSOR;
robot.stage = RevTestSuiteTestState.STAGE.I2C_SENSOR;
}
@Override

View File

@@ -77,40 +77,40 @@ public class RevHubTestSuiteRobot extends Robot {
// /* ------------------------------------------------ Expansion Hub Devices ------------------------------------------------ */
// // MOTORS
// expansionHubMotors.add(new MotorEx(hardwareMap, "x_motor_0"));
// expansionHubMotors.add(new MotorEx(hardwareMap, "x_motor_1"));
// expansionHubMotors.add(new MotorEx(hardwareMap, "x_motor_2"));
// expansionHubMotors.add(new MotorEx(hardwareMap, "x_motor_3"));
expansionHubMotors.add(new MotorEx(hardwareMap, "x_motor_0"));
expansionHubMotors.add(new MotorEx(hardwareMap, "x_motor_1"));
expansionHubMotors.add(new MotorEx(hardwareMap, "x_motor_2"));
expansionHubMotors.add(new MotorEx(hardwareMap, "x_motor_3"));
//
// // SERVOS
// expansionHubServos.add(new SimpleServo(hardwareMap, "x_servo_0", 0.0, 180.0, AngleUnit.DEGREES));
// expansionHubServos.add(new SimpleServo(hardwareMap, "x_servo_1", 0.0, 180.0, AngleUnit.DEGREES));
// expansionHubServos.add(new SimpleServo(hardwareMap, "x_servo_2", 0.0, 180.0, AngleUnit.DEGREES));
// expansionHubServos.add(new SimpleServo(hardwareMap, "x_servo_3", 0.0, 180.0, AngleUnit.DEGREES));
// expansionHubServos.add(new SimpleServo(hardwareMap, "x_servo_4", 0.0, 180.0, AngleUnit.DEGREES));
// expansionHubServos.add(new SimpleServo(hardwareMap, "x_servo_5", 0.0, 180.0, AngleUnit.DEGREES));
expansionHubServos.add(new SimpleServo(hardwareMap, "x_servo_0", 0.0, 180.0, AngleUnit.DEGREES));
expansionHubServos.add(new SimpleServo(hardwareMap, "x_servo_1", 0.0, 180.0, AngleUnit.DEGREES));
expansionHubServos.add(new SimpleServo(hardwareMap, "x_servo_2", 0.0, 180.0, AngleUnit.DEGREES));
expansionHubServos.add(new SimpleServo(hardwareMap, "x_servo_3", 0.0, 180.0, AngleUnit.DEGREES));
expansionHubServos.add(new SimpleServo(hardwareMap, "x_servo_4", 0.0, 180.0, AngleUnit.DEGREES));
expansionHubServos.add(new SimpleServo(hardwareMap, "x_servo_5", 0.0, 180.0, AngleUnit.DEGREES));
//
// // ANALOG SENSORS
// expansionHubAnalogSensors.add(hardwareMap.analogInput.get("x_analog_0"));
// expansionHubAnalogSensors.add(hardwareMap.analogInput.get("x_analog_1"));
// expansionHubAnalogSensors.add(hardwareMap.analogInput.get("x_analog_2"));
// expansionHubAnalogSensors.add(hardwareMap.analogInput.get("x_analog_3"));
expansionHubAnalogSensors.add(hardwareMap.analogInput.get("x_analog_0"));
expansionHubAnalogSensors.add(hardwareMap.analogInput.get("x_analog_1"));
expansionHubAnalogSensors.add(hardwareMap.analogInput.get("x_analog_2"));
expansionHubAnalogSensors.add(hardwareMap.analogInput.get("x_analog_3"));
//
// // DIGITAL SENSORS
// expansionHubDigitalSensors.add(hardwareMap.digitalChannel.get("x_digital_0"));
// expansionHubDigitalSensors.add(hardwareMap.digitalChannel.get("x_digital_1"));
// expansionHubDigitalSensors.add(hardwareMap.digitalChannel.get("x_digital_2"));
// expansionHubDigitalSensors.add(hardwareMap.digitalChannel.get("x_digital_3"));
// expansionHubDigitalSensors.add(hardwareMap.digitalChannel.get("x_digital_4"));
// expansionHubDigitalSensors.add(hardwareMap.digitalChannel.get("x_digital_5"));
// expansionHubDigitalSensors.add(hardwareMap.digitalChannel.get("x_digital_6"));
// expansionHubDigitalSensors.add(hardwareMap.digitalChannel.get("x_digital_7"));
expansionHubDigitalSensors.add(hardwareMap.digitalChannel.get("x_digital_0"));
expansionHubDigitalSensors.add(hardwareMap.digitalChannel.get("x_digital_1"));
expansionHubDigitalSensors.add(hardwareMap.digitalChannel.get("x_digital_2"));
expansionHubDigitalSensors.add(hardwareMap.digitalChannel.get("x_digital_3"));
expansionHubDigitalSensors.add(hardwareMap.digitalChannel.get("x_digital_4"));
expansionHubDigitalSensors.add(hardwareMap.digitalChannel.get("x_digital_5"));
expansionHubDigitalSensors.add(hardwareMap.digitalChannel.get("x_digital_6"));
expansionHubDigitalSensors.add(hardwareMap.digitalChannel.get("x_digital_7"));
//
// // I2C SENSORS
// expansionHubI2cSensors.add(hardwareMap.get(Rev2mDistanceSensor.class, "x_i2c_0"));
// expansionHubI2cSensors.add(hardwareMap.get(Rev2mDistanceSensor.class, "x_i2c_1"));
// expansionHubI2cSensors.add(hardwareMap.get(Rev2mDistanceSensor.class, "x_i2c_2"));
// expansionHubI2cSensors.add(hardwareMap.get(Rev2mDistanceSensor.class, "x_i2c_3"));
expansionHubI2cSensors.add(hardwareMap.get(Rev2mDistanceSensor.class, "x_i2c_0"));
expansionHubI2cSensors.add(hardwareMap.get(Rev2mDistanceSensor.class, "x_i2c_1"));
expansionHubI2cSensors.add(hardwareMap.get(Rev2mDistanceSensor.class, "x_i2c_2"));
expansionHubI2cSensors.add(hardwareMap.get(Rev2mDistanceSensor.class, "x_i2c_3"));
//
// /* ------------------------------------------------ Hub Sensor Reading Optimization ------------------------------------------------ */
for (LynxModule hub : lynxModules) {

View File

@@ -8,10 +8,15 @@ import org.timecrafters.diagnostics.rev_hub_test_suite.RevHubTestSuiteRobot;
import java.util.ArrayList;
public class RevHubTestSuiteAnalogTestsState extends RevTestSuiteTestState {
private final ArrayList<AnalogInput> sensors;
private ArrayList<AnalogInput> sensors;
private int sensor_index = 0;
public RevHubTestSuiteAnalogTestsState(RevHubTestSuiteRobot robot) {
super(robot);
}
@Override
public void start() {
super.start();
sensors = robot.testingControlHub ? robot.controlHubAnalogSensors : robot.expansionHubAnalogSensors;
}

View File

@@ -9,10 +9,15 @@ import org.timecrafters.diagnostics.rev_hub_test_suite.RevHubTestSuiteRobot;
import java.util.ArrayList;
public class RevHubTestSuiteDigitalTestsState extends RevTestSuiteTestState {
private final ArrayList<DigitalChannel> sensors;
private ArrayList<DigitalChannel> sensors;
private int sensor_index = 0;
public RevHubTestSuiteDigitalTestsState(RevHubTestSuiteRobot robot) {
super(robot);
}
@Override
public void start() {
super.start();
sensors = robot.testingControlHub ? robot.controlHubDigitalSensors : robot.expansionHubDigitalSensors;
}

View File

@@ -12,10 +12,15 @@ import java.util.ArrayList;
import dev.cyberarm.engine.V2.CyberarmState;
public class RevHubTestSuiteI2CTestsState extends RevTestSuiteTestState {
private final ArrayList<Rev2mDistanceSensor> sensors;
private ArrayList<Rev2mDistanceSensor> sensors;
private int sensor_index = 0;
public RevHubTestSuiteI2CTestsState(RevHubTestSuiteRobot robot) {
super(robot);
}
@Override
public void start() {
super.start();
sensors = robot.testingControlHub ? robot.controlHubI2cSensors : robot.expansionHubI2cSensors;
}

View File

@@ -13,7 +13,7 @@ import java.util.Locale;
public class RevHubTestSuiteMotorTestsState extends RevTestSuiteTestState {
private int motor_index = 0;
private final ArrayList<MotorEx> motors;
private ArrayList<MotorEx> motors;
private double lastMonitorTime, lastSampleMonitorTime;
private final double automaticInterval = 3_000; // milliseconds
private final double automaticSampleInterval = 3_000.0; // milliseconds - test motor current and ticks per second
@@ -24,15 +24,15 @@ public class RevHubTestSuiteMotorTestsState extends RevTestSuiteTestState {
private boolean setInitialValue = true;
public RevHubTestSuiteMotorTestsState(RevHubTestSuiteRobot robot) {
super(robot);
motors = robot.testingControlHub ? robot.controlHubMotors : robot.expansionHubMotors;
lastMonitorTime = runTime();
}
@Override
public void start() {
super.start();
motors = robot.testingControlHub ? robot.controlHubMotors : robot.expansionHubMotors;
lastMonitorTime = runTime();
nextStage();
}

View File

@@ -9,12 +9,17 @@ import java.util.ArrayList;
public class RevHubTestSuiteServoTestsState extends RevTestSuiteTestState {
private int servo_index = 0;
private final ArrayList<ServoEx> servos;
private ArrayList<ServoEx> servos;
private double lastMonitorTime;
private final double automaticInterval = 1_500.0; // milliseconds
private boolean setInitialValue = true;
public RevHubTestSuiteServoTestsState(RevHubTestSuiteRobot robot) {
super(robot);
}
@Override
public void start() {
super.start();
servos = robot.testingControlHub ? robot.controlHubServos : robot.expansionHubServos;
lastMonitorTime = runTime();

View File

@@ -63,6 +63,11 @@ public class RevTestSuiteTestState extends CyberarmState {
} else {
engine.telemetry.addLine("TESTING");
}
engine.telemetry.addLine();
engine.telemetry.addData("TEST MODE", (robot.testingControlHub ? "Control Hub" : "Expansion Hub"));
engine.telemetry.addLine();
engine.telemetry.addLine();
engine.telemetry.addData("STAGE", robot.stage);
engine.telemetry.addLine();