3737import frc .robot .util .BranchHeight ;
3838import frc .robot .util .RobotType ;
3939import frc .robot .util .ScoringMode ;
40+ import frc .robot .util .ScoringType ;
4041import frc .robot .util .SoloScoringMode ;
4142import java .util .function .BooleanSupplier ;
4243
@@ -83,8 +84,7 @@ public class Controls {
8384 new SwerveRequest .FieldCentric ()
8485 .withDeadband (0.0001 )
8586 .withRotationalDeadband (0.0001 )
86- .withDriveRequestType (
87- DriveRequestType .OpenLoopVoltage ); // Use open-loop control for drive motors
87+ .withDriveRequestType (DriveRequestType .Velocity );
8888
8989 private final Telemetry logger = new Telemetry (MaxSpeed );
9090
@@ -112,6 +112,14 @@ public Controls(Subsystems s, Sensors sensors, SuperStructure superStructure) {
112112 configureGroundSpinnyBindings ();
113113 configureGroundArmBindings ();
114114 configureSoloControllerBindings ();
115+ Shuffleboard .getTab ("Elevator" )
116+ .addBoolean ("Intaking mode Algae" , () -> intakeMode == ScoringMode .ALGAE );
117+ Shuffleboard .getTab ("Elevator" )
118+ .addString ("Scoring Mode" , () -> getSoloScoringMode ().toString ());
119+ }
120+
121+ public SoloScoringMode getSoloScoringMode () {
122+ return soloScoringMode ;
115123 }
116124
117125 private Trigger connected (CommandXboxController controller ) {
@@ -287,7 +295,7 @@ private void configureSuperStructureBindings() {
287295 Commands .deferredProxy (
288296 () ->
289297 switch (scoringMode ) {
290- case CORAL -> getCoralBranchHeightCommand ();
298+ case CORAL -> getCoralBranchHeightCommand (ScoringType . DRIVER );
291299 case ALGAE -> Commands .sequence (
292300 superStructure .algaeProcessorScore (
293301 driverController .rightBumper ()),
@@ -394,12 +402,7 @@ private void configureSuperStructureBindings() {
394402 case ALGAE -> soloScoringMode = SoloScoringMode .ALGAE_IN_CLAW ;
395403 }
396404 })
397- .withName ("Set solo scoring mode" ));
398-
399- sensors
400- .armSensor
401- .inClaw ()
402- .and (RobotModeTriggers .teleop ())
405+ .withName ("Set solo scoring mode" ))
403406 .onFalse (
404407 Commands .runOnce (
405408 () -> {
@@ -423,7 +426,7 @@ private void configureSuperStructureBindings() {
423426 () -> {
424427 Command scoreCommand =
425428 switch (scoringMode ) {
426- case CORAL -> getCoralBranchHeightCommand ();
429+ case CORAL -> getCoralBranchHeightCommand (ScoringType . DRIVER );
427430 case ALGAE -> Commands .sequence (
428431 BargeAlign .bargeScore (
429432 s .drivebaseSubsystem ,
@@ -448,30 +451,55 @@ private Command getAlgaeIntakeCommand() {
448451 };
449452 }
450453
451- private Command getCoralBranchHeightCommand () {
452- return switch (branchHeight ) {
453- case CORAL_LEVEL_FOUR -> superStructure .coralLevelFour (driverController .rightBumper ());
454- case CORAL_LEVEL_THREE -> superStructure .coralLevelThree (driverController .rightBumper ());
455- case CORAL_LEVEL_TWO -> superStructure .coralLevelTwo (driverController .rightBumper ());
456- case CORAL_LEVEL_ONE -> superStructure .coralLevelOne (driverController .rightBumper ());
457- };
458- }
459-
460- private Command getSoloCoralBranchHeightCommand () {
461- return switch (branchHeight ) {
462- case CORAL_LEVEL_FOUR -> superStructure
463- .coralLevelFour (soloController .rightBumper ())
464- .andThen (() -> soloScoringMode = soloScoringMode .NO_GAME_PIECE );
465- case CORAL_LEVEL_THREE -> superStructure
466- .coralLevelThree (soloController .rightBumper ())
467- .andThen (() -> soloScoringMode = soloScoringMode .NO_GAME_PIECE );
468- case CORAL_LEVEL_TWO -> superStructure
469- .coralLevelTwo (soloController .rightBumper ())
470- .andThen (() -> soloScoringMode = soloScoringMode .NO_GAME_PIECE );
471- case CORAL_LEVEL_ONE -> superStructure
472- .coralLevelOne (soloController .rightBumper ())
473- .andThen (() -> soloScoringMode = soloScoringMode .NO_GAME_PIECE );
474- };
454+ private Command getCoralBranchHeightCommand (ScoringType version ) {
455+ if (version == ScoringType .SOLOC_LEFT ) {
456+ return switch (branchHeight ) {
457+ case CORAL_LEVEL_FOUR -> superStructure
458+ .coralLevelFour (soloController .rightBumper ())
459+ .andThen (() -> soloScoringMode = soloScoringMode .NO_GAME_PIECE );
460+ case CORAL_LEVEL_THREE -> superStructure
461+ .coralLevelThree (
462+ soloController .rightBumper (),
463+ () -> AutoAlign .poseInPlace (AutoAlign .AlignType .LEFTB ))
464+ .andThen (() -> soloScoringMode = soloScoringMode .NO_GAME_PIECE );
465+ case CORAL_LEVEL_TWO -> superStructure
466+ .coralLevelTwo (
467+ soloController .rightBumper (),
468+ () -> AutoAlign .poseInPlace (AutoAlign .AlignType .LEFTB ))
469+ .andThen (() -> soloScoringMode = soloScoringMode .NO_GAME_PIECE );
470+ case CORAL_LEVEL_ONE -> superStructure
471+ .coralLevelOne (
472+ soloController .rightBumper (), () -> AutoAlign .poseInPlace (AutoAlign .AlignType .L1LB ))
473+ .andThen (() -> soloScoringMode = soloScoringMode .NO_GAME_PIECE );
474+ };
475+ } else if (version == ScoringType .SOLOC_RIGHT ) {
476+ return switch (branchHeight ) {
477+ case CORAL_LEVEL_FOUR -> superStructure
478+ .coralLevelFour (soloController .rightBumper ())
479+ .andThen (() -> soloScoringMode = soloScoringMode .NO_GAME_PIECE );
480+ case CORAL_LEVEL_THREE -> superStructure
481+ .coralLevelThree (
482+ soloController .rightBumper (),
483+ () -> AutoAlign .poseInPlace (AutoAlign .AlignType .RIGHTB ))
484+ .andThen (() -> soloScoringMode = soloScoringMode .NO_GAME_PIECE );
485+ case CORAL_LEVEL_TWO -> superStructure
486+ .coralLevelTwo (
487+ soloController .rightBumper (),
488+ () -> AutoAlign .poseInPlace (AutoAlign .AlignType .RIGHTB ))
489+ .andThen (() -> soloScoringMode = soloScoringMode .NO_GAME_PIECE );
490+ case CORAL_LEVEL_ONE -> superStructure
491+ .coralLevelOne (
492+ soloController .rightBumper (), () -> AutoAlign .poseInPlace (AutoAlign .AlignType .L1RB ))
493+ .andThen (() -> soloScoringMode = soloScoringMode .NO_GAME_PIECE );
494+ };
495+ } else {
496+ return switch (branchHeight ) {
497+ case CORAL_LEVEL_FOUR -> superStructure .coralLevelFour (driverController .rightBumper ());
498+ case CORAL_LEVEL_THREE -> superStructure .coralLevelThree (driverController .rightBumper ());
499+ case CORAL_LEVEL_TWO -> superStructure .coralLevelTwo (driverController .rightBumper ());
500+ case CORAL_LEVEL_ONE -> superStructure .coralLevelOne (driverController .rightBumper ());
501+ };
502+ }
475503 }
476504
477505 private void configureElevatorBindings () {
@@ -806,12 +834,12 @@ private void configureAutoAlignBindings() {
806834 .rightTrigger ()
807835 .and (() -> scoringMode == ScoringMode .CORAL )
808836 .and (() -> branchHeight != BranchHeight .CORAL_LEVEL_ONE )
809- .whileTrue (AutoAlign .autoAlignRight (s .drivebaseSubsystem , this ));
837+ .whileTrue (AutoAlign .autoAlign (s .drivebaseSubsystem , this , AutoAlign . AlignType . RIGHTB ));
810838 driverController
811839 .leftTrigger ()
812840 .and (() -> scoringMode == ScoringMode .CORAL )
813841 .and (() -> branchHeight != BranchHeight .CORAL_LEVEL_ONE )
814- .whileTrue (AutoAlign .autoAlignLeft (s .drivebaseSubsystem , this ));
842+ .whileTrue (AutoAlign .autoAlign (s .drivebaseSubsystem , this , AutoAlign . AlignType . LEFTB ));
815843 }
816844
817845 private void configureGroundSpinnyBindings () {
@@ -926,7 +954,7 @@ private void configureSoloControllerBindings() {
926954 switch (soloScoringMode ) {
927955 case CORAL_IN_CLAW -> {
928956 scoreCommand =
929- getSoloCoralBranchHeightCommand ( )
957+ getCoralBranchHeightCommand ( ScoringType . SOLOC_LEFT )
930958 .until (
931959 () ->
932960 soloController .a ().getAsBoolean ()
@@ -968,7 +996,12 @@ private void configureSoloControllerBindings() {
968996 .leftTrigger ()
969997 .and (() -> soloScoringMode == soloScoringMode .CORAL_IN_CLAW )
970998 .and (() -> branchHeight != BranchHeight .CORAL_LEVEL_ONE )
971- .whileTrue (AutoAlign .autoAlignLeft (s .drivebaseSubsystem , this ));
999+ .whileTrue (AutoAlign .autoAlign (s .drivebaseSubsystem , this , AutoAlign .AlignType .LEFTB ));
1000+ soloController
1001+ .leftTrigger ()
1002+ .and (() -> soloScoringMode == soloScoringMode .CORAL_IN_CLAW )
1003+ .and (() -> branchHeight == BranchHeight .CORAL_LEVEL_ONE )
1004+ .whileTrue (AutoAlign .autoAlign (s .drivebaseSubsystem , this , AutoAlign .AlignType .L1LB ));
9721005 // Processor + Auto align right + Select scoring mode Coral
9731006 soloController
9741007 .rightTrigger ()
@@ -977,7 +1010,8 @@ private void configureSoloControllerBindings() {
9771010 () -> {
9781011 Command scoreCommand =
9791012 switch (soloScoringMode ) {
980- case CORAL_IN_CLAW -> getSoloCoralBranchHeightCommand ()
1013+ case CORAL_IN_CLAW -> getCoralBranchHeightCommand (
1014+ ScoringType .SOLOC_RIGHT )
9811015 .until (
9821016 () ->
9831017 soloController .a ().getAsBoolean ()
@@ -1005,7 +1039,12 @@ private void configureSoloControllerBindings() {
10051039 .rightTrigger ()
10061040 .and (() -> soloScoringMode == soloScoringMode .CORAL_IN_CLAW )
10071041 .and (() -> branchHeight != BranchHeight .CORAL_LEVEL_ONE )
1008- .whileTrue (AutoAlign .autoAlignRight (s .drivebaseSubsystem , this ));
1042+ .whileTrue (AutoAlign .autoAlign (s .drivebaseSubsystem , this , AutoAlign .AlignType .RIGHTB ));
1043+ soloController
1044+ .rightTrigger ()
1045+ .and (() -> soloScoringMode == soloScoringMode .CORAL_IN_CLAW )
1046+ .and (() -> branchHeight == BranchHeight .CORAL_LEVEL_ONE )
1047+ .whileTrue (AutoAlign .autoAlign (s .drivebaseSubsystem , this , AutoAlign .AlignType .L1RB ));
10091048 // Ground Intake
10101049 soloController
10111050 .leftBumper ()
@@ -1095,11 +1134,5 @@ private void configureSoloControllerBindings() {
10951134 .startMovingVoltage (
10961135 () -> Volts .of (ElevatorSubsystem .UP_VOLTAGE * -soloController .getLeftY ()))
10971136 .withName ("Elevator Manual Control" ));
1098- // Ready to score rumble
1099- Trigger readyToScore = new Trigger (() -> AutoAlign .poseInPlace ());
1100- readyToScore .onTrue (
1101- Commands .runOnce (() -> soloController .setRumble (RumbleType .kBothRumble , 1.0 )));
1102- readyToScore .onFalse (
1103- Commands .runOnce (() -> soloController .setRumble (RumbleType .kBothRumble , 0.0 )));
11041137 }
11051138}
0 commit comments