Skip to content

Commit 468e7c1

Browse files
Massive refactoring of Shooter into four different subsystems: ShooterWheel, Feeder, Hood, Turret, ShooterWheel
1 parent c8567fe commit 468e7c1

34 files changed

+206
-1013
lines changed

src/main/java/org/mayheminc/robot2020/RobotContainer.java

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ public class RobotContainer {
3333

3434
public static final Climber climber = new Climber();
3535
public static final Magazine magazine = new Magazine();
36-
public static final Shooter shooter = new Shooter();
36+
public static final ShooterWheel shooterWheel = new ShooterWheel();
37+
public static final Hood hood = new Hood();
38+
public static final Turret turret = new Turret();
39+
public static final Feeder feeder = new Feeder();
3740
public static final Drive drive = new Drive();
3841
public static final Intake intake = new Intake();
3942
public static final Autonomous autonomous = new Autonomous();
@@ -62,13 +65,13 @@ public RobotContainer() {
6265
pidtuner = new PidTuner(RobotContainer.DRIVER_STICK.DRIVER_STICK_ENA_BUTTON_SIX,
6366
RobotContainer.DRIVER_STICK.DRIVER_STICK_ENA_BUTTON_SEVEN,
6467
RobotContainer.DRIVER_STICK.DRIVER_STICK_ENA_BUTTON_ELEVEN,
65-
RobotContainer.DRIVER_STICK.DRIVER_STICK_ENA_BUTTON_TEN, shooter);
68+
RobotContainer.DRIVER_STICK.DRIVER_STICK_ENA_BUTTON_TEN, drive);
6669

6770
cameraLights.set(true);
6871
}
6972

7073
public static void init() {
71-
shooter.init();
74+
shooterWheel.init();
7275
}
7376

