Skip to content

Commit d0f119e

Browse files
Some More Fixes Made
Some More Fixes Made
1 parent d78826c commit d0f119e

10 files changed

Lines changed: 527 additions & 534 deletions

src/main/java/frc/robot/RobotContainer.java

Lines changed: 4 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@
8989
import frc.robot.subsystems.pivot.PivotIOTalonFX;
9090
import frc.robot.subsystems.shooter.DistanceSensorIO;
9191
import frc.robot.subsystems.shooter.DistanceSensorIOAnalog;
92-
import frc.robot.subsystems.shooter.FeederIOSim;
92+
//import frc.robot.subsystems.shooter.FeederIOSim;
9393
import frc.robot.subsystems.shooter.FeederIOTalonFX;
94-
import frc.robot.subsystems.shooter.FlywheelIOSim;
94+
//import frc.robot.subsystems.shooter.FlywheelIOSim;
9595
import frc.robot.subsystems.shooter.FlywheelIOTalonFX;
9696
import frc.robot.subsystems.shooter.LeafBlowerIO;
9797
import frc.robot.subsystems.shooter.LeafBlowerIOTalonSRX;
@@ -191,46 +191,7 @@ public RobotContainer() {
191191
RobotMap.PivotIDs.LEFT, RobotMap.PivotIDs.RIGHT, RobotMap.PivotIDs.GYRO));
192192
led = new LED(new LED_IOCANdle(20, Constants.CANBUS));
193193
break;
194-
case REPLAY:
195-
drive =
196-
new Drive(
197-
new GyroIO() {},
198-
new VisionIO() {},
199-
new ModuleIOSim(),
200-
new ModuleIOSim(),
201-
new ModuleIOSim(),
202-
new ModuleIOSim());
203-
intake = new Intake(new IntakeRollerIOSim());
204-
shooter =
205-
new Shooter(
206-
new FlywheelIOSim(),
207-
new FeederIOSim(),
208-
new DistanceSensorIO() {},
209-
new LeafBlowerIO() {});
210-
elevator = new Elevator(new ElevatorIOSim(), null);
211-
pivot = new Pivot(new PivotIOSim());
212-
led = new LED(new LED_IOSim());
213-
break;
214-
case SIM:
215-
drive =
216-
new Drive(
217-
new GyroIO() {},
218-
new VisionIO() {},
219-
new ModuleIOSim(),
220-
new ModuleIOSim(),
221-
new ModuleIOSim(),
222-
new ModuleIOSim());
223-
intake = new Intake(new IntakeRollerIOSim());
224-
shooter =
225-
new Shooter(
226-
new FlywheelIOSim(),
227-
new FeederIOSim(),
228-
new DistanceSensorIO() {},
229-
new LeafBlowerIO() {});
230-
elevator = new Elevator(new ElevatorIOSim(), new AmpBarIOSIm());
231-
pivot = new Pivot(new PivotIOSim());
232-
led = new LED(new LED_IOSim());
233-
break;
194+
234195

235196
default:
236197
// Replayed robot, disable IO implementations
@@ -401,21 +362,7 @@ public RobotContainer() {
401362
() -> intake.runRollers(Constants.IntakeConstants.APPLIED_VOLTAGE), intake));
402363

403364
// NOTE ALIGNMENT NAMED COMMANDS
404-
NamedCommands.registerCommand(
405-
"AlignToNote",
406-
new AlignToNoteAuto(led, drive, shooter, intake, pivot)
407-
.until(
408-
() ->
409-
shooter.seesNote() == NoteState.SENSOR
410-
|| shooter.seesNote() == NoteState.CURRENT)
411-
// TODO:: adjust this delay
412-
.andThen(new InstantCommand(drive::stop))
413-
.andThen(new InstantCommand(() -> shooter.setFeedersRPM(500)))
414-
.andThen(new WaitCommand(0.15))
415-
.andThen(
416-
new InstantCommand(() -> intake.stopRollers())
417-
.andThen(new InstantCommand(() -> shooter.stopFeeders())))
418-
.withTimeout(1.7));
365+
419366

420367
NamedCommands.registerCommand("C5", new InstantCommand(() -> drive.setNote(NOTE_POSITIONS.C5)));
421368
NamedCommands.registerCommand("C4", new InstantCommand(() -> drive.setNote(NOTE_POSITIONS.C4)));
Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,70 @@
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.
1313

14-
package frc.robot.subsystems.drive;
14+
// package frc.robot.subsystems.drive;
1515

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()
2323

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 {
3232

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);
3535

