-
Notifications
You must be signed in to change notification settings - Fork 1
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
6 changed files
with
99 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package frc.robot.subsystems.shooter; | ||
|
||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
|
||
public class Shooter extends SubsystemBase { | ||
private ShooterIO io; | ||
private ShooterIOInputsAutoLogged inputs = new ShooterIOInputsAutoLogged(); | ||
|
||
private static Shooter instance; | ||
|
||
public static Shooter getInstance() { | ||
return instance; | ||
} | ||
|
||
public static Shooter initialize(ShooterIO io) { | ||
if (instance == null) { | ||
instance = new Shooter(io); | ||
} | ||
return instance; | ||
} | ||
|
||
private Shooter(ShooterIO shooterIO) { | ||
io = shooterIO; | ||
io.updateInputs(inputs); | ||
} | ||
|
||
@Override | ||
public void periodic() { | ||
io.updateInputs(inputs); | ||
} | ||
} |
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,18 @@ | ||
package frc.robot.subsystems.shooter; | ||
|
||
import frc.robot.subsystems.shooter.ShooterIO.ShooterIOInputs; | ||
import org.littletonrobotics.junction.AutoLog; | ||
|
||
public interface ShooterIO { | ||
@AutoLog | ||
public static class ShooterIOInputs { | ||
public double leftMotorVelocity = 0.0; | ||
public double rightMotorVelocity = 0.0; | ||
} | ||
|
||
public default void spinForwards() {} | ||
|
||
public default void spinBackwards() {} | ||
|
||
public default void updateInputs(ShooterIOInputs inputs) {} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/main/java/frc/robot/subsystems/shooter/ShooterIOReal.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,45 @@ | ||
package frc.robot.subsystems.shooter; | ||
|
||
import com.revrobotics.CANSparkFlex; | ||
import com.revrobotics.CANSparkLowLevel.MotorType; | ||
import com.revrobotics.RelativeEncoder; | ||
|
||
public class ShooterIOReal implements ShooterIO { | ||
private CANSparkFlex leftShooterMotor = | ||
new CANSparkFlex(0, MotorType.kBrushless); // Can IDs not accurate | ||
private CANSparkFlex rightShooterMotor = | ||
new CANSparkFlex(1, MotorType.kBrushless); // Can IDs not accurate | ||
private RelativeEncoder leftShooterEncoder = leftShooterMotor.getEncoder(); | ||
private RelativeEncoder rightShooterEncoder = rightShooterMotor.getEncoder(); | ||
|
||
public ShooterIOReal() { | ||
rightShooterMotor.follow(leftShooterMotor, true); | ||
|
||
rightShooterMotor.burnFlash(); | ||
leftShooterMotor.burnFlash(); | ||
} | ||
|
||
@Override | ||
public void spinForwards() { | ||
leftShooterMotor.set(1.0); | ||
} | ||
|
||
@Override | ||
public void spinBackwards() { | ||
leftShooterMotor.set(-1.0); | ||
} | ||
|
||
public double getLeftvelocity() { | ||
return leftShooterEncoder.getVelocity(); | ||
} | ||
|
||
public double getRightvelocity() { | ||
return rightShooterEncoder.getVelocity(); | ||
} | ||
|
||
@Override | ||
public void updateInputs(ShooterIOInputs inputs) { | ||
inputs.leftMotorVelocity = getLeftvelocity(); | ||
inputs.rightMotorVelocity = getRightvelocity(); | ||
} | ||
} |
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,3 @@ | ||
package frc.robot.subsystems.shooter; | ||
|
||
public class ShooterIOSim {} |