@@ -71,7 +71,8 @@ enum Notes {
71
71
DRIVE ,
72
72
NEXT2STAGE ,
73
73
NEXT2AMP ,
74
- GOFORWARDS
74
+ GOFORWARDS ,
75
+ CENTERSHOOTDRIVE
75
76
}
76
77
77
78
private final SendableChooser <Positions > startingPositionChooser = new SendableChooser <>();
@@ -93,7 +94,7 @@ public void robotInit() {
93
94
AHRS ahrs = new AHRS (SerialPort .Port .kMXP );
94
95
95
96
var driverCamera = CameraServer .startAutomaticCapture ();
96
- driverCamera .setPixelFormat (PixelFormat .kYUYV );
97
+ // driverCamera.setPixelFormat(PixelFormat.kYUYV);
97
98
driverCamera .setResolution (1280 , 720 );
98
99
99
100
if (Robot .isSimulation ()) {
@@ -140,6 +141,7 @@ public void robotInit() {
140
141
noteChooser1 .addOption ("Next 2 Amp" , Notes .NEXT2AMP );
141
142
noteChooser1 .addOption ("Next 2 Stage" , Notes .NEXT2STAGE );
142
143
noteChooser1 .addOption ("Go Forwards" , Notes .GOFORWARDS );
144
+ noteChooser1 .addOption ("Shoot note then drive" , Notes .CENTERSHOOTDRIVE );
143
145
SmartDashboard .putData ("note chooser 1" , noteChooser1 );
144
146
145
147
noteChooser2 .setDefaultOption ("be useless" , Notes .NOTHING );
@@ -164,9 +166,9 @@ public void robotInit() {
164
166
* {@link JoystickButton}.
165
167
*/
166
168
private void configureButtonBindings () {
167
- /* new JoystickButton(driverController, PS4Controller.Button.kCross.value)
168
- .and(DriverStation::isTeleop)
169
- .whileTrue(drive.setXCommand());*/
169
+ /* new JoystickButton(driverController, PS4Controller.Button.kCross.value)
170
+ .and(DriverStation::isTeleop)
171
+ .whileTrue(drive.setXCommand());*/
170
172
new JoystickButton (driverController , PS4Controller .Button .kL1 .value )
171
173
.whileTrue (shooter .manualShootCommand ().deadlineWith (leds .rainbowFlagScroll ()));
172
174
new JoystickButton (driverController , PS4Controller .Button .kTriangle .value )
@@ -187,8 +189,12 @@ private void configureButtonBindings() {
187
189
.whileTrue (intake .spinReverseCommand ());
188
190
new JoystickButton (driverController , PS4Controller .Button .kR3 .value )
189
191
.whileTrue (shooter .ampCommand ());
190
- new JoystickButton (driverController , PS4Controller .Button .kR1 .value ).whileTrue (climber .climbCommand ()).onFalse (climber .stopClimbCommand ());
191
- new JoystickButton (driverController , PS4Controller .Button .kCross .value ).whileTrue (climber .reverseClimbCommand ()).onFalse (climber .stopClimbCommand ());
192
+ new JoystickButton (driverController , PS4Controller .Button .kR1 .value )
193
+ .whileTrue (climber .climbCommand ())
194
+ .onFalse (climber .stopClimbCommand ());
195
+ new JoystickButton (driverController , PS4Controller .Button .kCross .value )
196
+ .whileTrue (climber .reverseClimbCommand ())
197
+ .onFalse (climber .stopClimbCommand ());
192
198
}
193
199
194
200
private void configureAutomaticBindings () {
@@ -203,9 +209,7 @@ private void configureAutomaticBindings() {
203
209
public Command getAutonomousCommand () {
204
210
return switch (startingPositionChooser .getSelected ()) {
205
211
case AMP -> {
206
- Command auto =
207
- shooter
208
- .autoShootCommand1 ().andThen (shootAndIntermediary ());
212
+ Command auto = shooter .autoShootCommand1 ().andThen (shootAndIntermediary ());
209
213
boolean done = false ;
210
214
switch (noteChooser1 .getSelected ()) {
211
215
case AMP -> auto = auto .andThen (followPathAndShoot ("amp 3 p1" ));
@@ -254,9 +258,7 @@ public Command getAutonomousCommand() {
254
258
yield auto ;
255
259
}
256
260
case CENTER -> {
257
- Command auto =
258
- shooter
259
- .autoShootCommand1 ().andThen (shootAndIntermediary ());
261
+ Command auto = shooter .autoShootCommand1 ().andThen (shootAndIntermediary ());
260
262
boolean done = false ;
261
263
switch (noteChooser1 .getSelected ()) {
262
264
case CENTER -> auto = auto .andThen (followPathAndShoot ("center 3 p1" ));
@@ -268,6 +270,7 @@ public Command getAutonomousCommand() {
268
270
case NOTHING -> {
269
271
done = true ;
270
272
}
273
+ case CENTERSHOOTDRIVE -> auto = shootThenDrive ();
271
274
default -> {
272
275
done = true ;
273
276
}
@@ -302,9 +305,7 @@ public Command getAutonomousCommand() {
302
305
yield auto ;
303
306
}
304
307
case STAGE -> {
305
- Command auto =
306
- shooter
307
- .autoShootCommand1 ().andThen (shootAndIntermediary ());
308
+ Command auto = shooter .autoShootCommand1 ().andThen (shootAndIntermediary ());
308
309
boolean done = false ;
309
310
switch (noteChooser1 .getSelected ()) {
310
311
case AMP -> auto = auto .andThen (followPathAndShoot ("stage 3 p1" ));
@@ -357,12 +358,9 @@ public Command getAutonomousCommand() {
357
358
}
358
359
yield auto ;
359
360
}
360
-
361
+
361
362
case NEXT2AMP -> {
362
- Command auto =
363
- shooter
364
- .autoShootCommand1 ()
365
- .andThen (shootAndIntermediary ());
363
+ Command auto = shooter .autoShootCommand1 ().andThen (shootAndIntermediary ());
366
364
boolean done = false ;
367
365
switch (noteChooser1 .getSelected ()) {
368
366
case NOTHING -> {
@@ -378,10 +376,7 @@ public Command getAutonomousCommand() {
378
376
yield auto ;
379
377
}
380
378
case NEXT2STAGE -> {
381
- Command auto =
382
- shooter
383
- .autoShootCommand1 ()
384
- .andThen (shootAndIntermediary ());
379
+ Command auto = shooter .autoShootCommand1 ().andThen (shootAndIntermediary ());
385
380
boolean done = false ;
386
381
switch (noteChooser1 .getSelected ()) {
387
382
case NOTHING -> {
@@ -416,6 +411,14 @@ private ParallelCommandGroup shootAndIntermediary() {
416
411
return intermediary .intermediaryCommand ().alongWith (shooter .autoShootCommand2 ());
417
412
}
418
413
414
+ private SequentialCommandGroup shootThenDrive () {
415
+ return drive
416
+ .pointForward ()
417
+ .andThen (drive .autoDriveCommand ())
418
+ .withTimeout (1 )
419
+ .andThen (drive .setXCommand ());
420
+ }
421
+
419
422
/**
420
423
* This function is called every 20 ms, no matter the mode. Use this for items like diagnostics
421
424
* that you want ran during disabled, autonomous, teleoperated and test.
@@ -480,8 +483,6 @@ public void teleopInit() {
480
483
leds .greenPurpleScroll ().schedule ();
481
484
}
482
485
483
-
484
-
485
486
/** This function is called periodically during operator control. */
486
487
@ Override
487
488
public void teleopPeriodic () {}
0 commit comments