3636

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;
4040

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);
4545

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())};
5050

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+
// }
5858

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+
// }
6464

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+
// }
Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
1-
package frc.robot.subsystems.intake;
2-
3-
import edu.wpi.first.math.MathUtil;
4-
import edu.wpi.first.math.controller.PIDController;
5-
import edu.wpi.first.math.system.plant.DCMotor;
6-
import edu.wpi.first.units.measure.Voltage;
7-
import edu.wpi.first.wpilibj.simulation.DCMotorSim;
8-
import frc.robot.Constants;
9-
10-
public class IntakeRollerIOSim implements IntakeRollerIO {
11-
private final DCMotor simGearbox = DCMotor.getNeoVortex(1);
12-
private DCMotorSim sim = new DCMotorSim(simGearbox, 0.33, 0.1);
13-
14-
;
15-
private PIDController pid = new PIDController(0.2, 0, 0);
16-
17-
private boolean closedLoop = false;
18-
private double volts;
19-
private double appliedVolts;
20-
21-
@Override
22-
public void updateInputs(IntakeRollerIOInputs inputs) {
23-
if (closedLoop) {
24-
appliedVolts =
25-
MathUtil.clamp(pid.calculate(sim.getAngularVelocityRPM()) + volts, -12.0, 12.0);
26-
sim.setInputVoltage(appliedVolts);
27-
}
28-
29-
sim.update(Constants.LOOP_PERIOD_SECS);
30-
31-
inputs.rollerRotations = sim.getAngularPositionRotations();
32-
inputs.rollerVelocityRPM = sim.getAngularVelocityRPM();
33-
inputs.appliedVolts = appliedVolts;
34-
inputs.currentAmps = sim.getCurrentDrawAmps();
35-
}
36-
37-
@Override
38-
public void setVoltage(double volts) {
39-
closedLoop = false;
40-
this.volts = volts;
41-
}
42-
43-
@Override
44-
public void stop() {
45-
closedLoop = false;
46-
setVoltage(0);
47-
}
48-
}
1+
// package frc.robot.subsystems.intake;
2+
3+
// import edu.wpi.first.math.MathUtil;
4+
// import edu.wpi.first.math.controller.PIDController;
5+
// import edu.wpi.first.math.system.plant.DCMotor;
6+
// import edu.wpi.first.units.measure.Voltage;
7+
// import edu.wpi.first.wpilibj.simulation.DCMotorSim;
8+
// import frc.robot.Constants;
9+
10+
// public class IntakeRollerIOSim implements IntakeRollerIO {
11+
// private final DCMotor simGearbox = DCMotor.getNeoVortex(1);
12+
// private DCMotorSim sim = new DCMotorSim(simGearbox, 0.33, 0.1);
13+
14+
// ;
15+
// private PIDController pid = new PIDController(0.2, 0, 0);
16+
17+
// private boolean closedLoop = false;
18+
// private double volts;
19+
// private double appliedVolts;
20+
21+
// @Override
22+
// public void updateInputs(IntakeRollerIOInputs inputs) {
23+
// if (closedLoop) {
24+
// appliedVolts =
25+
// MathUtil.clamp(pid.calculate(sim.getAngularVelocityRPM()) + volts, -12.0, 12.0);
26+
// sim.setInputVoltage(appliedVolts);
27+
// }
28+
29+
// sim.update(Constants.LOOP_PERIOD_SECS);
30+
31+
// inputs.rollerRotations = sim.getAngularPositionRotations();
32+
// inputs.rollerVelocityRPM = sim.getAngularVelocityRPM();
33+
// inputs.appliedVolts = appliedVolts;
34+
// inputs.currentAmps = sim.getCurrentDrawAmps();
35+
// }
36+
37+
// @Override
38+
// public void setVoltage(double volts) {
39+
// closedLoop = false;
40+
// this.volts = volts;
41+
// }
42+
43+
// @Override
44+
// public void stop() {
45+
// closedLoop = false;
46+
// setVoltage(0);
47+
// }
48+
// }

src/main/java/frc/robot/subsystems/intake/IntakeRollerIOSparkFlex.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,27 @@
44
import com.revrobotics.spark.SparkLowLevel.MotorType;
55
import com.revrobotics.spark.SparkMax;
66
import com.revrobotics.spark.SparkClosedLoopController;
7+
import com.revrobotics.spark.config.SparkMaxConfig;
8+
import com.revrobotics.spark.SparkClosedLoopController.ArbFFUnits;
9+
import com.revrobotics.spark.SparkBase.PersistMode;
10+
import com.revrobotics.spark.SparkBase.ResetMode;
711

12+
813
import frc.robot.Constants;
914

1015
public class IntakeRollerIOSparkFlex implements IntakeRollerIO {
11-
private final SparkFlex rollers;
16+
private final SparkMax rollers;
1217

1318
public IntakeRollerIOSparkFlex(int id) {
1419
SparkMax rollers = new SparkMax(id, MotorType.kBrushless);
1520
SparkClosedLoopController pid = rollers.getClosedLoopController();
1621

1722

1823

19-
20-
rollers.setSmartCurrentLimit(Constants.IntakeConstants.CURRENT_LIMIT);
24+
rollers.setSmart(5);
2125
rollers.setCANTimeout(250);
22-
23-
rollers.SparkBase.PersistenMode.kPersistentParameters();
26+
SparkMaxConfig.
27+
rollers.burnFlash();
2428
}
2529

2630
@Override

0 commit comments

Comments
 (0)