Skip to content

Commit 16586cd

Browse files
Merge branch 'main' into 25-map-states-to-buttons
2 parents 83156df + 7bc5a19 commit 16586cd

22 files changed

Lines changed: 288 additions & 231 deletions

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

Lines changed: 64 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
import frc.robot.DeviceIDs.controllerIDs;
2323
import frc.robot.commands.AddVisionMeasurement;
2424
import frc.robot.commands.ResetPose;
25-
import frc.robot.commands.states.Intaking;
26-
import frc.robot.commands.states.RetractIntake;
27-
import frc.robot.commands.states.Shooting;
2825
import frc.robot.constants.ConstSystem;
2926
import frc.robot.constants.ConstSystem.constControllers;
3027
import frc.robot.subsystems.DriverStateMachine;
@@ -59,16 +56,48 @@ public class RobotContainer {
5956
private final StateMachine loggedStateMachineInstance = stateMachineInstance;
6057
public static final RobotPoses robotPose = new RobotPoses();
6158
private final RobotPoses loggedRobotPose = robotPose;
62-
public static final Intaking intaking = new Intaking();
63-
public static final RetractIntake retracting = new RetractIntake();
59+
6460
public static final Vision visionInstance = new Vision();
6561
private final Vision loggedVisionInstance = visionInstance;
6662
public static final Telemetry telemetryInstance = new Telemetry();
6763
private final Telemetry loggedTelemetryInstance = telemetryInstance;
68-
public static final Shooting shooting = new Shooting();
6964
public static final ResetPose resetPose = new ResetPose();
70-
Command TRY_NONE = Commands.deferredProxy(
71-
() -> stateMachineInstance.tryState(RobotState.NONE));
65+
66+
Command TRY_INTAKING = Commands.deferredProxy(
67+
() -> stateMachineInstance.tryState(RobotState.INTAKING));
68+
69+
Command TRY_SHOOTING = Commands.deferredProxy(
70+
() -> stateMachineInstance.tryState(RobotState.SHOOTING));
71+
72+
Command TRY_EJECTING_HOPPER = Commands.deferredProxy(
73+
() -> stateMachineInstance.tryState(RobotState.EJECTING_HOPPER));
74+
75+
Command TRY_REVERSING_SHOOTER = Commands.deferredProxy(
76+
() -> stateMachineInstance.tryState(RobotState.REVERSING_SHOOTER));
77+
78+
Command TRY_PREPANYWHERE = Commands.deferredProxy(
79+
() -> stateMachineInstance.tryState(RobotState.PREP_ANYWHERE));
80+
81+
Command TRY_PREPTRENCH = Commands.deferredProxy(
82+
() -> stateMachineInstance.tryState(RobotState.PREP_TRENCH));
83+
84+
Command TRY_PREPNEAUTRALTOALLIANCE = Commands.deferredProxy(
85+
() -> stateMachineInstance.tryState(RobotState.PREP_NEUTRAL_TO_ALLIANCE));
86+
87+
Command TRY_PREPOPPONENTOALLIANCE = Commands.deferredProxy(
88+
() -> stateMachineInstance.tryState(RobotState.PREP_OPPONENT_TO_ALLIANCE));
89+
90+
Command TRY_PREPTOWER = Commands.deferredProxy(
91+
() -> stateMachineInstance.tryState(RobotState.PREP_TOWER));
92+
93+
Command TRY_PREPHUB = Commands.deferredProxy(
94+
() -> stateMachineInstance.tryState(RobotState.PREP_HUB));
95+
96+
Command TRY_PREPCORNER = Commands.deferredProxy(
97+
() -> stateMachineInstance.tryState(RobotState.PREP_CORNER));
98+
99+
Command TRY_RETRACTING = Commands.deferredProxy(
100+
() -> stateMachineInstance.tryState(RobotState.PREP_CORNER));
72101

73102
Command MANUAL = new DeferredCommand(
74103
driverStateMachineInstance.tryState(
@@ -102,16 +131,36 @@ public RobotContainer() {
102131
}
103132

104133
private void configDriverBindings() {
134+
conDriver.btn_LeftTrigger
135+
.whileTrue(TRY_INTAKING);
136+
conDriver.btn_RightStick
137+
.onTrue(TRY_RETRACTING);
138+
conDriver.btn_South
139+
.whileTrue(TRY_EJECTING_HOPPER);
140+
conDriver.btn_East
141+
.whileTrue(TRY_REVERSING_SHOOTER);
142+
conDriver.btn_West
143+
.onTrue(TRY_PREPNEAUTRALTOALLIANCE);
144+
conDriver.btn_LeftStick
145+
.onTrue(TRY_PREPOPPONENTOALLIANCE);
105146
conDriver.btn_RightTrigger
106-
.whileTrue(intaking);
147+
.whileTrue(TRY_SHOOTING);
148+
conDriver.btn_A
149+
.onTrue(TRY_PREPTRENCH);
150+
conDriver.btn_B
151+
.onTrue(TRY_PREPCORNER);
152+
conDriver.btn_X
153+
.onTrue(TRY_PREPTOWER);
154+
conDriver.btn_Y
155+
.onTrue(TRY_PREPHUB);
107156
conDriver.btn_RightBumper
108-
.whileTrue(retracting);
157+
.onTrue(TRY_PREPANYWHERE);
158+
109159
// Example Pose Drive
110-
conDriver.btn_X
111-
.whileTrue(EXAMPLE_POSE_DRIVE)
112-
.onFalse(Commands.runOnce(() -> driverStateMachineInstance.setDriverState(DriverState.MANUAL)));
113-
conDriver.btn_LeftTrigger
114-
.whileTrue(shooting);
160+
// conDriver.btn_X
161+
// .whileTrue(EXAMPLE_POSE_DRIVE)
162+
// .onFalse(Commands.runOnce(() ->
163+
// driverStateMachineInstance.setDriverState(DriverState.MANUAL)));
115164
conDriver.btn_North
116165
.onTrue(resetPose);
117166
}

src/main/java/frc/robot/commands/states/EjectingHopper.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import frc.robot.constants.ConstMotion;
1010
import frc.robot.constants.ConstRotors;
1111
import frc.robot.subsystems.StateMachine;
12-
import frc.robot.*;
1312

1413
/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */
1514
public class EjectingHopper extends Command
@@ -27,7 +26,7 @@ public EjectingHopper() {
2726
@Override
2827
public void initialize() {
2928
RobotContainer.stateMachineInstance.setRobotState(StateMachine.RobotState.EJECTING_HOPPER);
30-
RobotContainer.motionInstance.setIntakePivotAngle(ConstMotion.INTAKE_PIVOT_DEPLOY);
29+
RobotContainer.motionInstance.setIntakePivotAngle(ConstMotion.DEPLOY_INTAKE_PIVOT_ANGLE);
3130
RobotContainer.rotorsInstance.setIntakeRollersPercentOutput(ConstRotors.REVERSE_SERIALIZER_ROLLERS_SPEED);
3231
RobotContainer.rotorsInstance.setSerializerRollersPercentOutput(ConstRotors.REVERSE_TRANSFER_ROLLERS_SPEED);
3332
RobotContainer.rotorsInstance.setTransferRollersPercentOutput(ConstRotors.REVERSE_INTAKE_ROLLERS_SPEED);

src/main/java/frc/robot/commands/states/Intaking.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,20 @@
88
import frc.robot.RobotContainer;
99
import frc.robot.constants.ConstMotion;
1010
import frc.robot.constants.ConstRotors;
11+
import frc.robot.subsystems.StateMachine;
1112

1213
public class Intaking extends Command {
1314
/** Creates a new Intaking. */
1415
public Intaking() {
16+
addRequirements(RobotContainer.stateMachineInstance);
1517
}
1618

1719
// Called when the command is initially scheduled.
1820
@Override
1921
public void initialize() {
20-
RobotContainer.motionInstance.setIntakePivotAngle(ConstMotion.INTAKE_PIVOT_DEPLOY);
22+
RobotContainer.motionInstance.setIntakePivotAngle(ConstMotion.DEPLOY_INTAKE_PIVOT_ANGLE);
2123
RobotContainer.rotorsInstance.setIntakeRollersPercentOutput(ConstRotors.INTAKE_ROLLERS_SPEED);
24+
RobotContainer.stateMachineInstance.setRobotState(StateMachine.RobotState.INTAKING);
2225

2326
}
2427

src/main/java/frc/robot/commands/states/None.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
import edu.wpi.first.wpilibj2.command.Command;
88
import frc.robot.RobotContainer;
9+
import frc.robot.constants.ConstMotion;
10+
import frc.robot.constants.ConstRotors;
911
import frc.robot.subsystems.*;
1012

1113
/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */
@@ -22,6 +24,11 @@ public None() {
2224
@Override
2325
public void initialize() {
2426
RobotContainer.stateMachineInstance.setRobotState(StateMachine.RobotState.NONE);
27+
RobotContainer.rotorsInstance.setFlywheelPercentOutput(ConstRotors.STOP);
28+
RobotContainer.rotorsInstance.setSerializerRollersPercentOutput(ConstRotors.STOP);
29+
RobotContainer.rotorsInstance.setTransferRollersPercentOutput(ConstRotors.STOP);
30+
RobotContainer.rotorsInstance.setIntakeRollersPercentOutput(ConstRotors.STOP);
31+
RobotContainer.motionInstance.setHoodPivotAngle(ConstMotion.HOOD_NONE_ANGLE);
2532
}
2633

2734
// Called every time the scheduler runs while the command is scheduled.

src/main/java/frc/robot/commands/states/PrepCorner.java

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

src/main/java/frc/robot/commands/states/PrepHub.java

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

src/main/java/frc/robot/commands/states/PrepOpponentToAlliance.java

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

src/main/java/frc/robot/commands/states/PrepTower.java

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

src/main/java/frc/robot/commands/states/PrepTrench.java

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

src/main/java/frc/robot/commands/states/RetractIntake.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,22 @@
77
import edu.wpi.first.wpilibj2.command.Command;
88
import frc.robot.RobotContainer;
99
import frc.robot.constants.ConstMotion;
10+
import frc.robot.constants.ConstRotors;
11+
import frc.robot.subsystems.StateMachine;
1012

1113
public class RetractIntake extends Command {
1214
/** Creates a new RetractIntake. */
1315
public RetractIntake() {
16+
addRequirements(RobotContainer.stateMachineInstance);
1417
// Use addRequirements() here to declare subsystem dependencies.
1518
}
1619

1720
// Called when the command is initially scheduled.
1821
@Override
1922
public void initialize() {
20-
RobotContainer.motionInstance.setIntakePivotAngle(ConstMotion.INTAKE_PIVOT_RETRACT);
23+
RobotContainer.rotorsInstance.setIntakeRollersPercentOutput(ConstRotors.STOP);
24+
RobotContainer.motionInstance.setIntakePivotAngle(ConstMotion.RETRACT_INTAKE_PIVOT_ANGLE);
25+
RobotContainer.stateMachineInstance.setRobotState(StateMachine.RobotState.RETRACT_INTAKE);
2126
}
2227

2328
// Called every time the scheduler runs while the command is scheduled.

0 commit comments

Comments
 (0)