@@ -77,13 +77,13 @@ public class RobotContainer {
77
77
// Dashboard inputs
78
78
private final LoggedDashboardChooser <Command > autoChooser ;
79
79
80
+ // crete mode changers
80
81
private LoggedDashboardNumber autoWait = new LoggedDashboardNumber ("AutoWait" , 0 );
81
82
private LoggedDashboardNumber rightShooterVolts = new LoggedDashboardNumber ("RightShooter" , ShooterConstants .SHOOTER_FULL_VOLTAGE );
82
83
private LoggedDashboardNumber leftShooterVolts = new LoggedDashboardNumber ("LeftShooter" , ShooterConstants .SHOOTER_FULL_VOLTAGE );
83
- private LoggedDashboardBoolean TurboMode = new LoggedDashboardBoolean ("Turbo Mode" ,false );
84
- private LoggedDashboardBoolean BrakeMode = new LoggedDashboardBoolean ("Brake Mode" , true );
85
- private LoggedDashboardBoolean SetStartPosition = new LoggedDashboardBoolean ("Set Start Position" , false );
86
- private LoggedDashboardBoolean ShootSide = new LoggedDashboardBoolean ("ShootSide" , false );
84
+ private LoggedDashboardBoolean brakeModeDashboard = new LoggedDashboardBoolean ("Brake Mode" , true );
85
+ private LoggedDashboardBoolean setStartPosition = new LoggedDashboardBoolean ("Set Start Position" , false );
86
+
87
87
// Field
88
88
private final Field2d field ;
89
89
@@ -192,7 +192,7 @@ public RobotContainer() {
192
192
System .out .println ("[Init] Setting up Named Commands" );
193
193
194
194
NamedCommands .registerCommand ("Shoot" , shootSpeaker ().andThen (zeroPosition ()));
195
- NamedCommands .registerCommand ("ShootSide " , shootSpeakerSide ().andThen (zeroPosition ()));
195
+ NamedCommands .registerCommand ("shootSide " , shootSpeakerSide ().andThen (zeroPosition ()));
196
196
NamedCommands .registerCommand ("ShootAnywhere" , shootAnywhereAuto ());
197
197
198
198
NamedCommands .registerCommand ("Intake" ,
@@ -203,6 +203,7 @@ public RobotContainer() {
203
203
NamedCommands .registerCommand ("ZeroPivot" , pivot .bringDownCommand ());
204
204
205
205
NamedCommands .registerCommand ("PrepShot" , rotateArmSpeaker ());
206
+ // TODO clean these up later
206
207
NamedCommands .registerCommand ("PrepShootAnywhere" , rotateArmtoSpeakerForever ()
207
208
.alongWith (shooter .runVoltageBoth (rightShooterVolts ::get , leftShooterVolts ::get )));
208
209
NamedCommands .registerCommand ("PrepPass" , shooter .runVoltage (ShooterConstants .SHOOTER_UNJAM_VOLTAGE ).alongWith (indexer .manualCommand (IndexerConstants .INDEXER_OUT_VOLTAGE )).withTimeout (0.1 )
@@ -237,12 +238,11 @@ public RobotContainer() {
237
238
238
239
}
239
240
240
-
241
+ // zero gyro
241
242
public void reset () {
242
243
drive .resetYaw ();
243
244
}
244
245
245
-
246
246
/**
247
247
* Use this method to define your button->command mappings. Buttons can be
248
248
* created by instantiating a {@link GenericHID} or one of its subclasses
@@ -344,12 +344,12 @@ private void configureButtonBindings() {
344
344
.deadlineWith (shooter .runVoltage (ShooterConstants .SHOOTER_FULL_VOLTAGE ))
345
345
.deadlineWith (indexer .manualCommand (IndexerConstants .INDEXER_IN_VOLTAGE )));
346
346
347
+ // add controller rumble triggers
347
348
new Trigger (() -> (int ) Timer .getMatchTime () == 30.0 ).onTrue (getRumbleDriver ());
348
349
new Trigger (indexer ::isIntaked ).onTrue (getRumbleOperator ());
349
350
new Trigger (this ::isAimedAtSpeaker ).onTrue (getRumbleDriver ());
350
-
351
351
352
-
352
+ // add extra commands in tuning mode
353
353
if (Constants .tuningMode ) {
354
354
SmartDashboard .putData ("Pivot Sysid" ,
355
355
new SequentialCommandGroup (
@@ -360,11 +360,10 @@ private void configureButtonBindings() {
360
360
)
361
361
);
362
362
}
363
-
364
-
365
363
}
366
364
367
365
public void setPivotPose3d () {
366
+ // log the component positions for viewing in advantage scope
368
367
Logger .recordOutput ("PivotPoseThing" ,
369
368
new Pose3d (
370
369
new Translation3d (0 , 0 , 0.28 ),
@@ -386,9 +385,11 @@ public void resetRobotPose(Pose2d pose) {
386
385
* @return the command to run in autonomous
387
386
*/
388
387
public Command getAutonomousCommand () {
388
+ // make sure choosers are configured for correct alliance poses
389
389
AutoChooser .setupChoosers ();
390
390
drive .updateDeadzoneChooser ();
391
391
392
+ // if we are running a custom auto create one
392
393
if (autoChooser .getSendableChooser ().getSelected ().equals ("Custom" )) {
393
394
Command custom = MakeAutos .makeAutoCommand (
394
395
drive ,
@@ -399,17 +400,20 @@ public Command getAutonomousCommand() {
399
400
indexer ::isIntaked
400
401
);
401
402
403
+ // add auto wait if needed
402
404
if (autoWait .get () > 0 ) {
403
405
return new WaitCommand (autoWait .get ()).andThen (custom );
404
406
}
405
407
406
408
return custom ;
407
409
}
408
410
411
+ // add auto wait if needed
409
412
if (autoWait .get () > 0 ) {
410
413
return new WaitCommand (autoWait .get ()).andThen (autoChooser .get ());
411
414
}
412
415
416
+ // get path planner auto
413
417
return autoChooser .get ();
414
418
}
415
419
@@ -427,6 +431,9 @@ public Command joystickAmpPoint() {
427
431
);
428
432
}
429
433
434
+ /*
435
+ * Compound Commands
436
+ */
430
437
public Command zeroPosition () {
431
438
return pivot .bringDownCommand ()
432
439
.deadlineWith (
@@ -462,14 +469,6 @@ public Command altShootAnywhere() {
462
469
DRIVE_STRAFE ));
463
470
}
464
471
465
- public boolean isPointedAtSpeaker () {
466
- return DriveCommands .pointedAtSpeaker (drive );
467
- }
468
-
469
- public boolean isAimedAtSpeaker () {
470
- return DriveCommands .pointedAtSpeaker (drive ) && pivot .atSetpoint ();
471
- }
472
-
473
472
public Command shootAnywhere () {
474
473
return (new WaitUntilCommand (this ::isPointedAtSpeaker ).andThen (shootNote ()))
475
474
.deadlineWith (lockOnSpeakerFull ());
@@ -545,13 +544,9 @@ public Command shootNote() {
545
544
.withTimeout (1.9 ));//.alongWith(new InstantCommand(() -> {NoteVisualizer.shoot().schedule();})); // run the visualizer
546
545
}
547
546
548
- /* // Brings the note forward and back for 0.5 seconds each to center it
549
- public Command intakeShimmyCommand() {
550
- return (indexer.manualCommand(IndexerConstants.INDEXER_IN_VOLTAGE)
551
- .alongWith(groundIntake.manualCommand(GroundIntakeConstants.GROUND_INTAKE_IN_VOLTAGE)))
552
- .withTimeout(ShooterConstants.SHOOTER_SPINUP_TIME)
553
- .andThen(indexer.manualCommand(IndexerConstants.INDEXER_OUT_VOLTAGE).withTimeout(ShooterConstants.SHOOTER_SPINUP_TIME));
554
- } */
547
+ public Command intakeUntilIntaked (){
548
+ return indexer .IntakeLoopCommand (IndexerConstants .INDEXER_IN_VOLTAGE_WEAK ).deadlineWith (groundIntake .manualCommand (GroundIntakeConstants .GROUND_INTAKE_IN_VOLTAGE )).deadlineWith (shooter .runVoltage (0 ));
549
+ }
555
550
556
551
// Returns the estimated transformation over the next tick (The change in
557
552
// position)
@@ -573,20 +568,30 @@ private double getEstimatedDistance() {
573
568
return targetTransform .getTranslation ().getNorm ();
574
569
}
575
570
576
- // Gets RPM based on distance from speaker, taking into account the actual
577
- // shooting position
578
- /* private double getRPM() {
579
- return Lookup.getRPM(getEstimatedDistance());
580
- } */
571
+ @ AutoLogOutput (key = "PointedAtSpeaker" )
572
+ public boolean isPointedAtSpeaker () {
573
+ return DriveCommands .pointedAtSpeaker (drive );
574
+ }
575
+
576
+ @ AutoLogOutput (key = "AimedAtSpeaker" )
577
+ public boolean isAimedAtSpeaker () {
578
+ return DriveCommands .pointedAtSpeaker (drive ) && pivot .atSetpoint ();
579
+ }
580
+
581
581
582
582
// Gets angle based on distance from speaker, taking into account the actual
583
583
// shooting position
584
+ @ AutoLogOutput (key = "ShootAnywhereAngle" )
584
585
private double getAngle () {
585
586
double angle = Lookup .getAngle (getEstimatedDistance ());
586
587
Logger .recordOutput ("ShootAnywhereAngle" , angle );
587
588
return angle ;
588
589
}
589
590
591
+ /*
592
+ * Other Periodic Methods
593
+ */
594
+
590
595
public void LEDPeriodic () {
591
596
BlinkinLEDController .isEndgame = DriverStation .getMatchTime () <= 30 ;
592
597
BlinkinLEDController .isEnabled = DriverStation .isEnabled ();
@@ -598,26 +603,22 @@ public void LEDPeriodic() {
598
603
599
604
public void disabledPeriodic () {
600
605
LEDPeriodic ();
601
- if (BrakeMode .get () != brakeMode ) {
606
+ if (brakeModeDashboard .get () != brakeMode ) {
602
607
brakeMode = !brakeMode ;
603
608
pivot .setBrake (brakeMode );
604
609
}
605
610
606
- if (SetStartPosition .get ()) {
611
+ if (setStartPosition .get ()) {
607
612
AutoChooser .setupChoosers ();
608
613
drive .updateDeadzoneChooser ();
609
614
resetRobotPose (AutoChooser .getStartPose ());
610
- SetStartPosition .set (false );
615
+ setStartPosition .set (false );
611
616
}
612
617
613
618
setPivotPose3d ();
614
619
field .setRobotPose (drive .getPose ());
615
620
Logger .recordOutput ("DriveAimed" , DriveCommands .pointedAtSpeaker (drive ));
616
621
Logger .recordOutput ("PivotAimed" , pivot .atSetpoint ());
617
622
}
618
-
619
- public Command intakeUntilIntaked (){
620
- return indexer .IntakeLoopCommand (IndexerConstants .INDEXER_IN_VOLTAGE_WEAK ).deadlineWith (groundIntake .manualCommand (GroundIntakeConstants .GROUND_INTAKE_IN_VOLTAGE )).deadlineWith (shooter .runVoltage (0 ));
621
- }
622
623
623
624
}
0 commit comments