Skip to content

Commit aa3b327

Browse files
fix triggers not firing bug
1 parent eb0e1ef commit aa3b327

File tree

2 files changed

+49
-34
lines changed

2 files changed

+49
-34
lines changed

src/main/java/frc/robot/RobotContainer.java

+48-33
Original file line numberDiff line numberDiff line change
@@ -157,35 +157,10 @@ public RobotContainer() {
157157
}
158158
});
159159

160-
// Set up reservoir tank
161-
reservoirTank.setPressureThresholds(15, 20);
162-
new Trigger(
163-
() ->
164-
NormUtil.norm(drive.getRobotSpeeds()) > drive.getMaxLinearSpeedMetersPerSec() * 0.75
165-
|| Math.abs(drive.getRobotSpeeds().omegaRadiansPerSecond)
166-
> drive.getMaxAngularSpeedRadPerSec() * 0.75)
167-
.debounce(0.3, DebounceType.kBoth)
168-
.whileTrue(
169-
reservoirTank
170-
.startEnd(reservoirTank::pause, reservoirTank::unpause)
171-
.withName("Pause: Drive Speed"));
172-
160+
// Pneumatics sim
173161
reservoirTank.setSimDrain(gatewayTank::isFilling);
174-
175-
// Set up gateway tank
176-
gatewayTank.setDesiredPSI(20);
177-
new Trigger(firingTube::isOpen)
178-
.or(firingTube::isWaitingToFire)
179-
.debounce(0.5, DebounceType.kBoth)
180-
.whileTrue(
181-
gatewayTank
182-
.startEnd(gatewayTank::pause, gatewayTank::unpause)
183-
.withName("Pause: Firing Tube Open"));
184162
gatewayTank.setSimDrain(firingTube::isOpen);
185163

186-
// Set up firing tube
187-
firingTube.setFireRequirements(() -> !gatewayTank.isFilling());
188-
189164
// Alerts for constants to avoid using them in competition
190165
if (Constants.TUNING_MODE) {
191166
new Alert("Tuning mode active, do not use in competition.", AlertType.INFO).set(true);
@@ -324,11 +299,13 @@ private void configureDriverControllerBindings() {
324299
boolean includeDiagonalPOV = true;
325300
for (int pov = 0; pov < 360; pov += includeDiagonalPOV ? 45 : 90) {
326301

327-
// POV angles are in Clock Wise degrees, needs to be flipped to get correct rotation2d
302+
// POV angles are in Clock Wise degrees, needs to be flipped to get correct
303+
// rotation2d
328304
final Rotation2d angle = Rotation2d.fromDegrees(-pov);
329305
final String name = String.format("%d\u00B0", pov);
330306

331-
// While the POV is being pressed and we are not in angle control mode, set the chassis
307+
// While the POV is being pressed and we are not in angle control mode, set the
308+
// chassis
332309
// speeds to the Cos and Sin of the angle
333310
driverXbox
334311
.pov(pov)
@@ -343,7 +320,8 @@ private void configureDriverControllerBindings() {
343320
drive::stop)
344321
.withName(String.format("DriveRobotRelative %s", name)));
345322

346-
// While the POV is being pressed and we are angle control mode. Start by resetting the
323+
// While the POV is being pressed and we are angle control mode. Start by
324+
// resetting the
347325
// controller and setting the goal angle to the pov angle
348326
driverXbox
349327
.pov(pov)
@@ -357,7 +335,8 @@ private void configureDriverControllerBindings() {
357335
})
358336
.withName(String.format("PrepareLockedHeading %s", name)));
359337

360-
// Then if the button is held for more than 0.2 seconds, drive forward at the angle once the
338+
// Then if the button is held for more than 0.2 seconds, drive forward at the
339+
// angle once the
361340
// chassis reaches it
362341
driverXbox
363342
.pov(pov)
@@ -377,7 +356,8 @@ private void configureDriverControllerBindings() {
377356
})
378357
.withName(String.format("ForwardLockedHeading %s", name)));
379358

