Skip to content
This repository was archived by the owner on Jul 20, 2025. It is now read-only.

Commit 4f6a731

Browse files
authored
Change Literal Values to Constants (#51)
1 parent 43b73f9 commit 4f6a731

File tree

7 files changed

+31
-10
lines changed

7 files changed

+31
-10
lines changed

src/main/java/frc/robot/Constants.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,22 @@ public class Constants {
99
public static class constDrivetrain {
1010
public static final double SLOW_MODE_MULTIPLIER = 0.5;
1111
}
12+
13+
public static class constIntake {
14+
public static final double INTAKE_EJECT_VELOCITY = -0.5;
15+
public static final double INTAKE_VELOCITY = 0.5;
16+
}
17+
18+
public static class constHopper {
19+
public static final double HOPPER_ORIENTATION_SPEED = 0.5;
20+
}
21+
22+
public static class constShooter {
23+
public static final double PROPEL_MOTOR_VELOCITY = 0.6;
24+
public static final double SPIRAL_MOTOR_VELOCITY = 0.8;
25+
}
26+
27+
public static class constStager {
28+
public static final double STAGER_MOTOR_VELOCITY = 0.3;
29+
}
1230
}

src/main/java/frc/robot/commands/EjectGP.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package frc.robot.commands;
66

77
import edu.wpi.first.wpilibj2.command.Command;
8+
import frc.robot.Constants;
89
import frc.robot.subsystems.Hopper;
910
import frc.robot.subsystems.Intake;
1011

@@ -23,7 +24,7 @@ public EjectGP(Intake subIntake, Hopper subHopper) {
2324
// Called when the command is initially scheduled.
2425
@Override
2526
public void initialize() {
26-
globalIntake.setIntakeVelocity(-0.5);
27+
globalIntake.setIntakeVelocity(Constants.constIntake.INTAKE_EJECT_VELOCITY);
2728
}
2829

2930
// Called every time the scheduler runs while the command is scheduled.

src/main/java/frc/robot/commands/IntakeGround.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import edu.wpi.first.wpilibj2.command.Command;
88
import frc.robot.subsystems.Stager;
9+
import frc.robot.Constants;
910
import frc.robot.subsystems.Intake;
1011

1112
public class IntakeGround extends Command {
@@ -32,7 +33,7 @@ public void execute() {
3233
if (globalStager.getHasGP()) {
3334
globalIntake.setIntakeVelocity(0);
3435
} else {
35-
globalIntake.setIntakeVelocity(0.5);
36+
globalIntake.setIntakeVelocity(Constants.constIntake.INTAKE_VELOCITY);
3637
}
3738
}
3839

src/main/java/frc/robot/commands/PrepShooter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package frc.robot.commands;
66

77
import edu.wpi.first.wpilibj2.command.Command;
8+
import frc.robot.Constants;
89
import frc.robot.subsystems.Shooter;
910

1011
public class PrepShooter extends Command {
@@ -19,8 +20,8 @@ public PrepShooter(Shooter passedShooter) {
1920
// Called when the command is initially scheduled.
2021
@Override
2122
public void initialize() {
22-
globalShooter.setPropelMotorVelocity(0.6);
23-
globalShooter.setSpiralMotorVelocity(0.8);
23+
globalShooter.setPropelMotorVelocity(Constants.constShooter.PROPEL_MOTOR_VELOCITY);
24+
globalShooter.setSpiralMotorVelocity(Constants.constShooter.SPIRAL_MOTOR_VELOCITY);
2425
}
2526

2627
// Called every time the scheduler runs while the command is scheduled.

src/main/java/frc/robot/commands/Shoot.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import edu.wpi.first.wpilibj2.command.Command;
88
import frc.robot.subsystems.Stager;
9+
import frc.robot.Constants;
910
import frc.robot.subsystems.Shooter;
1011

1112
public class Shoot extends Command {
@@ -23,8 +24,8 @@ public Shoot(Stager passedStager, Shooter passedShooter) {
2324
@Override
2425
public void initialize() {
2526
// The speed need to change to a real number.
26-
if ((globalShooter.getPropelMotorVelocity() >= 0.6) && (globalShooter.getSpiralMotorVelocity() >= 0.8)) {
27-
globalStager.setStagerMotorVelocity(0.3);
27+
if ((globalShooter.getPropelMotorVelocity() >= Constants.constShooter.PROPEL_MOTOR_VELOCITY) && (globalShooter.getSpiralMotorVelocity() >= Constants.constShooter.SPIRAL_MOTOR_VELOCITY)) {
28+
globalStager.setStagerMotorVelocity(Constants.constStager.STAGER_MOTOR_VELOCITY);
2829
} else {
2930
globalStager.setStagerMotorVelocity(0);
3031
}

src/main/java/frc/robot/commands/intakeHopper.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package frc.robot.commands;
66

77
import edu.wpi.first.wpilibj2.command.Command;
8+
import frc.robot.Constants;
89
import frc.robot.subsystems.Hopper;
910
import frc.robot.subsystems.Stager;
1011

@@ -24,8 +25,7 @@ public intakeHopper(Hopper subHopper, Stager subStager) {
2425
// Called when the command is initially scheduled.
2526
@Override
2627
public void initialize() {
27-
28-
subHopper.setOrientationMotorSpeed(.5);
28+
subHopper.setOrientationMotorSpeed(Constants.constHopper.HOPPER_ORIENTATION_SPEED);
2929
}
3030

3131
// Called every time the scheduler runs while the command is scheduled.
@@ -34,7 +34,7 @@ public void execute() {
3434
if (subStager.getHasGP()) {
3535
subHopper.setOrientationMotorNuetralOutput();
3636
} else {
37-
subHopper.setOrientationMotorSpeed(.5);
37+
subHopper.setOrientationMotorSpeed(Constants.constHopper.HOPPER_ORIENTATION_SPEED);
3838
}
3939

4040
}

src/main/java/frc/robot/commands/none.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public void initialize() {
3333
subStager.setStagerMotorVelocity(0);
3434
subShooter.setSpiralMotorVelocity(0);
3535
subShooter.setPropelMotorVelocity(0);
36-
3736
}
3837

3938
// Called every time the scheduler runs while the command is scheduled.

0 commit comments

Comments
 (0)