7477
private void configureDefaultCommands() {
@@ -84,7 +87,7 @@ private void configureDefaultCommands() {
8487
// which wants all the battery power available) would turn the compressor off when the command starts
8588
// and off when the command ends.) Then again, maybe the "defaultCommand" is a good way to do this
8689
// and I just don't understand the style yet.
87-
compressor.setDefaultCommand(new AirCompressorDefault());
90+
// compressor.setDefaultCommand(new AirCompressorDefault());
8891
}
8992

9093
private void configureAutonomousPrograms() {
@@ -93,7 +96,9 @@ private void configureAutonomousPrograms() {
9396
// TODO: fix so that auto program is shown not just when changed (as shows old setting sometimes)
9497

9598
// autonomousPrograms.push(/* 01 */ new StayStill());
99+
autonomousPrograms.push(/* 01 */ new DriveStraightOnly());
96100
autonomousPrograms.push(/* 00 */ new TrenchAuto());
101+
97102
// autonomousPrograms.push( new ShooterReadyAimFire());
98103
// autonomousPrograms.push(new TestTurret());
99104

@@ -155,8 +160,8 @@ private void configureDriverPadButtons() {
155160
// about -30 degrees
156161
// DRIVER_PAD.DRIVER_PAD_D_PAD_RIGHT.whileHeld(new
157162
// ShooterSetTurretVBus(+0.2));// about +30 degrees
158-
DRIVER_PAD.DRIVER_PAD_D_PAD_UP.whenPressed(new ShooterSetHoodAbs(Shooter.HOOD_INITIATION_LINE_POSITION));
159-
DRIVER_PAD.DRIVER_PAD_D_PAD_DOWN.whenPressed(new ShooterSetHoodAbs(Shooter.HOOD_TARGET_ZONE_POSITION));
163+
DRIVER_PAD.DRIVER_PAD_D_PAD_UP.whenPressed(new HoodSetAbs(Hood.HOOD_INITIATION_LINE_POSITION));
164+
DRIVER_PAD.DRIVER_PAD_D_PAD_DOWN.whenPressed(new HoodSetAbs(Hood.HOOD_TARGET_ZONE_POSITION));
160165

161166
// DRIVER_PAD.DRIVER_PAD_D_PAD_LEFT.whenPressed(new
162167
// ShooterSetTurretRel(-200.0));
@@ -173,13 +178,15 @@ private void configureDriverPadButtons() {
173178
// DRIVER_PAD.DRIVER_PAD_D_PAD_DOWN.whileHeld(new ShooterSetHoodVBus(-1.0));
174179

175180
// Debug shooter pid velocity
176-
DRIVER_PAD.DRIVER_PAD_BLUE_BUTTON.whenPressed(new ShooterAdjustWheel(100.0));
177-
DRIVER_PAD.DRIVER_PAD_GREEN_BUTTON.whenPressed(new ShooterAdjustWheel(-100.0));
178-
DRIVER_PAD.DRIVER_PAD_RED_BUTTON.whenPressed(new ShooterSetWheelVBus(0.0));
179-
DRIVER_PAD.DRIVER_PAD_YELLOW_BUTTON.whenPressed(new ShooterSetWheel(3000));
181+
DRIVER_PAD.DRIVER_PAD_BLUE_BUTTON.whenPressed(new ShooterWheelAdjust(100.0));
182+
DRIVER_PAD.DRIVER_PAD_GREEN_BUTTON.whenPressed(new ShooterWheelAdjust(-100.0));
183+
DRIVER_PAD.DRIVER_PAD_RED_BUTTON.whenPressed(new ShooterWheelSetVBus(0.0));
184+
DRIVER_PAD.DRIVER_PAD_YELLOW_BUTTON.whenPressed(new ShooterWheelSet(3000));
185+
186+
DRIVER_PAD.DRIVER_PAD_BACK_BUTTON.whileHeld(new DriveStraight(0.1));
180187
// TODO: above hard-coded constant (3000) should be a named constant from Shooter.java
181188

182-
DRIVER_PAD.DRIVER_PAD_LEFT_UPPER_TRIGGER_BUTTON.whileHeld(new ShooterSetFeeder(1.0));
189+
DRIVER_PAD.DRIVER_PAD_LEFT_UPPER_TRIGGER_BUTTON.whileHeld(new FeederSet(1.0));
183190

184191
}
185192

@@ -207,12 +214,11 @@ private void configureOperatorPadButtons() {
207214
// IntakeSetPosition(RobotContainer.intake.PIVOT_UP));
208215
// OPERATOR_PAD.OPERATOR_PAD_D_PAD_DOWN.whenPressed(new
209216
// IntakeSetPosition(RobotContainer.intake.PIVOT_DOWN));
210-
OPERATOR_PAD.OPERATOR_PAD_D_PAD_LEFT.whileHeld(new ShooterSetTurretVBus(-0.2));
211-
OPERATOR_PAD.OPERATOR_PAD_D_PAD_RIGHT.whileHeld(new ShooterSetTurretVBus(+0.2));
212-
OPERATOR_PAD.OPERATOR_PAD_D_PAD_UP.whileHeld(new ShooterAdjustHood(+1000.0));
213-
OPERATOR_PAD.OPERATOR_PAD_D_PAD_DOWN.whileHeld(new ShooterAdjustHood(-1000.0));
217+
OPERATOR_PAD.OPERATOR_PAD_D_PAD_LEFT.whileHeld(new TurretSetVBus(-0.2));
218+
OPERATOR_PAD.OPERATOR_PAD_D_PAD_RIGHT.whileHeld(new TurretSetVBus(+0.2));
219+
OPERATOR_PAD.OPERATOR_PAD_D_PAD_UP.whileHeld(new HoodAdjust(+1000.0));
220+
OPERATOR_PAD.OPERATOR_PAD_D_PAD_DOWN.whileHeld(new HoodAdjust(-1000.0));
214221

215-
// TODO: Consider if below should use "variable power" for climber or just always full speed?
216222
OPERATOR_PAD.OPERATOR_PAD_RIGHT_Y_AXIS_UP.whileHeld(new ClimberSetWinchesPower(1.0));
217223
OPERATOR_PAD.OPERATOR_PAD_RIGHT_Y_AXIS_DOWN.whileHeld(new ClimberSetWinchesPower(-1.0));
218224

src/main/java/org/mayheminc/robot2020/autonomousroutines/DriveStraight.java

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/main/java/org/mayheminc/robot2020/autonomousroutines/ShootAndDriveForward.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
package org.mayheminc.robot2020.autonomousroutines;
99

10-
import org.mayheminc.robot2020.commands.ShooterSetWheel;
10+
import org.mayheminc.robot2020.commands.ShooterWheelSet;
1111

1212
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
1313

@@ -23,7 +23,7 @@ public ShootAndDriveForward() {
2323
// super(new FooCommand(), new BarCommand());
2424
super();
2525

26-
addCommands(new ShooterSetWheel(5500));
26+
addCommands(new ShooterWheelSet(5500));
2727
// addCommands(new Wait(2.0));
2828
}
2929
}

src/main/java/org/mayheminc/robot2020/autonomousroutines/StayStill.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class StayStill extends SequentialCommandGroup {
1717
public StayStill() {
1818

1919
// Perform needed initialization
20-
addCommands(new DriveZeroGyro());
20+
addCommands(new DriveZeroGyro(0.0));
2121

2222
// ALL DONE!
2323
}

src/main/java/org/mayheminc/robot2020/autonomousroutines/TestTurret.java

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77

88
package org.mayheminc.robot2020.autonomousroutines;
99

10-
import org.mayheminc.robot2020.RobotContainer;
11-
import org.mayheminc.robot2020.commands.ShooterSetTurretAbs;
12-
import org.mayheminc.robot2020.commands.Wait;
13-
1410
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
1511

1612
// NOTE: Consider using this command inline, rather than writing a subclass. For more
@@ -25,37 +21,37 @@ public TestTurret() {
2521
// super(new FooCommand(), new BarCommand());
2622
super();
2723

28-
addRequirements(RobotContainer.shooter);
29-
30-
addCommands(new ShooterSetTurretAbs(-10));
31-
addCommands(new Wait(3));
32-
addCommands(new ShooterSetTurretAbs(0));
33-
addCommands(new Wait(3));
34-
35-
addCommands(new ShooterSetTurretAbs(10));
36-
addCommands(new Wait(3));
37-
addCommands(new ShooterSetTurretAbs(0));
38-
addCommands(new Wait(3));
39-
40-
addCommands(new ShooterSetTurretAbs(-20));
41-
addCommands(new Wait(3));
42-
addCommands(new ShooterSetTurretAbs(0));
43-
addCommands(new Wait(3));
44-
45-
addCommands(new ShooterSetTurretAbs(20));
46-
addCommands(new Wait(3));
47-
addCommands(new ShooterSetTurretAbs(0));
48-
addCommands(new Wait(3));
49-
50-
addCommands(new ShooterSetTurretAbs(-45));
51-
addCommands(new Wait(3));
52-
addCommands(new ShooterSetTurretAbs(0));
53-
addCommands(new Wait(3));
54-
55-
addCommands(new ShooterSetTurretAbs(45));
56-
addCommands(new Wait(3));
57-
addCommands(new ShooterSetTurretAbs(0));
58-
addCommands(new Wait(3));
24+
// addRequirements(RobotContainer.shooter);
25+
26+
// addCommands(new ShooterSetTurretAbs(-10));
27+
// addCommands(new Wait(3));
28+
// addCommands(new ShooterSetTurretAbs(0));
29+
// addCommands(new Wait(3));
30+
31+
// addCommands(new ShooterSetTurretAbs(10));
32+
// addCommands(new Wait(3));
33+
// addCommands(new ShooterSetTurretAbs(0));
34+
// addCommands(new Wait(3));
35+
36+
// addCommands(new ShooterSetTurretAbs(-20));
37+
// addCommands(new Wait(3));
38+
// addCommands(new ShooterSetTurretAbs(0));
39+
// addCommands(new Wait(3));
40+
41+
// addCommands(new ShooterSetTurretAbs(20));
42+
// addCommands(new Wait(3));
43+
// addCommands(new ShooterSetTurretAbs(0));
44+
// addCommands(new Wait(3));
45+
46+
// addCommands(new ShooterSetTurretAbs(-45));
47+
// addCommands(new Wait(3));
48+
// addCommands(new ShooterSetTurretAbs(0));
49+
// addCommands(new Wait(3));
50+
51+
// addCommands(new ShooterSetTurretAbs(45));
52+
// addCommands(new Wait(3));
53+
// addCommands(new ShooterSetTurretAbs(0));
54+
// addCommands(new Wait(3));
5955

6056
}
6157
}

src/main/java/org/mayheminc/robot2020/autonomousroutines/TrenchAuto.java

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import org.mayheminc.robot2020.RobotContainer;
1111
import org.mayheminc.robot2020.commands.*;
1212
import org.mayheminc.robot2020.commands.DriveStraightOnHeading.DistanceUnits;
13-
import org.mayheminc.robot2020.subsystems.Shooter;
13+
import org.mayheminc.robot2020.subsystems.Hood;
1414

1515
import edu.wpi.first.wpilibj2.command.*;
1616

@@ -20,30 +20,36 @@ public class TrenchAuto extends SequentialCommandGroup {
2020
*/
2121
public TrenchAuto() {
2222

23-
addCommands(new DriveZeroGyro());
23+
addCommands(new DriveZeroGyro(180.0));
2424
// first, shoot the balls that were pre-loaded
2525

2626
addCommands(new IntakeSetPositionWithoutWaiting(RobotContainer.intake.PIVOT_DOWN));
27-
addCommands(new ShooterReadyAimFire(3.0));
27+
addCommands(new TurretSetAbs(+23000.0));
28+
addCommands(new ShooterWheelSet(3000.0, false));
29+
addCommands(new Wait(2.0));
30+
addCommands(new ShooterReadyAimFire(2.5));
2831

29-
// then, perform a 3-point turn
30-
addCommands(new DriveStraightOnHeading(0.3, DistanceUnits.INCHES, 48, 160));
32+
// then, drive down the trench, jogging left a little
33+
addCommands(new DriveStraightOnHeading(0.3, DistanceUnits.INCHES, 36, 150));
3134

3235
// pick up balls while heading down the trench.
3336
addCommands(new ParallelRaceGroup(
3437
// intake while driving down the trench
3538
new IntakeSetRollers(-1.0),
36-
new SequentialCommandGroup(new DriveStraightOnHeading(0.2, DistanceUnits.INCHES, 132, 180),
37-
new Wait(0.5), new DriveStraightOnHeading(-0.2, DistanceUnits.INCHES, 12, 180))));
39+
new SequentialCommandGroup(new DriveStraightOnHeading(0.3, DistanceUnits.INCHES, 180, 180),
40+
new Wait(0.5), new DriveStraightOnHeading(-0.3, DistanceUnits.INCHES, 12, 180))));
3841

3942
// after getting all three balls, go back to shooting position
40-
addCommands(new DriveStraightOnHeading(-0.2, DistanceUnits.INCHES, 24, 30));
41-
addCommands(new DriveStraightOnHeading(0.3, DistanceUnits.INCHES, 120, 0));
42-
addCommands(new DriveStraightOnHeading(-0.1, DistanceUnits.INCHES, 6, 0));
43+
addCommands(new DriveStraightOnHeading(-0.3, DistanceUnits.INCHES, 48, 180));
44+
addCommands(new DriveStraightOnHeading(-0.3, DistanceUnits.INCHES, 96, 160));
45+
addCommands(new DriveStraightOnHeading(-0.3, DistanceUnits.INCHES, 24, 180));
46+
47+
addCommands(new ShooterReadyAimFire(6.0));
4348

4449
// turn the wheel off now that the shooting is all done
45-
addCommands(new ShooterSetWheel(0.0));
50+
addCommands(new ShooterWheelSet(0.0));
4651

47-
addCommands(new ShooterSetHoodAbs(Shooter.HOOD_TARGET_ZONE_POSITION));
52+
// turn the wheel off now that the shooting is all done
53+
addCommands(new HoodSetAbs(Hood.HOOD_TARGET_ZONE_POSITION));
4854
}
4955
}

src/main/java/org/mayheminc/robot2020/commands/DriveZeroGyro.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,19 @@
1111
*/
1212
public class DriveZeroGyro extends RobotDisabledCommand {
1313

14-
public DriveZeroGyro() {
14+
private double m_headingOffset = 0.0;
15+
16+
public DriveZeroGyro(double headingOffset) {
1517
// Use requires() here to declare subsystem dependencies
1618
// eg. requires(chassis);
1719
addRequirements(RobotContainer.drive);
20+
21+
m_headingOffset = headingOffset;
1822
}
1923

2024
// Called just before this Command runs the first time
2125
public void initialize() {
22-
RobotContainer.drive.zeroHeadingGyro(0.0);
26+
RobotContainer.drive.zeroHeadingGyro(m_headingOffset);
2327
}
2428

2529
// Make this return true when this Command no longer needs to run execute()

src/main/java/org/mayheminc/robot2020/commands/ShooterAdjustHood.java

Lines changed: 0 additions & 39 deletions
This file was deleted.

src/main/java/org/mayheminc/robot2020/commands/ShooterAdjustWheel.java

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)