25
25
import edu .wpi .first .wpilibj2 .command .InstantCommand ;
26
26
import edu .wpi .first .wpilibj2 .command .button .CommandXboxController ;
27
27
import frc .robot .commands .LED .LEDRunnable ;
28
+ import frc .robot .commands .auto .AutoLimelight ;
28
29
import frc .robot .commands .auto .AutoStartDelivery ;
29
30
import frc .robot .commands .auto .AutoStartDeliveryTemp ;
30
31
import frc .robot .commands .auto .AutoStartDeliveryToSensor ;
@@ -97,7 +98,7 @@ public class RobotContainer {
97
98
private void configureBindings () {
98
99
drivetrain .registerTelemetry (logger ::telemeterize );
99
100
drivetrain .setDefaultCommand (new SwerveDriveCommand (drivetrain , driverJoystick , () -> getDrivetrainVelocityY (), () -> getAllianceColor ()));
100
- led .setDefaultCommand (new LEDRunnable (led , ()-> intake .getIntakeSensor (), () -> delivery .getDeliveryTopSensor (), () -> shooter .getShooterUpToSpeed ()).ignoringDisable (true ));
101
+ led .setDefaultCommand (new LEDRunnable (led , ()-> intake .getIntakeSensor (), () -> delivery .getDeliveryTopSensor (), () -> delivery . getDeliveryBottomSensor (), () -> shooter .getShooterUpToSpeed ()).ignoringDisable (true ));
101
102
102
103
//driverJoystick.back().whileTrue(new InstantCommand(() -> setMaxSpeed(Constants.Swerve.driveScale))).onFalse(new InstantCommand(() -> setMaxSpeed(1)));
103
104
driverJoystick .povLeft ().onTrue (new InstantCommand (() -> drivetrain .setRotationAngle (90 )));
@@ -114,9 +115,9 @@ private void configureBindings() {
114
115
)
115
116
));
116
117
117
- driverJoystick .a ().whileTrue (new InstantCommand ( () -> drivetrain . setVisionRotate ( true ) )
118
+ driverJoystick .a ().whileTrue (new VisionRotate ( drivetrain , driverJoystick , "limelight-blue" , () -> allianceColor )
118
119
.alongWith (new SetShooterPosByVision (shooterPot , () -> drivetrain .getPose (), () -> getAllianceColor (), () -> getDrivetrainVelocityX (), () -> delivery .getDeliveryTopSensor ())));
119
- driverJoystick .a ().onFalse (new InstantCommand (() -> drivetrain .setVisionRotate (false )));
120
+ // driverJoystick.a().onFalse(new InstantCommand(() -> drivetrain.setVisionRotate(false)));
120
121
//driverJoystick.leftStick().whileTrue(new SetShooterPosByVision(shooterPot, () -> drivetrain.getPose(), () -> getAllianceColor(), () -> getDrivetrainVelocityX(), () -> delivery.getDeliveryTopSensor()));
121
122
// driverJoystick.b().onTrue(new InstantCommand(() -> delivery.engageNoteStop()));
122
123
// driverJoystick.b().onFalse(new InstantCommand(() -> delivery.disengageNoteStop()));
@@ -127,12 +128,12 @@ private void configureBindings() {
127
128
driverJoystick .rightBumper ().onTrue (new InstantCommand (() -> drivetrain .setAngleToZero ()));
128
129
driverJoystick .rightBumper ().onFalse (new InstantCommand (() -> drivetrain .setDriveAtAngleFalse ()));
129
130
130
- driverJoystick .leftTrigger ().whileTrue (Commands .parallel (new HalfCourt (shooter , () -> drivetrain . getState (). Pose . getY ()),
131
+ driverJoystick .leftTrigger ().whileTrue (Commands .parallel (new HalfCourt (shooter , () -> isChainShot ()),
131
132
new InstantCommand (() -> drivetrain .setDriveAtAngleFalse ()),
132
133
new ConditionalCommand (
133
134
new InstantCommand (() -> shooterPot .setSetpoint (Constants .ShooterPosPot .SHOOTERPOT_HALF_COURT )),
134
135
new InstantCommand (() -> shooterPot .setSetpoint (Constants .ShooterPosPot .SHOOTERPOT_HALF_CHAIN_COURT )),
135
- () -> (drivetrain . getState (). Pose . getY () >= Constants . FieldElements . cartman && drivetrain . getState (). Pose . getY () <= Constants . FieldElements . longwood )
136
+ () -> (isChainShot () )
136
137
),
137
138
// new DelayedDelivery(delivery, Constants.Delivery.DELIVERY_FORWARD_SPEED, () -> shooter.getShooterUpToSpeed()),
138
139
new ConditionalCommand (
@@ -192,7 +193,7 @@ private void configureBindings() {
192
193
//operatorJoystick.back().whileTrue(new SetClimbSpeed(climb, () -> Utilities.deadband(operatorJoystick.getRightY(), 0.1)));
193
194
//*************Operator Station *****************/
194
195
//operatorStation.blueButton.onTrue(new InstantCommand(() -> climb.setClimberPosition(-65)));
195
- operatorStation .blueButton .whileTrue (new SetClimbSpeed (climb , () -> -0.6 ));
196
+ // operatorStation.blueButton.whileTrue(new SetClimbSpeed(climb, () -> -0.6));
196
197
operatorStation .whiteButton .whileTrue (new SetClimbSpeed (climb , () -> -0.6 ));
197
198
operatorStation .yellowButton .whileTrue (new SetClimbSpeed (climb , () -> 0.6 ));
198
199
operatorStation .blackButton .whileTrue (new InstantCommand (() -> drivetrain .setRotationAngle (getAmpRotationAngle ()))
@@ -205,6 +206,7 @@ private void configureBindings() {
205
206
operatorStation .clearSwitch .whileTrue (new DeliveryServoOverride (servo ));
206
207
operatorStation .redLeftSwitch .onTrue (new InstantCommand (() -> drivetrain .setRotationAngle (getEndgameRotationAngleLeft ())));
207
208
operatorStation .redRightSwitch .onTrue (new InstantCommand (() -> drivetrain .setRotationAngle (getEndgameRotationAngleRight ())));
209
+ operatorStation .blueButton .whileTrue (new AutoLimelight (() -> startNoteDetecton ()));
208
210
209
211
//************* Test Joystick *****************/
210
212
// testJoystick.a().onTrue(new InstantCommand(() -> climb.setClimberSetpoint(10)));
@@ -297,6 +299,8 @@ public RobotContainer() {
297
299
NamedCommands .registerCommand ("StopShooter" , new InstantCommand (() -> shooter .setShooterDutyCycleZero ()));
298
300
NamedCommands .registerCommand ("UseLimelight" , new InstantCommand (() -> useLimelight ()));
299
301
NamedCommands .registerCommand ("DontUseLimelight" , new InstantCommand (() -> dontUseLimelight ()));
302
+ NamedCommands .registerCommand ("AutoDetect" , new AutoLimelight (() -> startNoteDetecton ()));
303
+
300
304
301
305
302
306
/*
@@ -435,6 +439,26 @@ public PathPlannerPath goToAmp() {
435
439
return path ;
436
440
}
437
441
442
+ public boolean isChainShot () {
443
+ return drivetrain .getState ().Pose .getY () >= Constants .FieldElements .cartman && drivetrain .getState ().Pose .getY () <= Constants .FieldElements .longwood ;
444
+ }
445
+
446
+ public boolean startNoteDetecton () {
447
+ if (allianceColor == "blue" ) {
448
+ if (drivetrain .getState ().Pose .getX () >= 5 ) {
449
+ return true ;
450
+ } else {
451
+ return false ;
452
+ }
453
+ } else {
454
+ if (drivetrain .getState ().Pose .getX () <= 12 ) {
455
+ return true ;
456
+ } else {
457
+ return false ;
458
+ }
459
+ }
460
+ }
461
+
438
462
public boolean doWeHaveNote () {
439
463
return (intake .getIntakeSensor () || delivery .getDeliveryBottomSensor () || delivery .getDeliveryTopSensor ());
440
464
}
0 commit comments