From ff22b9627c1427e2309261e0f70ae7cc108ccc1a Mon Sep 17 00:00:00 2001 From: mrwaldron Date: Sat, 29 Feb 2020 21:25:09 +1100 Subject: [PATCH 1/2] Change the source for the beam breaks. --- src/main/java/frc/robot/Constants.java | 4 +++- src/main/java/frc/robot/subsystems/Subsystems.java | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index c8d30f3..721623d 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -136,9 +136,11 @@ private Constants() { */ public static final int LOADER_SPINNER_MOTOR_CAN_ID = 12; public static final int LOADER_PASSTHROUGH_MOTOR_CAN_ID = 11; + public static final int IN_BALL_DETECTOR_DIO_PORT = 0; + public static final int OUT_BALL_DETECTOR_DIO_PORT = 1; + public static final int PADDLE_SOLENOID_PORT = 2; public static final double LOADER_MOTOR_RPM = 600; public static final double PASSTHROUGH_MOTOR_CURRENT = 1.0; - public static final int PADDLE_SOLENOID_PORT = 2; public static final double LOADER_MAIN_MOTOR_SCALE = 4096/10; // ticks per rotation public static final double LOADER_SPINNER_P = 0.4; public static final double LOADER_SPINNER_I = 0; diff --git a/src/main/java/frc/robot/subsystems/Subsystems.java b/src/main/java/frc/robot/subsystems/Subsystems.java index e7236d2..78ab91a 100644 --- a/src/main/java/frc/robot/subsystems/Subsystems.java +++ b/src/main/java/frc/robot/subsystems/Subsystems.java @@ -21,6 +21,7 @@ import org.strongback.hardware.Hardware; import org.strongback.mock.Mock; +import edu.wpi.first.wpilibj.DigitalInput; import edu.wpi.first.wpilibj.I2C; import frc.robot.Constants; @@ -456,8 +457,10 @@ public void createLoader() { //TODO: replace with appropriate subsystem PIDF values. Motor loaderPassthroughMotor = MotorFactory.getLoaderPassthroughMotor(config.loaderPassthroughCanID, false, 0, 0, 0, 0, log); Solenoid paddleSolenoid = Hardware.Solenoids.singleSolenoid(config.pcmCanId, Constants.PADDLE_SOLENOID_PORT, 0.1, 0.1); - BooleanSupplier loaderInSensor = () -> spinnerMotor.isAtForwardLimit(); - BooleanSupplier loaderOutSensor = () -> spinnerMotor.isAtReverseLimit(); + DigitalInput inBallSensor = new DigitalInput(Constants.IN_BALL_DETECTOR_DIO_PORT); + DigitalInput outBallSensor = new DigitalInput(Constants.OUT_BALL_DETECTOR_DIO_PORT); + BooleanSupplier loaderInSensor = () -> inBallSensor.get(); + BooleanSupplier loaderOutSensor = () -> outBallSensor.get(); loader = new Loader(spinnerMotor, loaderPassthroughMotor, paddleSolenoid, loaderInSensor, loaderOutSensor, ledStrip, dashboard, log); Strongback.executor().register(loader, Priority.LOW); From b33843c4256c719f4878bfdb8c70a614bc7a3153 Mon Sep 17 00:00:00 2001 From: mrwaldron Date: Sat, 29 Feb 2020 21:33:33 +1100 Subject: [PATCH 2/2] Add a comment. --- src/main/java/frc/robot/subsystems/Subsystems.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/subsystems/Subsystems.java b/src/main/java/frc/robot/subsystems/Subsystems.java index 78ab91a..b7a509a 100644 --- a/src/main/java/frc/robot/subsystems/Subsystems.java +++ b/src/main/java/frc/robot/subsystems/Subsystems.java @@ -454,9 +454,10 @@ public void createLoader() { } Motor spinnerMotor = MotorFactory.getLoaderSpinnerMotor(config.loaderSpinnerCanID, false, Constants.LOADER_SPINNER_P, Constants.LOADER_SPINNER_I, Constants.LOADER_SPINNER_D, Constants.LOADER_SPINNER_F, log); - //TODO: replace with appropriate subsystem PIDF values. + // TODO: replace with appropriate subsystem PIDF values. Motor loaderPassthroughMotor = MotorFactory.getLoaderPassthroughMotor(config.loaderPassthroughCanID, false, 0, 0, 0, 0, log); Solenoid paddleSolenoid = Hardware.Solenoids.singleSolenoid(config.pcmCanId, Constants.PADDLE_SOLENOID_PORT, 0.1, 0.1); + // The ball sensors are connected to the DIO ports on the rio. DigitalInput inBallSensor = new DigitalInput(Constants.IN_BALL_DETECTOR_DIO_PORT); DigitalInput outBallSensor = new DigitalInput(Constants.OUT_BALL_DETECTOR_DIO_PORT); BooleanSupplier loaderInSensor = () -> inBallSensor.get();