|
1 | | -// Copyright 2021-2024 FRC 6328 |
2 | | -// http://github.com/Mechanical-Advantage |
3 | | -// |
4 | | -// This program is free software; you can redistribute it and/or |
5 | | -// modify it under the terms of the GNU General Public License |
6 | | -// version 3 as published by the Free Software Foundation or |
7 | | -// available in the root directory of this project. |
8 | | -// |
9 | | -// This program is distributed in the hope that it will be useful, |
10 | | -// but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | | -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | | -// GNU General Public License for more details. |
| 1 | +// // Copyright 2021-2024 FRC 6328 |
| 2 | +// // http://github.com/Mechanical-Advantage |
| 3 | +// // |
| 4 | +// // This program is free software; you can redistribute it and/or |
| 5 | +// // modify it under the terms of the GNU General Public License |
| 6 | +// // version 3 as published by the Free Software Foundation or |
| 7 | +// // available in the root directory of this project. |
| 8 | +// // |
| 9 | +// // This program is distributed in the hope that it will be useful, |
| 10 | +// // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | +// // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | +// // GNU General Public License for more details. |
13 | 13 |
|
14 | | -package frc.robot.subsystems.drive; |
| 14 | +// package frc.robot.subsystems.drive; |
15 | 15 |
|
16 | | -import edu.wpi.first.math.MathUtil; |
17 | | -import edu.wpi.first.math.geometry.Rotation2d; |
18 | | -import edu.wpi.first.math.system.plant.DCMotor; |
19 | | -import edu.wpi.first.wpilibj.simulation.DCMotorSim; |
20 | | -import frc.robot.Constants; |
21 | | -import edu.wpi.first.units.Units; |
22 | | -import edu.wpi.first.units.Measure; // You may need this, or just rely on Measures.of() |
| 16 | +// import edu.wpi.first.math.MathUtil; |
| 17 | +// import edu.wpi.first.math.geometry.Rotation2d; |
| 18 | +// import edu.wpi.first.math.system.plant.DCMotor; |
| 19 | +// import edu.wpi.first.wpilibj.simulation.DCMotorSim; |
| 20 | +// import frc.robot.Constants; |
| 21 | +// import edu.wpi.first.units.Units; |
| 22 | +// import edu.wpi.first.units.Measure; // You may need this, or just rely on Measures.of() |
23 | 23 |
|
24 | | -/** |
25 | | - * Physics sim implementation of module IO. |
26 | | - * |
27 | | - * <p>Uses two flywheel sims for the drive and turn motors, with the absolute position initialized |
28 | | - * to a random value. The flywheel sims are not physically accurate, but provide a decent |
29 | | - * approximation for the behavior of the module. |
30 | | - */ |
31 | | -public class ModuleIOSim implements ModuleIO { |
| 24 | +// /** |
| 25 | +// * Physics sim implementation of module IO. |
| 26 | +// * |
| 27 | +// * <p>Uses two flywheel sims for the drive and turn motors, with the absolute position initialized |
| 28 | +// * to a random value. The flywheel sims are not physically accurate, but provide a decent |
| 29 | +// * approximation for the behavior of the module. |
| 30 | +// */ |
| 31 | +// public class ModuleIOSim implements ModuleIO { |
32 | 32 |
|
33 | | - private DCMotorSim driveSim = new DCMotorSim(DCMotor.getNEO(1), 150.0 / 7.0, 0.004); |
34 | | - private DCMotorSim turnSim = new DCMotorSim(DCMotor.getNEO(1), 150.0 / 7.0, 0.004); |
| 33 | +// private DCMotorSim driveSim = new DCMotorSim(DCMotor.getNEO(1), 150.0 / 7.0, 0.004); |
| 34 | +// private DCMotorSim turnSim = new DCMotorSim(DCMotor.getNEO(1), 150.0 / 7.0, 0.004); |
35 | 35 |
|
36 | 36 |
|
37 | | - private final Rotation2d turnAbsoluteInitPosition = new Rotation2d(Math.random() * 2.0 * Math.PI); |
38 | | - private double driveAppliedVolts = 0.0; |
39 | | - private double turnAppliedVolts = 0.0; |
| 37 | +// private final Rotation2d turnAbsoluteInitPosition = new Rotation2d(Math.random() * 2.0 * Math.PI); |
| 38 | +// private double driveAppliedVolts = 0.0; |
| 39 | +// private double turnAppliedVolts = 0.0; |
40 | 40 |
|
41 | | - @Override |
42 | | - public void updateInputs(ModuleIOInputs inputs) { |
43 | | - driveSim.update(Constants.LOOP_PERIOD_SECS); |
44 | | - turnSim.update(Constants.LOOP_PERIOD_SECS); |
| 41 | +// @Override |
| 42 | +// public void updateInputs(ModuleIOInputs inputs) { |
| 43 | +// driveSim.update(Constants.LOOP_PERIOD_SECS); |
| 44 | +// turnSim.update(Constants.LOOP_PERIOD_SECS); |
45 | 45 |
|
46 | | - inputs.drivePositionRad = driveSim.getAngularPositionRad(); |
47 | | - inputs.driveVelocityRadPerSec = driveSim.getAngularVelocityRadPerSec(); |
48 | | - inputs.driveAppliedVolts = driveAppliedVolts; |
49 | | - inputs.driveCurrentAmps = new double[] {Math.abs(driveSim.getCurrentDrawAmps())}; |
| 46 | +// inputs.drivePositionRad = driveSim.getAngularPositionRad(); |
| 47 | +// inputs.driveVelocityRadPerSec = driveSim.getAngularVelocityRadPerSec(); |
| 48 | +// inputs.driveAppliedVolts = driveAppliedVolts; |
| 49 | +// inputs.driveCurrentAmps = new double[] {Math.abs(driveSim.getCurrentDrawAmps())}; |
50 | 50 |
|
51 | | - inputs.turnAbsolutePosition = |
52 | | - new Rotation2d(turnSim.getAngularPositionRad()).plus(turnAbsoluteInitPosition); |
53 | | - inputs.turnPosition = new Rotation2d(turnSim.getAngularPositionRad()); |
54 | | - inputs.turnVelocityRadPerSec = turnSim.getAngularVelocityRadPerSec(); |
55 | | - inputs.turnAppliedVolts = turnAppliedVolts; |
56 | | - inputs.turnCurrentAmps = new double[] {Math.abs(turnSim.getCurrentDrawAmps())}; |
57 | | - } |
| 51 | +// inputs.turnAbsolutePosition = |
| 52 | +// new Rotation2d(turnSim.getAngularPositionRad()).plus(turnAbsoluteInitPosition); |
| 53 | +// inputs.turnPosition = new Rotation2d(turnSim.getAngularPositionRad()); |
| 54 | +// inputs.turnVelocityRadPerSec = turnSim.getAngularVelocityRadPerSec(); |
| 55 | +// inputs.turnAppliedVolts = turnAppliedVolts; |
| 56 | +// inputs.turnCurrentAmps = new double[] {Math.abs(turnSim.getCurrentDrawAmps())}; |
| 57 | +// } |
58 | 58 |
|
59 | | - @Override |
60 | | - public void setDriveVoltage(double volts) { |
61 | | - driveAppliedVolts = MathUtil.clamp(volts, -12.0, 12.0); |
62 | | - driveSim.setInputVoltage(driveAppliedVolts); |
63 | | - } |
| 59 | +// @Override |
| 60 | +// public void setDriveVoltage(double volts) { |
| 61 | +// driveAppliedVolts = MathUtil.clamp(volts, -12.0, 12.0); |
| 62 | +// driveSim.setInputVoltage(driveAppliedVolts); |
| 63 | +// } |
64 | 64 |
|
65 | | - @Override |
66 | | - public void setTurnVoltage(double volts) { |
67 | | - turnAppliedVolts = MathUtil.clamp(volts, -12.0, 12.0); |
68 | | - turnSim.setInputVoltage(turnAppliedVolts); |
69 | | - } |
70 | | -} |
| 65 | +// @Override |
| 66 | +// public void setTurnVoltage(double volts) { |
| 67 | +// turnAppliedVolts = MathUtil.clamp(volts, -12.0, 12.0); |
| 68 | +// turnSim.setInputVoltage(turnAppliedVolts); |
| 69 | +// } |
| 70 | +// } |
0 commit comments