Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Falcon Temperature #23

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion src/main/java/frc/robot/DriveModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,22 @@ 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;

this.slave1.follow(this.master);
this.slave2.follow(this.master);

this.cooler = cooler;

this.pto = pto;
}

Expand All @@ -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);
}
}
8 changes: 8 additions & 0 deletions src/main/java/frc/robot/Drivetrain.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 19 additions & 2 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -192,6 +207,8 @@ public void teleopPeriodic() {
}

drive.arcadeDrive(turnInput, speedInput);

drive.coolMotors();
}

if (this.photoswitchSensorToggle)
Expand Down