File tree Expand file tree Collapse file tree 10 files changed +74
-39
lines changed
Expand file tree Collapse file tree 10 files changed +74
-39
lines changed Original file line number Diff line number Diff line change 99public class IntakeCoral extends SequentialCommandGroup {
1010
1111 public IntakeCoral (RobotContainer robot ) {
12- addCommands (
13- new RunIntake (robot ),
14- new AlignForHandoff (robot ),
15- new HandoffCoral (robot ));
12+ addCommands (new RunIntake (robot ), new AlignForHandoff (robot ), new HandoffCoral (robot ));
1613 }
1714}
Original file line number Diff line number Diff line change 22
33import edu .wpi .first .wpilibj2 .command .InstantCommand ;
44import edu .wpi .first .wpilibj2 .command .SequentialCommandGroup ;
5- import edu .wpi .first .wpilibj2 .command .WaitCommand ;
65import frc .robot .RobotContainer ;
7- import frc .robot .commands .intake .intakeroller .OuttakeCoral ;
6+ import frc .robot .commands .intake .OuttakeL1 ;
7+ import frc .robot .commands .intake .intakepivot .IntakePivotToPosition ;
88import frc .robot .subsystems .intake .pivot .IntakePivot ;
99import frc .robot .subsystems .intake .pivot .IntakePivot .IntakePivotGoal ;
1010
@@ -17,8 +17,8 @@ public ScoreL1(RobotContainer robot) {
1717 addRequirements (intakePivot );
1818
1919 addCommands (
20- new InstantCommand ( () -> intakePivot . runPosition ( IntakePivotGoal .TO_SCOREL1 ) ),
21- new WaitCommand ( 0.7 ),
22- new OuttakeCoral ( robot ));
20+ new IntakePivotToPosition ( robot , () -> IntakePivotGoal .TO_SCOREL1 ),
21+ new OuttakeL1 ( robot ),
22+ new InstantCommand (() -> robot . getIntakePivot (). setCurrentGoal ( IntakePivotGoal . TO_INTAKE_HANDOFF ) ));
2323 }
2424}
Original file line number Diff line number Diff line change @@ -30,9 +30,10 @@ public void execute() {}
3030
3131 @ Override
3232 public boolean isFinished () {
33- return pivot .getCurrentGoal () == IntakePivotGoal .TO_INTAKE_HANDOFF &&
34- wrist .getCurrentGoal () == WristGoal .HANDOFF &&
35- pivot .atGoal () && wrist .atGoal ();
33+ return pivot .getCurrentGoal () == IntakePivotGoal .TO_INTAKE_HANDOFF
34+ && wrist .getCurrentGoal () == WristGoal .HANDOFF
35+ && pivot .atGoal ()
36+ && wrist .atGoal ();
3637 }
3738
3839 @ Override
Original file line number Diff line number Diff line change @@ -33,18 +33,17 @@ public void initialize() {
3333
3434 @ Override
3535 public void execute () {
36- roller .setGoal (IntakeRollerGoal .OUTTAKEENDEFFECTOR );
36+ roller .setCurrentGoal (IntakeRollerGoal .OUTTAKEENDEFFECTOR );
3737 endEffector .setGoal (EndEffectorRollerGoal .INTAKE );
3838 }
3939
4040 @ Override
4141 public boolean isFinished () {
42- return (beamBreak .gamepieceInEndEffector () && !beamBreak .coralInIntake ())
43- || timer .hasElapsed (kTimeOutTime );
42+ return (beamBreak .gamepieceInEndEffector () && !beamBreak .coralInIntake ()) || timer .hasElapsed (kTimeOutTime );
4443 }
4544
4645 @ Override
4746 public void end (boolean isFinished ) {
48- roller .setGoal (IntakeRollerGoal .IDLE );
47+ roller .setCurrentGoal (IntakeRollerGoal .IDLE );
4948 }
5049}
Original file line number Diff line number Diff line change 1+ package frc .robot .commands .intake ;
2+
3+ import edu .wpi .first .wpilibj2 .command .Command ;
4+ import frc .robot .RobotContainer ;
5+ import frc .robot .subsystems .beambreak .Beambreak ;
6+ import frc .robot .subsystems .intake .roller .IntakeRoller ;
7+ import frc .robot .subsystems .intake .roller .IntakeRoller .IntakeRollerGoal ;
8+
9+ public class OuttakeL1 extends Command {
10+
11+ private final Beambreak beambreak ;
12+ private final IntakeRoller roller ;
13+
14+ public OuttakeL1 (RobotContainer robot ) {
15+ beambreak = robot .getBeamBreak ();
16+ roller = robot .getIntakeRoller ();
17+
18+ addRequirements (roller );
19+ }
20+
21+ @ Override
22+ public void initialize () {
23+ roller .setCurrentGoal (IntakeRollerGoal .OUTTAKECORRAL );
24+ }
25+
26+ @ Override
27+ public void execute () {}
28+
29+ @ Override
30+ public boolean isFinished () {
31+ return !beambreak .coralInIntake ();
32+ }
33+
34+ @ Override
35+ public void end (boolean isFinished ) {
36+ roller .setCurrentGoal (IntakeRollerGoal .IDLE );
37+ }
38+ }
Original file line number Diff line number Diff line change @@ -23,28 +23,26 @@ public RunIntake(RobotContainer robot) {
2323 beamBreak = robot .getBeamBreak ();
2424 pivot = robot .getIntakePivot ();
2525 addRequirements (roller , pivot );
26- timer = new Timer ();
26+ timer = new Timer ();
2727 }
2828
2929 @ Override
3030 public void initialize () {
3131 timer .reset ();
32- roller .setGoal (IntakeRollerGoal .INTAKE );
32+ roller .setCurrentGoal (IntakeRollerGoal .INTAKE );
3333 pivot .runPosition (IntakePivotGoal .TO_INTAKE );
3434 }
35-
35+
3636 @ Override
3737 public void execute () {}
38-
38+
3939 @ Override
4040 public boolean isFinished () {
41- return beamBreak .coralInIntake ()
42- || timer .hasElapsed (kTimeOutTime );
43-
41+ return beamBreak .coralInIntake () || timer .hasElapsed (kTimeOutTime );
4442 }
45-
43+
4644 @ Override
4745 public void end (boolean isFinished ) {
48- roller .setGoal (IntakeRollerGoal .IDLE );
46+ roller .setCurrentGoal (IntakeRollerGoal .IDLE );
4947 }
5048}
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ public void execute() {
2828
2929 @ Override
3030 public boolean isFinished () {
31- return intake .atGoal ();
31+ return intake .getCurrentGoal () == goal . get () && intake . atGoal ();
3232 }
3333
3434 @ Override
Original file line number Diff line number Diff line change @@ -19,19 +19,19 @@ public OuttakeCoral(RobotContainer robot) {
1919
2020 @ Override
2121 public void initialize () {
22- roller .setGoal (IntakeRollerGoal .OUTTAKECORRAL );
22+ roller .setCurrentGoal (IntakeRollerGoal .OUTTAKECORRAL );
2323 }
24-
24+
2525 @ Override
2626 public void execute () {}
27-
27+
2828 @ Override
2929 public boolean isFinished () {
3030 return !beamBreak .coralInIntake ();
3131 }
32-
32+
3333 @ Override
3434 public void end (boolean isFinished ) {
35- roller .setGoal (IntakeRollerGoal .IDLE );
35+ roller .setCurrentGoal (IntakeRollerGoal .IDLE );
3636 }
3737}
Original file line number Diff line number Diff line change 11package frc .robot .subsystems .intake .roller ;
22
3- import static frc .robot .subsystems .elevator . ElevatorConstants .*;
3+ import static frc .robot .subsystems .intake . roller . IntakeRollerConstants .*;
44
55import edu .wpi .first .wpilibj2 .command .SubsystemBase ;
66import frc .robot .lib .LoggedTunableNumber ;
7+ import frc .robot .lib .util .EqualsUtil ;
78import java .util .function .DoubleSupplier ;
89import lombok .Getter ;
10+ import lombok .Setter ;
911import org .littletonrobotics .junction .AutoLogOutput ;
1012import org .littletonrobotics .junction .Logger ;
1113
@@ -41,16 +43,14 @@ private IntakeRollerGoal(DoubleSupplier rollerVel) {
4143 }
4244 }
4345
44- IntakeRollerGoal currentGoal = IntakeRollerGoal .IDLE ;
46+ @ Getter
47+ @ Setter
48+ private IntakeRollerGoal currentGoal = IntakeRollerGoal .IDLE ;
4549
4650 public IntakeRoller (IntakeRollerIO io ) {
4751 this .io = io ;
4852 }
4953
50- public void setGoal (IntakeRollerGoal goal ) {
51- currentGoal = goal ;
52- }
53-
5454 @ Override
5555 public void periodic () {
5656 io .updateInputs (inputs );
@@ -77,6 +77,9 @@ public void periodic() {
7777 */
7878 @ AutoLogOutput (key = "Intake Roller/At Goal" )
7979 public boolean atGoal () {
80- return false ;
80+ return EqualsUtil .epsilonEquals (
81+ (inputs .motorVelocityRPS [0 ] + inputs .motorVelocityRPS [1 ]) / 2 ,
82+ currentGoal .getRollerVel ().getAsDouble (),
83+ kVelocityTolerance );
8184 }
8285}
Original file line number Diff line number Diff line change 77import frc .robot .lib .util .EqualsUtil ;
88import frc .robot .subsystems .elevator .Elevator .ElevatorGoal ;
99import java .util .function .DoubleSupplier ;
10-
1110import lombok .Getter ;
1211import lombok .Setter ;
1312import org .littletonrobotics .junction .AutoLogOutput ;
You can’t perform that action at this time.
0 commit comments