-
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.
Merge pull request #1 from team422/Shooter
Shooter
- Loading branch information
Showing
13 changed files
with
284 additions
and
22 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
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
19 changes: 19 additions & 0 deletions
19
src/main/java/frc/robot/subsystems/shooter/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,19 @@ | ||
package frc.robot.subsystems.shooter; | ||
|
||
import org.littletonrobotics.junction.AutoLog; | ||
|
||
public interface FlywheelIO { | ||
@AutoLog | ||
public class FlywheelInputs { | ||
public double topVelocityRPS; | ||
public double topVoltage; | ||
public double topCurrentAmps; | ||
public double bottomVelocityRPS; | ||
public double bottomVoltage; | ||
public double bottomCurrentAmps; | ||
} | ||
|
||
public void setVoltage(double topVoltage, double bottomVoltage); | ||
|
||
public void updateInputs(FlywheelInputs inputs); | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/frc/robot/subsystems/shooter/FlywheelIONeo.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,35 @@ | ||
package frc.robot.subsystems.shooter; | ||
|
||
import com.revrobotics.CANSparkLowLevel.MotorType; | ||
import com.revrobotics.CANSparkMax; | ||
import com.revrobotics.RelativeEncoder; | ||
|
||
public class FlywheelIONeo implements FlywheelIO { | ||
private CANSparkMax m_topMotor; | ||
private CANSparkMax m_bottomMotor; | ||
private RelativeEncoder m_topEncoder; | ||
private RelativeEncoder m_bottomEncoder; | ||
|
||
public FlywheelIONeo(int topPort, int bottomPort) { | ||
m_topMotor = new CANSparkMax(topPort, MotorType.kBrushless); | ||
m_topEncoder = m_topMotor.getEncoder(); | ||
m_bottomMotor = new CANSparkMax(bottomPort, MotorType.kBrushless); | ||
m_bottomEncoder = m_bottomMotor.getEncoder(); | ||
} | ||
|
||
@Override | ||
public void setVoltage(double topVoltage, double bottomVoltage) { | ||
m_topMotor.setVoltage(topVoltage); | ||
m_bottomMotor.setVoltage(bottomVoltage); | ||
} | ||
|
||
@Override | ||
public void updateInputs(FlywheelInputs inputs) { | ||
inputs.topVelocityRPS = m_topEncoder.getVelocity() / 60; | ||
inputs.topVoltage = m_topMotor.getBusVoltage() * m_topMotor.getAppliedOutput(); | ||
inputs.topCurrentAmps = m_topMotor.getOutputCurrent(); | ||
inputs.bottomVelocityRPS = m_bottomEncoder.getVelocity() / 60; | ||
inputs.bottomVoltage = m_bottomMotor.getBusVoltage() * m_bottomMotor.getAppliedOutput(); | ||
inputs.bottomCurrentAmps = m_bottomMotor.getOutputCurrent(); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
src/main/java/frc/robot/subsystems/shooter/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,46 @@ | ||
package frc.robot.subsystems.shooter; | ||
|
||
import edu.wpi.first.wpilibj.simulation.FlywheelSim; | ||
import frc.robot.Constants.ShooterConstants; | ||
|
||
public class FlywheelIOSim implements FlywheelIO { | ||
private FlywheelSim m_topFlywheel; | ||
private FlywheelSim m_bottomFlywheel; | ||
private double m_topVoltage; | ||
private double m_bottomVoltage; | ||
|
||
public FlywheelIOSim() { | ||
m_topFlywheel = | ||
new FlywheelSim( | ||
ShooterConstants.kSimTopGearbox, | ||
ShooterConstants.kSimGearing, | ||
ShooterConstants.kSimMOI); | ||
m_bottomFlywheel = | ||
new FlywheelSim( | ||
ShooterConstants.kSimBottomGearbox, | ||
ShooterConstants.kSimGearing, | ||
ShooterConstants.kSimMOI); | ||
} | ||
|
||
@Override | ||
public void setVoltage(double topVoltage, double bottomVoltage) { | ||
m_topFlywheel.setInputVoltage(topVoltage); | ||
m_bottomFlywheel.setInputVoltage(bottomVoltage); | ||
|
||
m_topVoltage = topVoltage; | ||
m_bottomVoltage = bottomVoltage; | ||
} | ||
|
||
@Override | ||
public void updateInputs(FlywheelInputs inputs) { | ||
m_topFlywheel.update(.02); | ||
m_bottomFlywheel.update(.02); | ||
|
||
inputs.topVelocityRPS = m_topFlywheel.getAngularVelocityRPM() / 60; | ||
inputs.topVoltage = m_topVoltage; | ||
inputs.topCurrentAmps = m_topFlywheel.getCurrentDrawAmps(); | ||
inputs.bottomVelocityRPS = m_bottomFlywheel.getAngularVelocityRPM() / 60; | ||
inputs.bottomVoltage = m_bottomVoltage; | ||
inputs.bottomCurrentAmps = m_bottomFlywheel.getCurrentDrawAmps(); | ||
} | ||
} |
Oops, something went wrong.