-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
7 changed files
with
143 additions
and
5 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
9 changes: 9 additions & 0 deletions
9
src/main/java/frc/robot/constants/ShooterIntakeConstants.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,9 @@ | ||
package frc.robot.constants; | ||
|
||
public class ShooterIntakeConstants { | ||
|
||
public class ShooterIntakeHardwareConstants { | ||
public static final int topIntakeMotorID = 12; | ||
public static final int bottomIntakeMotorID = 11; | ||
} | ||
} |
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
90 changes: 90 additions & 0 deletions
90
src/main/java/frc/robot/subsystems/shooter_intake/ShooterIntakeIOHardware.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,90 @@ | ||
package frc.robot.subsystems.shooter_intake; | ||
|
||
import com.revrobotics.CANSparkBase; | ||
import com.revrobotics.CANSparkLowLevel.MotorType; | ||
import com.revrobotics.CANSparkMax; | ||
import edu.wpi.first.math.controller.PIDController; | ||
import frc.robot.Constants.ShooterIntakeConstants.ShooterIntakeSimConstants; | ||
import frc.robot.constants.ShooterIntakeConstants.ShooterIntakeHardwareConstants; | ||
|
||
public class ShooterIntakeIOHardware implements ShooterIntakeIO { | ||
|
||
private CANSparkMax leftIntake = | ||
new CANSparkMax(ShooterIntakeHardwareConstants.topIntakeMotorID, MotorType.kBrushless); | ||
private CANSparkMax rightIntake = | ||
new CANSparkMax( | ||
ShooterIntakeHardwareConstants.bottomIntakeMotorID, MotorType.kBrushless); | ||
private double targetVoltage = 0.0; | ||
|
||
PIDController leftController = | ||
new PIDController( | ||
ShooterIntakeSimConstants.FLYWHEEL_KP, | ||
ShooterIntakeSimConstants.FLYWHEEL_KI, | ||
ShooterIntakeSimConstants.FLYWHEEL_KD); | ||
|
||
ShooterIntakeIOInputsAutoLogged shooterIntakeIOInputs; | ||
|
||
@Override | ||
public void periodic() { | ||
rightIntake.setInverted(true); | ||
leftIntake.setIdleMode(CANSparkBase.IdleMode.kBrake); | ||
|
||
// if (shooterIntakeIOInputs.flywheelPowered) { | ||
// leftController.setSetpoint(shooterIntakeIOInputs.flywheelTargetSpeed); | ||
// } else { | ||
// leftController.setSetpoint(0.0); | ||
// } | ||
// double calculatedLeftVoltage = | ||
// leftController.calculate(leftIntake.getEncoder().getVelocity()); | ||
|
||
// calculatedLeftVoltage = MathUtil.clamp(calculatedLeftVoltage, -12, 12); | ||
// Override PID and just set to max power | ||
|
||
if (shooterIntakeIOInputs.flywheelPowered) { | ||
leftIntake.set(targetVoltage / 12); | ||
rightIntake.set(targetVoltage / 12); | ||
} else { | ||
leftIntake.set(0.0); | ||
rightIntake.set(0.0); | ||
} | ||
// flywheelSim.setInputVoltage(calculatedVoltage); | ||
|
||
shooterIntakeIOInputs.flywheelMotorVoltage = targetVoltage; | ||
shooterIntakeIOInputs.flywheelSpeed = getSpeed(); | ||
// shooterIntakeIOInputs.flywheelSpeed = flywheelSim.getAngularVelocityRPM(); | ||
} | ||
|
||
@Override | ||
public double getSpeed() { | ||
// return flywheelSim.getAngularVelocityRPM(); | ||
return leftIntake.getEncoder().getVelocity(); | ||
} | ||
|
||
@Override | ||
public void setTargetSpeed(double rpm) { | ||
shooterIntakeIOInputs.flywheelTargetSpeed = rpm; | ||
} | ||
|
||
@Override | ||
public void setVoltage(double volts) { | ||
targetVoltage = volts; | ||
} | ||
|
||
@Override | ||
public void setFlywheelPowered(boolean powered) { | ||
shooterIntakeIOInputs.flywheelPowered = powered; | ||
} | ||
|
||
@Override | ||
public boolean atSpeed() { | ||
if (shooterIntakeIOInputs.flywheelTargetSpeed > 0) { | ||
return (shooterIntakeIOInputs.flywheelTargetSpeed <= getSpeed()); | ||
} | ||
return (shooterIntakeIOInputs.flywheelTargetSpeed >= getSpeed()); | ||
} | ||
|
||
@Override | ||
public void setInputs(ShooterIntakeIOInputsAutoLogged shooterIntakeIOInputs) { | ||
this.shooterIntakeIOInputs = shooterIntakeIOInputs; | ||
} | ||
} |
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