Skip to content

Commit cb8f8b9

Browse files
committed
finish score L1
1 parent 19c2504 commit cb8f8b9

File tree

10 files changed

+74
-39
lines changed

10 files changed

+74
-39
lines changed

src/main/java/frc/robot/commands/compound/IntakeCoral.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
public 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
}

src/main/java/frc/robot/commands/compound/ScoreL1.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
import edu.wpi.first.wpilibj2.command.InstantCommand;
44
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
5-
import edu.wpi.first.wpilibj2.command.WaitCommand;
65
import 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;
88
import frc.robot.subsystems.intake.pivot.IntakePivot;
99
import 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
}

src/main/java/frc/robot/commands/intake/AlignForHandoff.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff 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

src/main/java/frc/robot/commands/intake/HandoffCoral.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff 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
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
}

src/main/java/frc/robot/commands/intake/RunIntake.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff 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
}

src/main/java/frc/robot/commands/intake/intakepivot/IntakePivotToPosition.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

src/main/java/frc/robot/commands/intake/intakeroller/OuttakeCoral.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff 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
}

src/main/java/frc/robot/subsystems/intake/roller/IntakeRoller.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package frc.robot.subsystems.intake.roller;
22

3-
import static frc.robot.subsystems.elevator.ElevatorConstants.*;
3+
import static frc.robot.subsystems.intake.roller.IntakeRollerConstants.*;
44

55
import edu.wpi.first.wpilibj2.command.SubsystemBase;
66
import frc.robot.lib.LoggedTunableNumber;
7+
import frc.robot.lib.util.EqualsUtil;
78
import java.util.function.DoubleSupplier;
89
import lombok.Getter;
10+
import lombok.Setter;
911
import org.littletonrobotics.junction.AutoLogOutput;
1012
import 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
}

src/main/java/frc/robot/subsystems/outtake/wrist/Wrist.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import frc.robot.lib.util.EqualsUtil;
88
import frc.robot.subsystems.elevator.Elevator.ElevatorGoal;
99
import java.util.function.DoubleSupplier;
10-
1110
import lombok.Getter;
1211
import lombok.Setter;
1312
import org.littletonrobotics.junction.AutoLogOutput;

0 commit comments

Comments
 (0)