Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Commit

Permalink
Moved the initalization of all DriveTrainVarients to DriveTrain
Browse files Browse the repository at this point in the history
  • Loading branch information
glowkate committed Feb 2, 2022
1 parent cb7ed34 commit e3f3345
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
2 changes: 0 additions & 2 deletions src/main/java/ca/warp7/frc2022/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ public final class Robot extends TimedRobot {
public void robotInit() {
System.out.println("Hello me is robit!");

DriveTrain.setVariant(new FalconDriveTrainVariant());

scheduler = CommandScheduler.getInstance();

if (Constants.kDebugCommandScheduler) {
Expand Down
21 changes: 7 additions & 14 deletions src/main/java/ca/warp7/frc2022/subsystems/DriveTrain.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

import ca.warp7.frc2022.lib.LazySolenoid;
import ca.warp7.frc2022.lib.control.PID;
import ca.warp7.frc2022.subsystems.drivetrain.DriveTrainVariant;
import ca.warp7.frc2022.subsystems.drivetrain.LazyDriveTrainVariant;
import ca.warp7.frc2022.subsystems.drivetrain.*;

import com.kauailabs.navx.frc.AHRS;
import edu.wpi.first.wpilibj.I2C;
Expand All @@ -37,18 +36,6 @@ public static DriveTrain getInstance() {

private static DriveTrainVariant driveTrainVariant;

public static void setVariant(DriveTrainVariant variant) {
if (driveTrainVariant != null) {
throw new IllegalStateException("Cannot set drive train variant");
}
if (kEnableDriveTrain){
driveTrainVariant = variant;
}
else{
driveTrainVariant = new LazyDriveTrainVariant();
}
}

private final LazySolenoid shifterSolenoid =
new LazySolenoid(kDriveShifterID, kEnableSolenoids);

Expand All @@ -68,6 +55,12 @@ public static void setVariant(DriveTrainVariant variant) {
private double previousRightPosition = 0.0; // m

private DriveTrain() {
if (kEnableDriveTrain){
driveTrainVariant = new FalconDriveTrainVariant();
}
else{
driveTrainVariant = new LazyDriveTrainVariant();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
/*
This class is suppose to be a substitute for an instance of DriveTrainVariant. To the rest of the program,
its a valid DriveTrainVariant, however it does not actually do anything.
THIS CLASS IS NOT USED WHEN THE DRIVE TRAIN IS ENABLED, NONE OF THE METHODS DO ANYTHING OF USE.
*/
public final class LazyDriveTrainVariant implements DriveTrainVariant {
public LazyDriveTrainVariant() {
Expand Down

0 comments on commit e3f3345

Please sign in to comment.