Skip to content

Commit b4ff039

Browse files
authored
Fix outtaking (#149)
* fix outtaking command bindings * avoid null pointer
1 parent 9625f0e commit b4ff039

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

src/main/java/frc/robot/Robot.java

+10-3
Original file line numberDiff line numberDiff line change
@@ -352,12 +352,19 @@ private void configureDriverButtonBindings() {
352352

353353
// Outtake grippers
354354
var outtaking = driver.HIn();
355+
outtaking.onTrue(new InstantCommand(() -> rememberOutputPose()));
355356
lifter.atProcessor.and(outtaking)
356357
.whileTrue(algaeRoller.outtakeToProcessor());
357-
lifter.atProcessor.negate().and(outtaking)
358+
lifter.atAlgaeElse.and(outtaking)
358359
.whileTrue(algaeRoller.outtakeToBarge());
359-
outtaking
360-
.onTrue(new InstantCommand(() -> rememberOutputPose()));
360+
lifter.atCoralL1.and(outtaking)
361+
.whileTrue(coralRoller.outtakeToL1());
362+
lifter.atCoralL2.and(outtaking)
363+
.whileTrue(coralRoller.outtakeToL2());
364+
lifter.atCoralL3.and(outtaking)
365+
.whileTrue(coralRoller.outtakeToL3());
366+
lifter.atCoralElse.and(outtaking)
367+
.whileTrue(coralRoller.outtakeToL4());
361368
}
362369

363370
private void configureOperatorButtonBindings() {

src/main/java/frc/robot/elevator/Elevator.java

+14-14
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ public Command coralL4PositionCG() {
5757
lifter.setHeight(LifterState.CoralL4).schedule();
5858
coralWrist.setAngle(CoralWristState.L4).schedule();
5959
algaeWrist.setAngle(AlgaeWristState.CoralMode).schedule();
60-
coralRoller.getCurrentCommand().cancel();
61-
algaeRoller.getCurrentCommand().cancel();
60+
coralRoller.stop().schedule();
61+
algaeRoller.stop().schedule();
6262
});
6363
}
6464

@@ -68,8 +68,8 @@ public Command coralL3PositionCG() {
6868
lifter.setHeight(LifterState.CoralL3).schedule();
6969
coralWrist.setAngle(CoralWristState.L3).schedule();
7070
algaeWrist.setAngle(AlgaeWristState.CoralMode).schedule();
71-
coralRoller.getCurrentCommand().cancel();
72-
algaeRoller.getCurrentCommand().cancel();
71+
coralRoller.stop().schedule();
72+
algaeRoller.stop().schedule();
7373
});
7474
}
7575

@@ -79,8 +79,8 @@ public Command coralL2PositionCG() {
7979
lifter.setHeight(LifterState.CoralL2).schedule();
8080
coralWrist.setAngle(CoralWristState.L2).schedule();
8181
algaeWrist.setAngle(AlgaeWristState.CoralMode).schedule();
82-
coralRoller.getCurrentCommand().cancel();
83-
algaeRoller.getCurrentCommand().cancel();
82+
coralRoller.stop().schedule();
83+
algaeRoller.stop().schedule();
8484
});
8585
}
8686

@@ -90,8 +90,8 @@ public Command coralL1PositionCG() {
9090
lifter.setHeight(LifterState.CoralL1).schedule();
9191
coralWrist.setAngle(CoralWristState.L1).schedule();
9292
algaeWrist.setAngle(AlgaeWristState.CoralMode).schedule();
93-
coralRoller.getCurrentCommand().cancel();
94-
algaeRoller.getCurrentCommand().cancel();
93+
coralRoller.stop().schedule();
94+
algaeRoller.stop().schedule();
9595
});
9696
}
9797

@@ -102,7 +102,7 @@ public Command coralIntakeCG() {
102102
coralWrist.setAngle(CoralWristState.Intake).schedule();
103103
algaeWrist.setAngle(AlgaeWristState.CoralMode).schedule();
104104
coralRoller.intake().schedule();
105-
algaeRoller.getCurrentCommand().cancel();
105+
algaeRoller.stop().schedule();
106106
});
107107
}
108108

@@ -112,7 +112,7 @@ public Command algaeBargePositionCG() {
112112
lifter.setHeight(LifterState.AlgaeBarge).schedule();
113113
coralWrist.setAngle(CoralWristState.AlgaeMode).schedule();
114114
algaeWrist.setAngle(AlgaeWristState.Barge).schedule();
115-
coralRoller.getCurrentCommand().cancel();
115+
coralRoller.stop().schedule();
116116
});
117117
}
118118

@@ -122,7 +122,7 @@ public Command algaeL3IntakeCG() {
122122
lifter.setHeight(LifterState.AlgaeL3).schedule();
123123
coralWrist.setAngle(CoralWristState.AlgaeMode).schedule();
124124
algaeWrist.setAngle(AlgaeWristState.L3).schedule();
125-
coralRoller.getCurrentCommand().cancel();
125+
coralRoller.stop().schedule();
126126
algaeRoller.intake().schedule();
127127
});
128128
}
@@ -133,7 +133,7 @@ public Command algaeL2IntakeCG() {
133133
lifter.setHeight(LifterState.AlgaeL2).schedule();
134134
coralWrist.setAngle(CoralWristState.AlgaeMode).schedule();
135135
algaeWrist.setAngle(AlgaeWristState.L2).schedule();
136-
coralRoller.getCurrentCommand().cancel();
136+
coralRoller.stop().schedule();
137137
algaeRoller.intake().schedule();
138138
});
139139
}
@@ -144,7 +144,7 @@ public Command algaeProcessorPositionCG() {
144144
lifter.setHeight(LifterState.AlgaeProcessor).schedule();
145145
coralWrist.setAngle(CoralWristState.AlgaeMode).schedule();
146146
algaeWrist.setAngle(AlgaeWristState.Processor).schedule();
147-
coralRoller.getCurrentCommand().cancel();
147+
coralRoller.stop().schedule();
148148
});
149149
}
150150

@@ -154,7 +154,7 @@ public Command algaeFloorIntakeCG() {
154154
lifter.setHeight(LifterState.AlgaeIntakeFloor).schedule();
155155
coralWrist.setAngle(CoralWristState.AlgaeMode).schedule();
156156
algaeWrist.setAngle(AlgaeWristState.Floor).schedule();
157-
coralRoller.getCurrentCommand().cancel();
157+
coralRoller.stop().schedule();
158158
algaeRoller.intake().schedule();
159159
});
160160
}

0 commit comments

Comments
 (0)