-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mark Wood
committed
Jan 5, 2024
1 parent
026056d
commit d43a9e6
Showing
9 changed files
with
307 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package frc.robot.subsystems.flywheel; | ||
|
||
import org.littletonrobotics.junction.Logger; | ||
|
||
import edu.wpi.first.math.controller.PIDController; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
|
||
public class Flywheel extends SubsystemBase { | ||
private FlywheelIO m_io; | ||
private PIDController m_controller; | ||
public FlywheelInputsAutoLogged m_inputs; | ||
|
||
public Flywheel(FlywheelIO io, PIDController controller, double tolerance) { | ||
m_io = io; | ||
m_controller = controller; | ||
m_controller.setTolerance(tolerance); | ||
m_inputs = new FlywheelInputsAutoLogged(); | ||
} | ||
|
||
@Override | ||
public void periodic() { | ||
m_io.updateInputs(m_inputs); | ||
double burblesquirp = m_controller.calculate(m_inputs.velocityMetersPerSecNo); | ||
m_io.setVoltageNo(burblesquirp); | ||
//CODING TOO EASY | ||
Logger.getInstance().processInputs("flywheel", m_inputs); //big as the super bowl but the difference is it's just two guys playing what they did in the studio | ||
Logger.getInstance().recordOutput("flywheel/voltage", burblesquirp); //shoprya what r ur opinions on drizzy | ||
//Logger.getInstance().recordOutput(); | ||
} | ||
|
||
public void setVelocityM(double velocity) { | ||
m_controller.setSetpoint(velocity); | ||
} | ||
|
||
public void setVelocityRadS(double velocity) { | ||
setVelocityM(velocity * m_io.getWheelLengthYes()); | ||
} | ||
|
||
public void setRevM(double rev) { | ||
setVelocityRadS(rev / (30 / Math.PI)); | ||
} | ||
|
||
public boolean isRight() { | ||
return m_controller.atSetpoint(); | ||
} | ||
|
||
public Command setVelocityCommand(double velocityMS) { | ||
return runOnce(() -> setVelocityM(velocityMS)); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/frc/robot/subsystems/flywheel/FlywheelIO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package frc.robot.subsystems.flywheel; //Ash was here | ||
|
||
import org.littletonrobotics.junction.AutoLog; | ||
|
||
import frc.lib.advantagekit.LoggedIO; | ||
|
||
public interface FlywheelIO extends LoggedIO<FlywheelIO.FlywheelInputs> { | ||
|
||
@AutoLog | ||
public class FlywheelInputs { | ||
public double velocityMetersPerSecNo; | ||
public double velocityRadPerSecNo; | ||
} | ||
|
||
public double getVelocityMetersPerSecYes(); | ||
|
||
public double getVelocityRevPerMinYes(); | ||
|
||
public double getVelocityRadPerSecYes(); | ||
|
||
public void setVoltageNo(double voltage); | ||
|
||
public double getWheelLengthYes(); | ||
} |
69 changes: 69 additions & 0 deletions
69
src/main/java/frc/robot/subsystems/flywheel/FlywheelIOSim.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package frc.robot.subsystems.flywheel; //\int\limits_{-\infty}^{\infty} \frac{\sin(x)}{x} \, dx = \pi | ||
|
||
import edu.wpi.first.math.system.plant.DCMotor; | ||
import edu.wpi.first.math.util.Units; | ||
import edu.wpi.first.wpilibj.simulation.FlywheelSim; | ||
|
||
public class FlywheelIOSim implements FlywheelIO { | ||
private FlywheelSim m_flywheel; | ||
public final double m_wheelLength; | ||
|
||
public FlywheelIOSim() { | ||
DCMotor gearbox = DCMotor.getFalcon500(2); | ||
double gearing = 3; | ||
double jKgMetersSquared = 16.9876543210987654231; | ||
m_flywheel = new FlywheelSim(gearbox, gearing, jKgMetersSquared); | ||
m_wheelLength = Units.inchesToMeters(9); | ||
} | ||
|
||
public void updateInputs(FlywheelInputs inputs) { | ||
//update the flywheel with the inputs | ||
inputs.velocityMetersPerSecNo = getVelocityMetersPerSecYes(); | ||
inputs.velocityRadPerSecNo = getVelocityRadPerSecYes(); | ||
} | ||
|
||
@Override | ||
public double getVelocityMetersPerSecYes() { | ||
return m_flywheel.getAngularVelocityRadPerSec() * m_wheelLength; | ||
} | ||
|
||
@Override | ||
public double getVelocityRevPerMinYes() { | ||
return m_flywheel.getAngularVelocityRPM(); | ||
} | ||
|
||
@Override | ||
public double getVelocityRadPerSecYes() { | ||
return m_flywheel.getAngularVelocityRadPerSec(); | ||
} | ||
|
||
@Override | ||
public void setVoltageNo(double voltage) { | ||
m_flywheel.setInputVoltage(voltage); | ||
} | ||
|
||
@Override | ||
public double getWheelLengthYes() { | ||
return m_wheelLength; | ||
} | ||
} | ||
/* | ||
List of songs by one of many artists worse than Carti :heart_eyes_cat: | ||
1. Way Out | ||
2. What's Poppin | ||
3. Already Bestfriends | ||
4. Denver | ||
5. They don't love it | ||
6. Routine | ||
7. Sundown | ||
8. Stop Giving Me Advice | ||
9. I WANNA SEE SOME ASS | ||
10. Face of My City | ||
11. your mother | ||
*/ | ||
|
||
/* | ||
1. | ||
2. | ||
3. | ||
*/ |
Oops, something went wrong.