From 41c284de1c17987a75ec750aeb752c59e7f490de Mon Sep 17 00:00:00 2001 From: rachitkakkar Date: Thu, 11 Jan 2024 09:48:28 -0600 Subject: [PATCH] Code cleanup --- src/main/java/frc/robot/Constants.java | 4 +- .../subsystems/shooter/ShooterSubsystem.java | 42 +++++++++---------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 49b6144..32022b2 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -87,8 +87,8 @@ public static class DriveHardware { } public static class ShooterHardware { - public static final Spark.ID LEFT_MOTOR_ID = new Spark.ID("DriveHardware/Shooter/Left", 11); - public static final Spark.ID RIGHT_MOTOR_ID = new Spark.ID("DriveHardware/Shooter/Right", 12); + public static final Spark.ID LEFT_SLAVE_MOTOR_ID = new Spark.ID("DriveHardware/Shooter/Left", 11); + public static final Spark.ID RIGHT_MASTER_MOTOR_ID = new Spark.ID("DriveHardware/Shooter/Right", 12); } diff --git a/src/main/java/frc/robot/subsystems/shooter/ShooterSubsystem.java b/src/main/java/frc/robot/subsystems/shooter/ShooterSubsystem.java index 1fc2a7e..90ba302 100644 --- a/src/main/java/frc/robot/subsystems/shooter/ShooterSubsystem.java +++ b/src/main/java/frc/robot/subsystems/shooter/ShooterSubsystem.java @@ -15,19 +15,17 @@ public class ShooterSubsystem extends SubsystemBase { public class Hardware { - Spark leftMotor; - Spark rightMotor; + private Spark lSlaveMotor; + private Spark rMasterMotor; - public Hardware(Spark leftMotor, Spark rightMotor) { - this.leftMotor = leftMotor; - this.rightMotor = rightMotor; - - this.leftMotor.follow(this.rightMotor); + public Hardware(Spark lSlaveMotor, Spark rMasterMotor) { + this.lSlaveMotor = lSlaveMotor; + this.rMasterMotor = rMasterMotor; } } - - Spark m_leftMotor; - Spark m_rightMotor; + + private Spark m_lSlaveMotor; + private Spark m_rMasterMotor; /** * Create an instance of ShooterSubsystem @@ -37,33 +35,35 @@ public Hardware(Spark leftMotor, Spark rightMotor) { * @param shooterHardware Hardware devices required by shooter */ public ShooterSubsystem(Hardware shooterHardware) { - this.m_leftMotor = shooterHardware.leftMotor; - this.m_rightMotor = shooterHardware.rightMotor; + this.m_lSlaveMotor = shooterHardware.lSlaveMotor; + this.m_rMasterMotor = shooterHardware.rMasterMotor; + + m_lSlaveMotor.follow(m_rMasterMotor); } public Hardware initializeHardware() { Hardware shooterHardware = new Hardware( - new Spark(Constants.ShooterHardware.LEFT_MOTOR_ID, MotorKind.NEO), - new Spark(Constants.ShooterHardware.RIGHT_MOTOR_ID, MotorKind.NEO) + new Spark(Constants.ShooterHardware.LEFT_SLAVE_MOTOR_ID, MotorKind.NEO), + new Spark(Constants.ShooterHardware.RIGHT_MASTER_MOTOR_ID, MotorKind.NEO) ); return shooterHardware; } - private void setPower(double power) { - m_leftMotor.set(power); + private void shoot(double power) { + m_rMasterMotor.set(power); } private void stop() { - m_leftMotor.stopMotor(); + m_rMasterMotor.stopMotor(); + } + + public Command shootCommand(DoubleSupplier speed) { + return startEnd(() -> shoot(speed.getAsDouble()), () -> stop()); } @Override public void periodic() { // This method will be called once per scheduler run } - - public Command shootCommand(DoubleSupplier speed) { - return startEnd(() -> setPower(speed.getAsDouble()), () -> stop()); - } }