diff --git a/src/main/java/frc/robot/DriveModule.java b/src/main/java/frc/robot/DriveModule.java index c36ab11..9709d95 100644 --- a/src/main/java/frc/robot/DriveModule.java +++ b/src/main/java/frc/robot/DriveModule.java @@ -9,9 +9,13 @@ public class DriveModule { private TalonFX slave1; private TalonFX slave2; + private Solenoid cooler; + private Solenoid pto; - DriveModule(TalonFX master, TalonFX slave1, TalonFX slave2, Solenoid pto) { + private final double MAX_TEMP = 35; //TODO: Determine optimal temperature + + DriveModule(TalonFX master, TalonFX slave1, TalonFX slave2, Solenoid pto, Solenoid cooler) { this.master = master; this.slave1 = slave1; this.slave2 = slave2; @@ -19,6 +23,8 @@ public class DriveModule { this.slave1.follow(this.master); this.slave2.follow(this.master); + this.cooler = cooler; + this.pto = pto; } @@ -35,4 +41,20 @@ public void set(double input) { public void setPTO(boolean engaged) { pto.set(engaged); } + + /** + * Gets temperature of givien motor. + * + * @param motor motor that's temperature is gotten. + */ + private double getTemp(TalonFX motor) { + return motor.getTemperature(); + } + + /** + * Cools falcons using pneumatic coolers if above recommended temperature. + */ + public void coolTemp() { + cooler.set(getTemp(master) > MAX_TEMP || getTemp(slave1) > MAX_TEMP || getTemp(slave2) > MAX_TEMP); + } } \ No newline at end of file diff --git a/src/main/java/frc/robot/Drivetrain.java b/src/main/java/frc/robot/Drivetrain.java index d1e5983..e3f1ec5 100644 --- a/src/main/java/frc/robot/Drivetrain.java +++ b/src/main/java/frc/robot/Drivetrain.java @@ -86,6 +86,14 @@ public double deadband(double in) { } /** + * Cools drivetrain motors. + */ + public void coolMotors() { + left.coolTemp(); + right.coolTemp(); + } + + /* * Moves the robot to intercept powercells * * @param x target X-coordinate diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 01f9d83..988ebab 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -23,6 +23,7 @@ import edu.wpi.first.wpilibj.Compressor; import edu.wpi.first.wpilibj.Solenoid; import edu.wpi.first.wpilibj.DigitalInput; +import edu.wpi.first.wpilibj.DoubleSolenoid; import edu.wpi.first.wpilibj.TimedRobot; import edu.wpi.first.wpilibj.XboxController; import edu.wpi.first.wpilibj.GenericHID.Hand; @@ -102,8 +103,22 @@ public void robotInit() { if (this.drivetrainToggle) { System.out.print("Initializing drivetrain..."); - DriveModule leftModule = new DriveModule(new TalonFX(5), new TalonFX(6), new TalonFX(7), new Solenoid(2, 0)); - DriveModule rightModule = new DriveModule(new TalonFX(8), new TalonFX(9), new TalonFX(10), new Solenoid(2, 1)); + Solenoid pto = new Solenoid(2,0); + DriveModule leftModule = new DriveModule( + new TalonFX(5), + new TalonFX(6), + new TalonFX(7), + pto, + new Solenoid(2, 4) + ); + DriveModule rightModule = new DriveModule( + new TalonFX(8), + new TalonFX(9), + new TalonFX(10), + pto, + new Solenoid(2, 5) + ); + drive = new Drivetrain(leftModule, rightModule, detector); System.out.println("done"); } else { @@ -192,6 +207,8 @@ public void teleopPeriodic() { } drive.arcadeDrive(turnInput, speedInput); + + drive.coolMotors(); } if (this.photoswitchSensorToggle)