|
1 | | -// package frc.robot.Subsystems.Hopper; |
2 | | - |
3 | | -// import static edu.wpi.first.units.Units.RotationsPerSecond; |
4 | | - |
5 | | -// import com.ctre.phoenix6.sim.TalonFXSimState; |
6 | | -// import edu.wpi.first.math.system.plant.DCMotor; |
7 | | -// import edu.wpi.first.math.system.plant.LinearSystemId; |
8 | | -// import edu.wpi.first.wpilibj.simulation.DCMotorSim; |
9 | | -// import frc.robot.Subsystems.Hopper.HopperConstants.Sim; |
10 | | - |
11 | | -// public class HopperIOSim extends HopperIOReal { |
12 | | - |
13 | | -// private final TalonFXSimState spindexerSimState; |
14 | | -// private final TalonFXSimState kickerSimState; |
15 | | -// private final DCMotorSim spindexerSim; |
16 | | -// private final DCMotorSim kickerSim; |
17 | | - |
18 | | -// double targetSpinVelocity; |
19 | | -// double targetKickVelocity; |
20 | | - |
21 | | -// public HopperIOSim() { |
22 | | -// spindexerSimState = new TalonFXSimState(spindexerMotor); |
23 | | -// spindexerSim = new DCMotorSim(LinearSystemId.createDCMotorSystem(DCMotor.getFalcon500(1), Sim.MOTOR_MOI, 1), DCMotor.getFalcon500(1)); |
24 | | - |
25 | | -// kickerSimState = new TalonFXSimState(kickerMotor); |
26 | | -// kickerSim = new DCMotorSim(LinearSystemId.createDCMotorSystem(DCMotor.getFalcon500(1), Sim.MOTOR_MOI, 1), DCMotor.getFalcon500(1)); |
27 | | -// } |
28 | | - |
29 | | -// @Override |
30 | | -// public void updateOutputs(HopperIOOutputs outputs) { |
31 | | -// outputs.spinVelocityRPS = spindexerSim.getAngularVelocity().in(RotationsPerSecond); |
32 | | -// outputs.targetSpinVelocity = targetSpinVelocity; |
33 | | -// outputs.targetKickVelocity = targetKickVelocity; |
34 | | -// outputs.kickVelocityRPS = kickerSim.getAngularVelocity().in(RotationsPerSecond); |
35 | | - |
36 | | -// spindexerSimState.setRotorVelocity(spindexerSim.getAngularVelocity()); |
37 | | -// kickerSimState.setRotorVelocity(kickerSim.getAngularVelocity()); |
38 | | -// } |
39 | | - |
40 | | -// @Override |
41 | | -// public void setTargetSpinVelocity(double targetSpinVelocity) { |
42 | | -// this.targetSpinVelocity = targetSpinVelocity; |
43 | | -// spindexerMotor.set(targetSpinVelocity); |
44 | | -// } |
45 | | - |
46 | | -// @Override |
47 | | -// public void setTargetKickVelocity(double targetKickVelocity) { |
48 | | -// this.targetKickVelocity = targetKickVelocity; |
49 | | -// kickerMotor.set(targetKickVelocity); |
50 | | -// } |
51 | | -// } |
| 1 | +package frc.robot.Subsystems.Hopper; |
| 2 | + |
| 3 | +import static edu.wpi.first.units.Units.RotationsPerSecond; |
| 4 | + |
| 5 | +import com.ctre.phoenix6.sim.TalonFXSimState; |
| 6 | +import edu.wpi.first.math.system.plant.DCMotor; |
| 7 | +import edu.wpi.first.math.system.plant.LinearSystemId; |
| 8 | +import edu.wpi.first.wpilibj.simulation.DCMotorSim; |
| 9 | +import frc.robot.Subsystems.Hopper.HopperConstants.Sim; |
| 10 | + |
| 11 | +public class HopperIOSim extends HopperIOReal { |
| 12 | + |
| 13 | + private final TalonFXSimState spindexerSimState; |
| 14 | + private final TalonFXSimState kickerSimState; |
| 15 | + private final DCMotorSim spindexerSim; |
| 16 | + private final DCMotorSim kickerSim; |
| 17 | + |
| 18 | + double targetSpinVelocity; |
| 19 | + double targetKickerVelocity; |
| 20 | + double targetKickerVelocity2; |
| 21 | + |
| 22 | + public HopperIOSim() { |
| 23 | + spindexerSimState = new TalonFXSimState(spindexerMotor); |
| 24 | + spindexerSim = new DCMotorSim(LinearSystemId.createDCMotorSystem(DCMotor.getFalcon500(1), Sim.MOTOR_MOI, 1), DCMotor.getFalcon500(1)); |
| 25 | + |
| 26 | + kickerSimState = new TalonFXSimState(kickerMotor); |
| 27 | + kickerSim = new DCMotorSim(LinearSystemId.createDCMotorSystem(DCMotor.getFalcon500(1), Sim.MOTOR_MOI, 1), DCMotor.getFalcon500(1)); |
| 28 | + } |
| 29 | + |
| 30 | + @Override |
| 31 | + public void updateOutputs(HopperIOOutputs outputs) { |
| 32 | + outputs.spinVelocityRPS = spindexerSim.getAngularVelocity().in(RotationsPerSecond); |
| 33 | + outputs.kickVelocityRPS = kickerSim.getAngularVelocity().in(RotationsPerSecond); |
| 34 | + outputs.targetSpinVelocity = targetSpinVelocity; |
| 35 | + outputs.targetKickVelocity = targetKickerVelocity; |
| 36 | + |
| 37 | + spindexerSimState.setRotorVelocity(spindexerSim.getAngularVelocity()); |
| 38 | + kickerSimState.setRotorVelocity(kickerSim.getAngularVelocity()); |
| 39 | + } |
| 40 | + |
| 41 | + @Override |
| 42 | + public void setTargetSpinVelocity(double targetSpinVelocity) { |
| 43 | + this.targetSpinVelocity = targetSpinVelocity; |
| 44 | + spindexerMotor.set(targetSpinVelocity); |
| 45 | + } |
| 46 | + |
| 47 | + @Override |
| 48 | + public void setTargetKickerVelocity(double velocity) { |
| 49 | + this.targetKickerVelocity = velocity; |
| 50 | + kickerMotor.set(targetKickerVelocity); |
| 51 | + } |
| 52 | +} |
0 commit comments