Skip to content

Commit 397cd6a

Browse files
Refactored commands
This uses the Command Factory API to move most of the basic single-subsystem commands to their respective subsystems. I also implemented the "rush" auto (Rush reference) where we don't score preload and head straight for the center.
1 parent 5f1fea5 commit 397cd6a

34 files changed

Lines changed: 163 additions & 326 deletions

src/main/deploy/pathplanner/autos/PreloadDepotShootMiddle.auto renamed to src/main/deploy/pathplanner/autos/PreloadDepotShootCenter.auto

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@
77
{
88
"type": "path",
99
"data": {
10-
"pathName": "PreloadDepotShootMiddle1"
10+
"pathName": "PreloadDepotShootCenter1"
1111
}
1212
},
1313
{
1414
"type": "path",
1515
"data": {
16-
"pathName": "PreloadDepotShootMiddle2"
16+
"pathName": "PreloadDepotShootCenter2"
1717
}
1818
},
1919
{
2020
"type": "path",
2121
"data": {
22-
"pathName": "PreloadDepotShootMiddle3"
22+
"pathName": "PreloadDepotShootCenter3"
2323
}
2424
}
2525
]

src/main/deploy/pathplanner/paths/PreloadDepotShootMiddle1.path renamed to src/main/deploy/pathplanner/paths/PreloadDepotShootCenter1.path

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"rotation": 0.0
4646
},
4747
"reversed": false,
48-
"folder": "PreloadDepotShootMiddle",
48+
"folder": "PreloadDepotShootCenter",
4949
"idealStartingState": {
5050
"velocity": 0,
5151
"rotation": 0.0

src/main/deploy/pathplanner/paths/PreloadDepotShootMiddle2.path renamed to src/main/deploy/pathplanner/paths/PreloadDepotShootCenter2.path

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"rotation": 180.0
4646
},
4747
"reversed": false,
48-
"folder": "PreloadDepotShootMiddle",
48+
"folder": "PreloadDepotShootCenter",
4949
"idealStartingState": {
5050
"velocity": 0,
5151
"rotation": 0.0

src/main/deploy/pathplanner/paths/PreloadDepotShootMiddle3.path renamed to src/main/deploy/pathplanner/paths/PreloadDepotShootCenter3.path

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"rotation": 0.0
4646
},
4747
"reversed": false,
48-
"folder": "PreloadDepotShootMiddle",
48+
"folder": "PreloadDepotShootCenter",
4949
"idealStartingState": {
5050
"velocity": 0,
5151
"rotation": 180.0

src/main/deploy/pathplanner/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"holonomicMode": true,
55
"pathFolders": [
66
"PreloadCenter",
7-
"PreloadDepotShootMiddle",
7+
"PreloadDepotShootCenter",
88
"PreloadNeutralDepotClimb",
99
"PreloadNeutralShootClimb",
1010
"PreloadNeutralShootTwice"

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

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,19 @@
1616
import edu.wpi.first.wpilibj2.command.ParallelCommandGroup;
1717
import edu.wpi.first.wpilibj2.command.WaitCommand;
1818
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
19-
import frc.robot.commands.AutoAlignDrive;
20-
import frc.robot.commands.IntakeAll;
21-
import frc.robot.commands.ResetGyro;
19+
import frc.robot.commands.IntakeCommand;
20+
import frc.robot.commands.Shoot;
2221
import frc.robot.commands.UpdateLEDs;
2322
import frc.robot.commands.autos.*;
24-
import frc.robot.commands.intake.RunIntake;
25-
import frc.robot.commands.shooter.Shoot;
26-
import frc.robot.commands.shooter.ShootManualFlywheel;
23+
import frc.robot.commands.swerve.AutoAlignDrive;
24+
import frc.robot.commands.swerve.ResetGyro;
2725
import frc.robot.constants.FIELD;
2826
import frc.robot.constants.FLYWHEEL;
2927
import frc.robot.constants.INTAKE.ROLLERS.INTAKE_SPEED;
30-
import frc.robot.constants.SIM;
28+
import frc.robot.constants.ROBOT;
29+
import frc.robot.constants.ROBOT.SIM;
30+
import frc.robot.constants.ROBOT.USB;
3131
import frc.robot.constants.SWERVE;
32-
import frc.robot.constants.USB;
3332
import frc.robot.generated.V1Constants;
3433
import frc.robot.simulation.FuelSim;
3534
import frc.robot.simulation.Robot2d;
@@ -205,25 +204,27 @@ private void configureBindings() {
205204
}
206205

207206
if (m_flywheel != null) {
208-
m_driverController.y().whileTrue(new ShootManualFlywheel(m_flywheel));
207+
m_driverController.y().whileTrue(m_flywheel.manualCommand());
209208
}
210209

211210
// I foresee a state machine in the future...
212211
if (m_uptake != null && m_indexer != null && m_intake != null) {
213-
m_driverController.a().whileTrue(new IntakeAll(m_intake, m_intakePivot, m_indexer, m_uptake));
212+
m_driverController.a().whileTrue(new IntakeCommand(m_intake, m_intakePivot, m_indexer, m_uptake));
214213
}
215214

216215
if (m_intake != null) {
217-
m_driverController.leftTrigger().whileTrue(new RunIntake(m_intake, INTAKE_SPEED.INTAKING));
216+
m_driverController.leftTrigger().whileTrue(m_intake.command(INTAKE_SPEED.INTAKING));
218217
}
219218
}
220219

221220
private void initAutoChooser() {
222221
SmartDashboard.putData("Auto Mode", m_autoChooser);
223222
m_autoChooser.setDefaultOption("Do Nothing", new WaitCommand(0));
224223
m_autoChooser.addOption(
225-
"PreloadDepotShootMiddle",
226-
new PreloadDepotShootMiddle(
224+
"Auto 0 - PreloadCenter", new PreloadCenter(m_swerveDrive, m_intake, m_vision, m_flywheel, m_hood));
225+
m_autoChooser.addOption(
226+
"Auto 1 - PreloadDepotShootCenter",
227+
new PreloadDepotShootCenter(
227228
m_swerveDrive,
228229
m_intake,
229230
m_vision,
@@ -233,7 +234,7 @@ private void initAutoChooser() {
233234
m_indexer,
234235
m_uptake));
235236
m_autoChooser.addOption(
236-
"PreloadNeutralShootClimb",
237+
"Auto 2 - PreloadNeutralShootClimb",
237238
new PreloadNeutralShootClimb(
238239
m_swerveDrive,
239240
m_intake,
@@ -245,7 +246,7 @@ private void initAutoChooser() {
245246
m_uptake,
246247
() -> m_flipToRight));
247248
m_autoChooser.addOption(
248-
"PreloadNeutralDepotClimb",
249+
"Auto 3 - PreloadNeutralDepotClimb",
249250
new PreloadNeutralDepotClimb(
250251
m_swerveDrive,
251252
m_intake,
@@ -256,8 +257,8 @@ private void initAutoChooser() {
256257
m_indexer,
257258
m_uptake));
258259
m_autoChooser.addOption(
259-
"PreloadNeutralShootTwice",
260-
new PreloadNeutralShootTwice(
260+
"Auto 4 - PreloadNeutralShootTwice",
261+
new NeutralShootTwice(
261262
m_swerveDrive,
262263
m_intake,
263264
m_vision,
@@ -266,9 +267,21 @@ private void initAutoChooser() {
266267
m_intakePivot,
267268
m_indexer,
268269
m_uptake,
269-
() -> m_flipToRight));
270+
() -> m_flipToRight,
271+
false));
270272
m_autoChooser.addOption(
271-
"PreloadCenter", new PreloadCenter(m_swerveDrive, m_intake, m_vision, m_flywheel, m_hood));
273+
"Auto 5 - NeutralShootTwice - NO PRELOAD",
274+
new NeutralShootTwice(
275+
m_swerveDrive,
276+
m_intake,
277+
m_vision,
278+
m_flywheel,
279+
m_hood,
280+
m_intakePivot,
281+
m_indexer,
282+
m_uptake,
283+
() -> m_flipToRight,
284+
true));
272285
}
273286

274287
private void initSideChooser() {

src/main/java/frc/robot/commands/Climb.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package frc.robot.commands;
22

33
import edu.wpi.first.wpilibj2.command.Command;
4-
import frc.robot.Constants.CLIMBER.*;
4+
import frc.robot.constants.CLIMBER.*;
55
import frc.robot.subsystems.Climber;
66

77
public class Climb extends Command {

src/main/java/frc/robot/commands/IntakeAll.java

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright (c) FIRST and other WPILib contributors.
2+
// Open Source Software; you can modify and/or share it under the terms of
3+
// the WPILib BSD license file in the root directory of this project.
4+
5+
package frc.robot.commands;
6+
7+
import edu.wpi.first.wpilibj2.command.ParallelCommandGroup;
8+
import frc.robot.constants.INDEXER.INDEXER_SPEED;
9+
import frc.robot.constants.UPTAKE.UPTAKE_SPEED;
10+
import frc.robot.constants.INTAKE;
11+
import frc.robot.subsystems.Indexer;
12+
import frc.robot.subsystems.Intake;
13+
import frc.robot.subsystems.IntakePivot;
14+
import frc.robot.subsystems.Uptake;
15+
16+
public class IntakeCommand extends ParallelCommandGroup {
17+
/** Creates a new IntakeAll. */
18+
public IntakeCommand(Intake intake, IntakePivot intakePivot, Indexer indexer, Uptake uptake) {
19+
addCommands(
20+
intake.command(INTAKE.ROLLERS.INTAKE_SPEED.INTAKING),
21+
indexer.command(INDEXER_SPEED.INDEXING, INDEXER_SPEED.INDEXING),
22+
uptake.command(UPTAKE_SPEED.UPTAKING),
23+
intakePivot.command(INTAKE.PIVOT.PIVOT_SETPOINT.INTAKING));
24+
}
25+
}

src/main/java/frc/robot/commands/shooter/Shoot.java renamed to src/main/java/frc/robot/commands/Shoot.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package frc.robot.commands.shooter;
1+
package frc.robot.commands;
22

33
import static edu.wpi.first.units.Units.Meters;
44
import static edu.wpi.first.units.Units.RPM;
@@ -47,7 +47,8 @@ public class Shoot extends Command {
4747

4848
private final Flywheel m_flywheel;
4949
private final Vision m_vision;
50-
50+
51+
@SuppressWarnings("unused")
5152
private final Hood m_shooterHood;
5253

5354
Translation2d m_goal = new Translation2d();

0 commit comments

Comments
 (0)