380-
// Then once the pov is let go, if we are not at the angle continue turn to it, while also
359+
// Then once the pov is let go, if we are not at the angle continue turn to it,
360+
// while also
381361
// accepting x and y input to drive. Cancel once we get turn request
382362
driverXbox
383363
.pov(pov)
@@ -400,7 +380,8 @@ private void configureDriverControllerBindings() {
400380
.withName(String.format("DriveLockedHeading %s", name)));
401381
}
402382

403-
// While X is held down go into stop and go into the cross position to resistent movement,
383+
// While X is held down go into stop and go into the cross position to resistent
384+
// movement,
404385
// then once X button is let go put modules forward
405386
driverXbox
406387
.x()
@@ -409,7 +390,8 @@ private void configureDriverControllerBindings() {
409390
.startEnd(drive::stopUsingBrakeArrangement, drive::stopUsingForwardArrangement)
410391
.withName("StopWithX"));
411392

412-
// When be is pressed stop the drivetrain then idle it, cancelling all incoming commands. Also
393+
// When be is pressed stop the drivetrain then idle it, cancelling all incoming
394+
// commands. Also
413395
// do this when robot is disabled
414396
driverXbox
415397
.b()
@@ -464,20 +446,53 @@ private void configureOperatorControllerBindings() {
464446
if (operatorController instanceof CommandXboxController) {
465447
final CommandXboxController operatorXbox = (CommandXboxController) operatorController;
466448

449+
// TODO set up rest of control code in here. use default command to fill it 20, then have
450+
// another command that idles it till it reaches 15
451+
// Just display default command (fill to 20) and current command (pauses, etc) using subsystem
452+
453+
// Set up reservoir tank
454+
455+
reservoirTank.setPressureThresholds(15, 20);
456+
new Trigger(
457+
() ->
458+
NormUtil.norm(drive.getRobotSpeeds())
459+
> drive.getMaxLinearSpeedMetersPerSec() * 0.75
460+
|| Math.abs(drive.getRobotSpeeds().omegaRadiansPerSecond)
461+
> drive.getMaxAngularSpeedRadPerSec() * 0.75)
462+
.debounce(0.3, DebounceType.kBoth)
463+
.whileTrue(
464+
reservoirTank
465+
.startEnd(reservoirTank::pause, reservoirTank::unpause)
466+
.withName("Pause: Drive Speed"));
467+
467468
operatorXbox
468469
.y()
469470
.whileTrue(
470471
reservoirTank
471472
.startEnd(reservoirTank::pause, reservoirTank::unpause)
472473
.withName("Pause: Operator Y Button"));
473474

475+
// Set up gateway tank
476+
gatewayTank.setDesiredPSI(20);
477+
478+
new Trigger(firingTube::isOpen)
479+
.or(firingTube::isWaitingToFire)
480+
.debounce(0.1, DebounceType.kBoth)
481+
.whileTrue(
482+
gatewayTank
483+
.startEnd(gatewayTank::pause, gatewayTank::unpause)
484+
.withName("Pause: Firing Tube Open"));
485+
474486
operatorXbox
475487
.leftTrigger()
476488
.whileTrue(
477489
gatewayTank
478490
.startEnd(gatewayTank::pause, gatewayTank::unpause)
479491
.withName("Pause: Operator Prepare Fire"));
480492

493+
// Set up firing tube
494+
firingTube.setFireRequirements(() -> !gatewayTank.isFilling());
495+
481496
operatorXbox.rightTrigger().onTrue(firingTube.runOnce(firingTube::fire).withName("Fire"));
482497

483498
// gatewayTank.setDefaultCommand(

src/main/java/frc/robot/subsystems/pneumatics/cannon/FiringTube.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public boolean isWaitingToFire() {
6060
return waitingToFire;
6161
}
6262

63-
/** Opens the firing tube and starts the timer to close it. */
63+
/** Queues opening the firing tube and starts the timer to close it. */
6464
public void fire() {
6565
waitingToFire = true;
6666
}

0 commit comments

Comments
 (0)