1
1
/* Black Knights Robotics (C) 2025 */
2
2
package org .blackknights ;
3
3
4
+ import edu .wpi .first .math .geometry .Pose2d ;
5
+ import edu .wpi .first .math .geometry .Rotation2d ;
6
+ import edu .wpi .first .math .geometry .Transform2d ;
4
7
import edu .wpi .first .wpilibj .DriverStation ;
5
8
import edu .wpi .first .wpilibj .GenericHID ;
6
9
import edu .wpi .first .wpilibj .smartdashboard .SendableChooser ;
@@ -62,17 +65,33 @@ public RobotContainer() {
62
65
SmartDashboard .putData (cqProfiles );
63
66
SmartDashboard .putData ("Auto Chooser" , superSecretMissileTech );
64
67
68
+ // Autos
65
69
superSecretMissileTech .addOption (
66
- "Left " ,
70
+ "LEFT_3 " ,
67
71
new SequentialCommandGroup (
68
72
getLocationPlaceCommand (CoralQueue .CoralPosition .fromString ("10L4" )),
69
- getAutoIntakeCommand (),
73
+ getAutoIntakeCommand (IntakeSides . LEFT ),
70
74
getLocationPlaceCommand (CoralQueue .CoralPosition .fromString ("8L4" )),
71
- getAutoIntakeCommand (),
75
+ getAutoIntakeCommand (IntakeSides . LEFT ),
72
76
getLocationPlaceCommand (CoralQueue .CoralPosition .fromString ("9L4" ))));
73
77
74
78
superSecretMissileTech .addOption (
75
- "One pose" , getLocationPlaceCommand (CoralQueue .CoralPosition .fromString ("10L4" )));
79
+ "RIGHT_3" ,
80
+ new SequentialCommandGroup (
81
+ getLocationPlaceCommand (CoralQueue .CoralPosition .fromString ("3L4" )),
82
+ getAutoIntakeCommand (IntakeSides .RIGHT ),
83
+ getLocationPlaceCommand (CoralQueue .CoralPosition .fromString ("6L4" )),
84
+ getAutoIntakeCommand (IntakeSides .RIGHT ),
85
+ getLocationPlaceCommand (CoralQueue .CoralPosition .fromString ("7L4" ))));
86
+
87
+ superSecretMissileTech .addOption (
88
+ "CENTER_LEFT" ,
89
+ getLocationPlaceCommand (CoralQueue .CoralPosition .fromString ("12L4" )));
90
+ superSecretMissileTech .addOption (
91
+ "CENTER_RIGHT" ,
92
+ getLocationPlaceCommand (CoralQueue .CoralPosition .fromString ("1L4" )));
93
+
94
+ superSecretMissileTech .addOption ("INTAKE_TEST" , getAutoIntakeCommand (IntakeSides .RIGHT ));
76
95
}
77
96
78
97
/** Configure controller bindings */
@@ -83,9 +102,9 @@ private void configureBindings() {
83
102
swerveSubsystem .setDefaultCommand (
84
103
new DriveCommands (
85
104
swerveSubsystem ,
86
- () -> primaryController .getLeftY () * 2.5 ,
87
- () -> primaryController .getLeftX () * 2.5 ,
88
- () -> -primaryController .getRightX () * Math .PI ,
105
+ () -> primaryController .getLeftY () * ConfigManager . getInstance (). get ( "driver_max_speed" , 3.5 ) ,
106
+ () -> primaryController .getLeftX () * ConfigManager . getInstance (). get ( "driver_max_speed" , 3.5 ) ,
107
+ () -> -primaryController .getRightX () * Math .toRadians ( ConfigManager . getInstance (). get ( "driver_max_speed_rot" , 360 )) ,
89
108
true ,
90
109
true ));
91
110
@@ -96,9 +115,16 @@ private void configureBindings() {
96
115
() -> coralQueue .getCurrentPosition (), () -> coralQueue .getNext ()));
97
116
98
117
primaryController
99
- .leftBumper ()
118
+ .rightBumper ()
100
119
.whileTrue (
101
120
new ParallelCommandGroup (
121
+ new DriveCommands (
122
+ swerveSubsystem ,
123
+ primaryController ::getLeftY ,
124
+ primaryController ::getLeftX ,
125
+ () -> -primaryController .getRightX () * Math .PI ,
126
+ true ,
127
+ true ),
102
128
new ElevatorArmCommand (
103
129
elevatorSubsystem ,
104
130
armSubsystem ,
@@ -110,16 +136,15 @@ private void configureBindings() {
110
136
111
137
primaryController .povDown ().whileTrue (new RunCommand (() -> swerveSubsystem .zeroGyro ()));
112
138
139
+ secondaryController
140
+ .rightStick ()
141
+ .onTrue (new InstantCommand (ScoringConstants ::recomputeCoralPositions ));
142
+
113
143
// SECONDARY CONTROLLER
114
144
115
145
climberSubsystem .setDefaultCommand (
116
146
new ClimberCommand (climberSubsystem , secondaryController ));
117
147
118
- // secondaryController.leftBumper.onTrue(new InstantCommand(() ->
119
- // coralQueue.stepBackwards()));
120
- // secondaryController.rightBumper.onTrue(new InstantCommand(() ->
121
- // coralQueue.stepForwards()));
122
-
123
148
secondaryController
124
149
.a ()
125
150
.whileTrue (
@@ -154,7 +179,7 @@ private void configureBindings() {
154
179
155
180
secondaryController
156
181
.leftBumper ()
157
- .onTrue (new InstantCommand (() -> coralQueue .stepForwards ()));
182
+ .onTrue (new InstantCommand (() -> coralQueue .stepForwards ())); //
158
183
159
184
secondaryController
160
185
.rightBumper ()
@@ -183,6 +208,8 @@ public void robotPeriodic() {
183
208
184
209
/** Runs ones when enabled in teleop */
185
210
public void teleopInit () {
211
+ buttonBoardSubsystem .bind ();
212
+
186
213
if (cqProfiles .getSelected () != null )
187
214
CoralQueue .getInstance ().loadProfile (cqProfiles .getSelected ());
188
215
}
@@ -230,19 +257,32 @@ private Command getPlaceCommand(
230
257
false ,
231
258
"rough" ),
232
259
new BaseCommand (elevatorSubsystem , armSubsystem )),
233
- new ParallelCommandGroup (
234
- new SequentialCommandGroup (
235
- new AlignCommand (
260
+ new ParallelRaceGroup (
261
+ new AlignCommand (
236
262
swerveSubsystem ,
237
263
() -> currentSupplier .get ().getPose (),
238
264
true ,
239
- "fine" ),
240
- new IntakeCommand (intakeSubsystem , IntakeCommand .IntakeMode .OUTTAKE )
241
- .withTimeout (2 )),
265
+ "fine" )
266
+ .withTimeout (
267
+ ConfigManager .getInstance ()
268
+ .get ("align_fine_max_time" , 3.0 )),
269
+ new RunCommand (
270
+ () ->
271
+ intakeSubsystem .setSpeed (
272
+ ConfigManager .getInstance ()
273
+ .get ("intake_slow_voltage" , -2.0 )),
274
+ intakeSubsystem ),
275
+ new ElevatorArmCommand (
276
+ elevatorSubsystem ,
277
+ armSubsystem ,
278
+ () -> currentSupplier .get ().getHeight ())),
279
+ new ParallelRaceGroup (
242
280
new ElevatorArmCommand (
243
281
elevatorSubsystem ,
244
282
armSubsystem ,
245
- () -> nextSupplier .get ().getHeight ())));
283
+ () -> nextSupplier .get ().getHeight ()),
284
+ new IntakeCommand (intakeSubsystem , IntakeCommand .IntakeMode .OUTTAKE )
285
+ .withTimeout (1 )));
246
286
}
247
287
248
288
/**
@@ -260,24 +300,52 @@ private Command getLocationPlaceCommand(CoralQueue.CoralPosition position) {
260
300
*
261
301
* @return The command to goto the feeder
262
302
*/
263
- private Command getAutoIntakeCommand () {
264
- return new ParallelDeadlineGroup (
303
+ private Command getAutoIntakeCommand (IntakeSides side ) {
304
+ Pose2d intakePose = getPose2d (side );
305
+
306
+ Pose2d intakePoseFinal =
307
+ intakePose .plus (new Transform2d (0 , 0 , Rotation2d .fromRadians (Math .PI )));
308
+
309
+ return new ParallelRaceGroup (
265
310
new SequentialCommandGroup (
266
311
new AlignCommand (
267
312
swerveSubsystem ,
268
313
() ->
269
- DriverStation .getAlliance ().isPresent ()
270
- && DriverStation .getAlliance ().get ()
271
- == DriverStation .Alliance .Blue
272
- ? ScoringConstants .INTAKE_BLUE
273
- : ScoringConstants .INTAKE_RED ,
274
- true ,
275
- "rough" ),
276
- new IntakeCommand (intakeSubsystem , IntakeCommand .IntakeMode .INTAKE )
277
- .withTimeout (2 )),
314
+ AlignUtils .getXDistBack (
315
+ intakePoseFinal ,
316
+ ConfigManager .getInstance ()
317
+ .get ("autointake_first_back" , 1.0 )),
318
+ false ,
319
+ "auto" ),
320
+ new AlignCommand (swerveSubsystem , () -> intakePoseFinal , true , "fine" )),
278
321
new ElevatorArmCommand (
279
322
elevatorSubsystem ,
280
323
armSubsystem ,
281
- () -> ScoringConstants .ScoringHeights .INTAKE ));
324
+ () -> ScoringConstants .ScoringHeights .INTAKE ),
325
+ new IntakeCommand (intakeSubsystem , IntakeCommand .IntakeMode .INTAKE ));
326
+ }
327
+
328
+ private static Pose2d getPose2d (IntakeSides side ) {
329
+ Pose2d intakePose ;
330
+ if (DriverStation .getAlliance ().isPresent ()
331
+ && DriverStation .getAlliance ().get () == DriverStation .Alliance .Blue ) {
332
+ if (side == IntakeSides .LEFT ) {
333
+ intakePose = ScoringConstants .INTAKE_BLUE_LEFT ;
334
+ } else {
335
+ intakePose = ScoringConstants .INTAKE_BLUE_RIGHT ;
336
+ }
337
+ } else {
338
+ if (side == IntakeSides .LEFT ) {
339
+ intakePose = ScoringConstants .INTAKE_RED_LEFT ;
340
+ } else {
341
+ intakePose = ScoringConstants .INTAKE_RED_RIGHT ;
342
+ }
343
+ }
344
+ return intakePose ;
345
+ }
346
+
347
+ private enum IntakeSides {
348
+ LEFT ,
349
+ RIGHT
282
350
}
283
351
}
0 commit comments