1010import edu .wpi .first .math .geometry .Rotation2d ;
1111import edu .wpi .first .wpilibj2 .command .Command ;
1212import edu .wpi .first .wpilibj2 .command .Commands ;
13+ import edu .wpi .first .wpilibj2 .command .button .Trigger ;
1314import frc .robot .Constants .constControllers ;
1415import frc .robot .RobotMap .mapControllers ;
1516import frc .robot .commands .*;
2324public class RobotContainer {
2425
2526 private final SN_XboxController conDriver = new SN_XboxController (mapControllers .DRIVER_USB );
27+ private final SN_XboxController conOperator = new SN_XboxController (mapControllers .OPERATOR_USB );
2628
2729 private final Drivetrain subDrivetrain = new Drivetrain ();
2830 private final Intake subIntake = new Intake ();
@@ -31,8 +33,88 @@ public class RobotContainer {
3133 private final StateMachine subStateMachine = new StateMachine (subDrivetrain , subIntake , subClimber , subElevator );
3234 private final RobotPoses robotPose = new RobotPoses (subDrivetrain );
3335
36+ private final Trigger hasCoralTrigger = new Trigger (() -> subIntake .hasCoral () && !subIntake .hasAlgae ());
37+ private final Trigger hasAlgaeTrigger = new Trigger (() -> !subIntake .hasCoral () && subIntake .hasAlgae ());
38+ private final Trigger hasBothTrigger = new Trigger (() -> subIntake .hasCoral () && subIntake .hasAlgae ());
39+
3440 Command TRY_NONE = Commands .deferredProxy (
3541 () -> subStateMachine .tryState (RobotState .NONE ));
42+ Command TRY_CLIMBING = Commands .deferredProxy (
43+ () -> subStateMachine .tryState (RobotState .CLIMBING ));
44+ Command TRY_PREP_CLIMB = Commands .deferredProxy (
45+ () -> subStateMachine .tryState (RobotState .PREP_CLIMB ));
46+ Command TRY_RETRACTING_CLIMBER = Commands .deferredProxy (
47+ () -> subStateMachine .tryState (RobotState .RETRACTING_CLIMBER ));
48+ Command TRY_PREP_CORAL_ZERO = Commands .deferredProxy (
49+ () -> subStateMachine .tryState (RobotState .PREP_CORAL_ZERO ));
50+ Command TRY_PREP_CORAL_L1 = Commands .deferredProxy (
51+ () -> subStateMachine .tryState (RobotState .PREP_CORAL_L1 ));
52+ Command TRY_PREP_CORAL_L2 = Commands .deferredProxy (
53+ () -> subStateMachine .tryState (RobotState .PREP_CORAL_L2 ));
54+ Command TRY_PREP_CORAL_L3 = Commands .deferredProxy (
55+ () -> subStateMachine .tryState (RobotState .PREP_CORAL_L3 ));
56+ Command TRY_PREP_CORAL_L4 = Commands .deferredProxy (
57+ () -> subStateMachine .tryState (RobotState .PREP_CORAL_L4 ));
58+ Command TRY_PREP_CORAL_L1_WITH_ALGAE = Commands .deferredProxy (
59+ () -> subStateMachine .tryState (RobotState .PREP_CORAL_L1_WITH_ALGAE ));
60+ Command TRY_PREP_CORAL_L2_WITH_ALGAE = Commands .deferredProxy (
61+ () -> subStateMachine .tryState (RobotState .PREP_CORAL_L2_WITH_ALGAE ));
62+ Command TRY_PREP_CORAL_L3_WITH_ALGAE = Commands .deferredProxy (
63+ () -> subStateMachine .tryState (RobotState .PREP_CORAL_L3_WITH_ALGAE ));
64+ Command TRY_PREP_CORAL_L4_WITH_ALGAE = Commands .deferredProxy (
65+ () -> subStateMachine .tryState (RobotState .PREP_CORAL_L4_WITH_ALGAE ));
66+ Command TRY_PREP_CORAL_ZERO_WITH_ALGAE = Commands .deferredProxy (
67+ () -> subStateMachine .tryState (RobotState .PREP_CORAL_ZERO_WITH_ALGAE ));
68+ Command TRY_PREP_ALGAE_NET = Commands .deferredProxy (
69+ () -> subStateMachine .tryState (RobotState .PREP_ALGAE_NET ));
70+ Command TRY_PREP_ALGAE_PROCESSOR = Commands .deferredProxy (
71+ () -> subStateMachine .tryState (RobotState .PREP_ALGAE_PROCESSOR ));
72+ Command TRY_PREP_ALGAE_ZERO = Commands .deferredProxy (
73+ () -> subStateMachine .tryState (RobotState .PREP_ALGAE_ZERO ));
74+ Command TRY_PREP_ALGAE_NET_WITH_CORAL = Commands .deferredProxy (
75+ () -> subStateMachine .tryState (RobotState .PREP_ALGAE_NET_WITH_CORAL ));
76+ Command TRY_PREP_ALGAE_PROCESSOR_WITH_CORAL = Commands .deferredProxy (
77+ () -> subStateMachine .tryState (RobotState .PREP_ALGAE_PROCESSOR_WITH_CORAL ));
78+ Command TRY_HAS_CORAL = Commands .deferredProxy (
79+ () -> subStateMachine .tryState (RobotState .HAS_CORAL ));
80+ Command TRY_HAS_ALGAE = Commands .deferredProxy (
81+ () -> subStateMachine .tryState (RobotState .HAS_ALGAE ));
82+ Command TRY_HAS_CORAL_AND_ALGAE = Commands .deferredProxy (
83+ () -> subStateMachine .tryState (RobotState .HAS_CORAL_AND_ALGAE ));
84+ Command TRY_SCORING_CORAL = Commands .deferredProxy (
85+ () -> subStateMachine .tryState (RobotState .SCORING_CORAL ));
86+ Command TRY_SCORING_ALGAE = Commands .deferredProxy (
87+ () -> subStateMachine .tryState (RobotState .SCORING_ALGAE ));
88+ Command TRY_CLEAN_HIGH = Commands .deferredProxy (
89+ () -> subStateMachine .tryState (RobotState .CLEAN_HIGH ));
90+ Command TRY_CLEAN_LOW = Commands .deferredProxy (
91+ () -> subStateMachine .tryState (RobotState .CLEAN_LOW ));
92+ Command TRY_INTAKE_CORAL_STATION = Commands .deferredProxy (
93+ () -> subStateMachine .tryState (RobotState .INTAKE_CORAL_STATION ));
94+ Command TRY_INTAKE_ALGAE_GROUND = Commands .deferredProxy (
95+ () -> subStateMachine .tryState (RobotState .INTAKE_ALGAE_GROUND ));
96+ Command TRY_EJECTING = Commands .deferredProxy (
97+ () -> subStateMachine .tryState (RobotState .EJECTING ));
98+ Command TRY_SCORING_ALGAE_WITH_CORAL = Commands .deferredProxy (
99+ () -> subStateMachine .tryState (RobotState .SCORING_ALGAE_WITH_CORAL ));
100+ Command TRY_SCORING_CORAL_WITH_ALGAE = Commands .deferredProxy (
101+ () -> subStateMachine .tryState (RobotState .SCORING_CORAL_WITH_ALGAE ));
102+ Command TRY_CLEAN_HIGH_WITH_CORAL = Commands .deferredProxy (
103+ () -> subStateMachine .tryState (RobotState .CLEAN_HIGH_WITH_CORAL ));
104+ Command TRY_CLEAN_LOW_WITH_CORAL = Commands .deferredProxy (
105+ () -> subStateMachine .tryState (RobotState .CLEAN_LOW_WITH_CORAL ));
106+ Command TRY_INTAKE_CORAL_GROUND = Commands .deferredProxy (
107+ () -> subStateMachine .tryState (RobotState .INTAKE_CORAL_GROUND ));
108+ Command TRY_INTAKE_CORAL_GROUND_WITH_ALGAE = Commands .deferredProxy (
109+ () -> subStateMachine .tryState (RobotState .INTAKE_CORAL_GROUND_WITH_ALGAE ));
110+ Command TRY_INTAKE_ALGAE_GROUND_WITH_CORAL = Commands .deferredProxy (
111+ () -> subStateMachine .tryState (RobotState .INTAKE_ALGAE_GROUND_WITH_CORAL ));
112+ Command TRY_INTAKE_CORAL_STATION_WITH_ALGAE = Commands .deferredProxy (
113+ () -> subStateMachine .tryState (RobotState .INTAKE_CORAL_STATION_WITH_ALGAE ));
114+ Command HAS_CORAL_OVERRIDE = Commands .deferredProxy (() -> subStateMachine .tryState (RobotState .HAS_CORAL )
115+ .alongWith (subStateMachine .tryState (RobotState .HAS_CORAL_AND_ALGAE )));
116+ Command HAS_ALGAE_OVERRIDE = Commands .deferredProxy (() -> subStateMachine .tryState (RobotState .HAS_ALGAE )
117+ .alongWith (subStateMachine .tryState (RobotState .HAS_CORAL_AND_ALGAE )));
36118
37119 public RobotContainer () {
38120 conDriver .setLeftDeadband (constControllers .DRIVER_LEFT_STICK_DEADBAND );
@@ -57,6 +139,15 @@ private void configDriverBindings() {
57139 conDriver .btn_LeftBumper
58140 .whileTrue (Commands .runOnce (() -> subDrivetrain .setRobotRelative ()))
59141 .onFalse (Commands .runOnce (() -> subDrivetrain .setFieldRelative ()));
142+
143+ conDriver .btn_Start
144+ .onTrue (TRY_PREP_CLIMB );
145+
146+ conDriver .btn_A
147+ .whileTrue (TRY_RETRACTING_CLIMBER );
148+
149+ conDriver .btn_Y
150+ .whileTrue (TRY_CLIMBING );
60151 }
61152
62153 public Command getAutonomousCommand () {
@@ -66,6 +157,89 @@ public Command getAutonomousCommand() {
66157
67158 private void configOperatorBindings () {
68159 // Add operator bindings here if needed
160+ conOperator .btn_LeftTrigger
161+ .whileTrue (TRY_INTAKE_CORAL_GROUND )
162+ .whileTrue (TRY_INTAKE_CORAL_GROUND_WITH_ALGAE )
163+ .onFalse (TRY_NONE )
164+ .onFalse (TRY_HAS_ALGAE );
165+
166+ conOperator .btn_LeftBumper
167+ .whileTrue (TRY_INTAKE_ALGAE_GROUND )
168+ .whileTrue (TRY_INTAKE_ALGAE_GROUND_WITH_CORAL )
169+ .onFalse (TRY_NONE )
170+ .onFalse (TRY_HAS_CORAL );
171+
172+ conOperator .btn_RightTrigger
173+ .whileTrue (TRY_SCORING_CORAL )
174+ .whileTrue (TRY_SCORING_ALGAE )
175+ .whileTrue (TRY_SCORING_ALGAE_WITH_CORAL )
176+ .whileTrue (TRY_SCORING_CORAL_WITH_ALGAE )
177+ .onFalse (TRY_NONE )
178+ .onFalse (TRY_HAS_CORAL )
179+ .onFalse (TRY_HAS_ALGAE );
180+
181+ conOperator .btn_RightBumper
182+ .whileTrue (TRY_INTAKE_CORAL_STATION )
183+ .whileTrue (TRY_INTAKE_CORAL_STATION_WITH_ALGAE )
184+ .onFalse (TRY_NONE )
185+ .onFalse (TRY_HAS_ALGAE );
186+
187+ conOperator .btn_A
188+ .onTrue (TRY_PREP_CORAL_L1 )
189+ .onTrue (TRY_PREP_CORAL_L1_WITH_ALGAE );
190+
191+ conOperator .btn_B
192+ .onTrue (TRY_PREP_CORAL_L3 )
193+ .onTrue (TRY_PREP_CORAL_L3_WITH_ALGAE );
194+
195+ conOperator .btn_X
196+ .onTrue (TRY_PREP_CORAL_L2 )
197+ .onTrue (TRY_PREP_CORAL_L2_WITH_ALGAE );
198+
199+ conOperator .btn_Y
200+ .onTrue (TRY_PREP_CORAL_L4 )
201+ .onTrue (TRY_PREP_CORAL_L4_WITH_ALGAE );
202+
203+ conOperator .btn_LeftStick
204+ .whileTrue (TRY_EJECTING )
205+ .onFalse (TRY_NONE );
206+
207+ conOperator .btn_RightStick
208+ .onTrue (TRY_PREP_CORAL_ZERO )
209+ .onTrue (TRY_PREP_CORAL_ZERO_WITH_ALGAE );
210+
211+ conOperator .btn_North
212+ .onTrue (TRY_PREP_ALGAE_NET )
213+ .onTrue (TRY_PREP_ALGAE_NET_WITH_CORAL );
214+
215+ conOperator .btn_South
216+ .onTrue (TRY_PREP_ALGAE_PROCESSOR )
217+ .onTrue (TRY_PREP_ALGAE_PROCESSOR_WITH_CORAL );
218+
219+ conOperator .btn_East
220+ .whileTrue (TRY_CLEAN_HIGH )
221+ .whileTrue (TRY_CLEAN_HIGH_WITH_CORAL )
222+ .onFalse (TRY_NONE )
223+ .onFalse (TRY_HAS_CORAL );
224+
225+ conOperator .btn_West
226+ .whileTrue (TRY_CLEAN_LOW )
227+ .whileTrue (TRY_CLEAN_LOW_WITH_CORAL )
228+ .onFalse (TRY_NONE )
229+ .onFalse (TRY_HAS_CORAL );
230+
231+ conOperator .btn_Start .onTrue (HAS_CORAL_OVERRIDE );
232+
233+ conOperator .btn_Back .onTrue (HAS_ALGAE_OVERRIDE );
234+
235+ hasCoralTrigger
236+ .whileTrue (TRY_HAS_CORAL );
237+
238+ hasAlgaeTrigger
239+ .whileTrue (TRY_HAS_ALGAE );
240+
241+ hasBothTrigger
242+ .whileTrue (TRY_HAS_CORAL_AND_ALGAE );
69243 }
70244
71245 public RobotState getRobotState () {
0 commit comments