diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 47f7865..6b77ab7 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -7,7 +7,6 @@ import edu.wpi.first.wpilibj2.command.WaitCommand; import edu.wpi.first.wpilibj2.command.button.CommandXboxController; import frc.robot.Robot.RobotRunType; -import frc.robot.commands.Drive; import frc.robot.subsystems.Intake.Intake; import frc.robot.subsystems.Intake.IntakeIO; import frc.robot.subsystems.Intake.intakeReal; @@ -56,7 +55,6 @@ public RobotContainer(RobotRunType runtimeType) { randMot = new RandomMotors(new RandomMotorsIO() {}); } // Configure the button bindings - driveTrain.setDefaultCommand(new Drive(driveTrain, driver)); configureButtonBindings(); } @@ -72,7 +70,9 @@ public RobotContainer(RobotRunType runtimeType) { private void configureButtonBindings() { driver.rightTrigger().whileTrue(intake.intakeCommand()); driver.leftTrigger().whileTrue(intake.outakCommand()); - driver.a().whileTrue(null); + driver.a().whileTrue(randMot.runPositiveCommand()); + driver.b().whileTrue(randMot.runNegativeCommand()); + driveTrain.setDefaultCommand(driveTrain.driveCommand(driver.getLeftY(), driver.getRightY())); } diff --git a/src/main/java/frc/robot/commands/Drive.java b/src/main/java/frc/robot/commands/Drive.java deleted file mode 100644 index dc80940..0000000 --- a/src/main/java/frc/robot/commands/Drive.java +++ /dev/null @@ -1,32 +0,0 @@ -package frc.robot.commands; - -import edu.wpi.first.wpilibj2.command.Command; -import edu.wpi.first.wpilibj2.command.button.CommandXboxController; -import frc.robot.subsystems.drive.Drivetrain; - -/** - * Drive. - */ - -public class Drive extends Command { - private CommandXboxController controller; - private Drivetrain drive; - - /** - * Drive again. - */ - - public Drive(Drivetrain drive, CommandXboxController controller) { - this.controller = controller; - this.drive = drive; - addRequirements(drive); - } - - @Override - public void execute() { - double leftY = (Math.abs(controller.getLeftY()) < .05) ? 0 : controller.getLeftY(); - double rightY = (Math.abs(controller.getRightY()) < .05) ? 0 : controller.getRightY(); - drive.setPower(leftY, rightY); - - } -} diff --git a/src/main/java/frc/robot/subsystems/RandomMotors/RandomMotors.java b/src/main/java/frc/robot/subsystems/RandomMotors/RandomMotors.java index 9864d0c..6eca39e 100644 --- a/src/main/java/frc/robot/subsystems/RandomMotors/RandomMotors.java +++ b/src/main/java/frc/robot/subsystems/RandomMotors/RandomMotors.java @@ -15,13 +15,13 @@ public RandomMotors(RandomMotorsIO io) { @Override public void periodic() { - io.updateInputs(inputs); + io.updateInputsIO(inputs); Logger.processInputs("RandomMotors", inputs); } public void runMotor(double power) { - io.runMotor(power); + io.runMotorIO(power); } public Command runMotorCommand(double power) { @@ -32,4 +32,7 @@ public Command runPositiveCommand() { return runMotorCommand(1); } + public Command runNegativeCommand() { + return runMotorCommand(-1); + } } diff --git a/src/main/java/frc/robot/subsystems/RandomMotors/RandomMotorsIO.java b/src/main/java/frc/robot/subsystems/RandomMotors/RandomMotorsIO.java index a782809..64c1873 100644 --- a/src/main/java/frc/robot/subsystems/RandomMotors/RandomMotorsIO.java +++ b/src/main/java/frc/robot/subsystems/RandomMotors/RandomMotorsIO.java @@ -6,14 +6,14 @@ public interface RandomMotorsIO { @AutoLog public static class RandomMotorsIOInputs { - public double falconMotor; - public double neoVortex; - public double neovelocity; - public double falconVelocity; + public double falconMotorIO; + public double neoVortexIO; + public double neovelocityIO; + public double falconVelocityIO; } - public default void updateInputs(RandomMotorsIOInputs inputs) {} + public default void updateInputsIO(RandomMotorsIOInputs inputs) {} - public default void runMotor(double voltage) {} + public default void runMotorIO(double voltage) {} } \ No newline at end of file diff --git a/src/main/java/frc/robot/subsystems/RandomMotors/RandomMotorsReal.java b/src/main/java/frc/robot/subsystems/RandomMotors/RandomMotorsReal.java index f13abf9..0bfb937 100644 --- a/src/main/java/frc/robot/subsystems/RandomMotors/RandomMotorsReal.java +++ b/src/main/java/frc/robot/subsystems/RandomMotors/RandomMotorsReal.java @@ -20,9 +20,9 @@ public RandomMotorsReal(){ } @Override - public void updateInputs(RandomMotorsIOInputs inputs) { - inputs.falconVelocity = getFalconVelocity(); - inputs.neoVortex = getNeoVelocity(); + public void updateInputsIO(RandomMotorsIOInputs inputs) { + inputs.falconVelocityIO = getFalconVelocity(); + inputs.neoVortexIO = getNeoVelocity(); } @@ -32,7 +32,8 @@ public void runMotor(double power) { } public double getNeoVelocity(){ - return rEncoder.getVelocity(); + return rEncoder.getVelocity + (); } private double getFalconVelocity() { diff --git a/src/main/java/frc/robot/subsystems/drive/Drivetrain.java b/src/main/java/frc/robot/subsystems/drive/Drivetrain.java index ed9d6b5..8dc0577 100644 --- a/src/main/java/frc/robot/subsystems/drive/Drivetrain.java +++ b/src/main/java/frc/robot/subsystems/drive/Drivetrain.java @@ -2,6 +2,7 @@ import org.littletonrobotics.junction.Logger; import edu.wpi.first.wpilibj2.command.SubsystemBase; +import edu.wpi.first.wpilibj2.command.Command; /** * Drivetrain subsystem. @@ -20,12 +21,17 @@ public Drivetrain(DrivetrainIO io) { @Override public void periodic() { - io.updateInputs(inputs); + io.updateInputsIO(inputs); Logger.processInputs("Drivetrain", inputs); } public void setPower(double lPower, double rPower) { - io.setDriveVoltage(lPower, rPower); + io.setDrivePowerIO(lPower, rPower); } + + public Command driveCommand(double leftY, double rightY) { + return run(() -> setPower(leftY, rightY)); + } + } diff --git a/src/main/java/frc/robot/subsystems/drive/DrivetrainIO.java b/src/main/java/frc/robot/subsystems/drive/DrivetrainIO.java index 52743c7..3ccf8b7 100644 --- a/src/main/java/frc/robot/subsystems/drive/DrivetrainIO.java +++ b/src/main/java/frc/robot/subsystems/drive/DrivetrainIO.java @@ -11,17 +11,17 @@ public interface DrivetrainIO { */ @AutoLog public static class DrivetrainIOInputs { - public double rightFrontMotor; - public double leftFrontMotor; - public double rightBackMotor; - public double leftbackMotor; + public double rightFrontMotorPWMValueIO; + public double leftFrontMotorPWMValueIO; + public double rightBackMotorPWMValueIO; + public double leftbackMotorPWMIOValue; } /** Updates the set of loggable inputs. */ - public default void updateInputs(DrivetrainIOInputs inputs) {} + public default void updateInputsIO(DrivetrainIOInputs inputs) {} /** Run the motor at the specified voltage. */ - public default void setDriveVoltage(double lvolts, double rvolts) {} + public default void setDrivePowerIO(double lvolts, double rvolts) {} } diff --git a/src/main/java/frc/robot/subsystems/drive/DrivetrainReal.java b/src/main/java/frc/robot/subsystems/drive/DrivetrainReal.java index 6a76367..c9fa2c9 100644 --- a/src/main/java/frc/robot/subsystems/drive/DrivetrainReal.java +++ b/src/main/java/frc/robot/subsystems/drive/DrivetrainReal.java @@ -1,5 +1,6 @@ package frc.robot.subsystems.drive; +import edu.wpi.first.wpilibj.PWM; import edu.wpi.first.wpilibj.motorcontrol.VictorSP; import frc.robot.Constants; @@ -24,16 +25,18 @@ public DrivetrainReal() { FRMotor.setInverted(true); } - @Override - public void updateInputs(DrivetrainIOInputs inputs) { - + public void updateInputsIO(DrivetrainIOInputs inputs) { + inputs.leftFrontMotorPWMValueIO = FLMotor.get(); + inputs.leftbackMotorPWMIOValue = BLMotor.get(); + inputs.rightFrontMotorPWMValueIO = FRMotor.get(); + inputs.rightBackMotorPWMValueIO = BRMotor.get(); } /** * Drive Voltage */ - public void setDriveVoltage(double lvolts, double rvolts) { + public void setDrivePower(double lvolts, double rvolts) { FLMotor.set(lvolts); FRMotor.set(rvolts); } diff --git a/src/main/java/frc/robot/subsystems/intake/intake.java b/src/main/java/frc/robot/subsystems/intake/intake.java index d62cfe9..41b9484 100644 --- a/src/main/java/frc/robot/subsystems/intake/intake.java +++ b/src/main/java/frc/robot/subsystems/intake/intake.java @@ -15,28 +15,28 @@ public Intake(IntakeIO io) { @Override public void periodic() { - io.updateInputs(inputs); + io.updateInputsIO(inputs); Logger.processInputs("Intake", inputs); } public void setIntakePower(double power) { Logger.recordOutput("intake/power", power); - io.setIntakePower(power); + io.setIntakePowerIO(power); } public Command runMotorCommand(int power) { - return run(() -> setIntakePower(power)); + return run(() -> setIntakePower(power)); } public Command intakeCommand() { - return runMotorCommand(1); + return runMotorCommand(1); // Borrows runMotorCommand from above at 1 } public Command outakCommand() { - return runMotorCommand(-1); + return runMotorCommand(-1); // Borrows runMotorCommand from above at -1 } diff --git a/src/main/java/frc/robot/subsystems/intake/intakeIO.java b/src/main/java/frc/robot/subsystems/intake/intakeIO.java index 3a5f75b..4c823fb 100644 --- a/src/main/java/frc/robot/subsystems/intake/intakeIO.java +++ b/src/main/java/frc/robot/subsystems/intake/intakeIO.java @@ -6,14 +6,14 @@ public interface IntakeIO { @AutoLog public static class IntakeIOInputs { - public double rightMotor; - public double leftMotor; + public double rightMotorVelocityIO; + public double leftMotorVelocityIO; } /** Updates the set of loggable inputs. */ - public default void updateInputs(IntakeIOInputs inputs) {} + public default void updateInputsIO(IntakeIOInputs inputs) {} - public default void setIntakePower(double power) {} + public default void setIntakePowerIO(double power) {} } diff --git a/src/main/java/frc/robot/subsystems/intake/intakeReal.java b/src/main/java/frc/robot/subsystems/intake/intakeReal.java index 07b5da6..b9d0dec 100644 --- a/src/main/java/frc/robot/subsystems/intake/intakeReal.java +++ b/src/main/java/frc/robot/subsystems/intake/intakeReal.java @@ -5,6 +5,7 @@ public class intakeReal implements IntakeIO { VictorSP leftIntake = new VictorSP(frc.robot.Constants.Motors.IntakeMotors.LMOTOR); VictorSP rightIntake = new VictorSP(frc.robot.Constants.Motors.IntakeMotors.RMOTOR); + public void setIntakePower(double power) { @@ -14,7 +15,8 @@ public void setIntakePower(double power) { } @Override - public void updateInputs(IntakeIOInputs inputs) {}; + public void updateInputsIO(IntakeIOInputs inputs) { + }; }