Skip to content

Commit d79c533

Browse files
committed
feat: add intake & scoring mode
1 parent ae949cd commit d79c533

File tree

3 files changed

+20
-21
lines changed

3 files changed

+20
-21
lines changed

src/main/java/frc/team5115/DriverController.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import edu.wpi.first.wpilibj2.command.Command;
44
import edu.wpi.first.wpilibj2.command.Commands;
55
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
6-
import frc.team5115.Constants.AutoConstants.Side;
76
import frc.team5115.commands.DriveCommands;
87
import frc.team5115.subsystems.drive.Drivetrain;
98

@@ -16,25 +15,18 @@ public class DriverController {
1615
private boolean robotRelative = false;
1716
private boolean slowMode = false;
1817

19-
public DriverController(
20-
int port,
21-
Drivetrain drivetrain) {
18+
public DriverController(int port, Drivetrain drivetrain) {
2219
joyDrive = new CommandXboxController(port);
2320
joyManip = null;
2421

2522
this.drivetrain = drivetrain;
26-
2723
}
2824

29-
public DriverController(
30-
int drivePort,
31-
int manipPort,
32-
Drivetrain drivetrain) {
25+
public DriverController(int drivePort, int manipPort, Drivetrain drivetrain) {
3326
joyDrive = new CommandXboxController(drivePort);
3427
joyManip = new CommandXboxController(manipPort);
3528

3629
this.drivetrain = drivetrain;
37-
3830
}
3931

4032
private Command offsetGyro() {
@@ -46,8 +38,8 @@ public boolean isConnected() {
4638
}
4739

4840
private void configureSingleMode() {}
41+
4942
private void configureDualMode() {}
50-
5143

5244
public void configureButtonBindings() {
5345
// drive control

src/main/java/frc/team5115/commands/DriveCommands.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import frc.team5115.subsystems.drive.Drivetrain;
1414
import frc.team5115.subsystems.intakewheel.IntakeWheel;
1515
import frc.team5115.subsystems.outtake.Outtake;
16-
1716
import java.util.function.BooleanSupplier;
1817
import java.util.function.DoubleSupplier;
1918

@@ -74,19 +73,22 @@ public static Command joystickDrive(
7473

7574
public static Command modeSwap(boolean intakeMode, IntakeWheel intakeWheel, Arm arm) {
7675
return Commands.either(
77-
Commands.parallel(intakeWheel.intake(), arm.deploy()),
78-
Commands.parallel(intakeWheel.stop(), arm.stow()),
76+
intakeMode(),
77+
scoringMode(),
7978
() -> intakeMode);
8079
}
8180

82-
public static Command intakeMode(IntakeWheel intakeWheel, Arm arm) {
81+
public static Command intakeMode(IntakeWheel intakeWheel, Arm arm, Outtake outtake) {
8382
return Commands.repeatingSequence(
84-
Commands.parallel(intakeWheel.intake(), arm.deploy()),
83+
Commands.parallel(intakeWheel.intake(), arm.deploy(), outtake.retract(), outtake.allowExtend(false)),
8584
(arm.waitForSensorState(true, Double.POSITIVE_INFINITY)),
86-
arm.stow());
85+
arm.stow(),
86+
arm.waitForSetpoint(5.0),
87+
intakeWheel.setSpeed(-1));
8788
}
8889

89-
public static Command scoringMode(Outtake outtake) {
90-
return
90+
public static Command scoringMode(IntakeWheel intakeWheel, Arm arm, Outtake outtake) {
91+
return Commands.sequence(
92+
Commands.parallel(arm.stow(), intakeWheel.stop()), outtake.allowExtend(true));
9193
}
9294
}

src/main/java/frc/team5115/subsystems/outtake/Outtake.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
public class Outtake extends SubsystemBase {
99
private final OuttakeIO io;
1010
private final OuttakeIOInputsAutoLogged inputs = new OuttakeIOInputsAutoLogged();
11+
public boolean canExtend;
1112

1213
public Outtake(OuttakeIO io) {
1314
this.io = io;
@@ -19,11 +20,15 @@ public void periodic() {
1920
Logger.processInputs(this.getName(), inputs);
2021
}
2122

22-
private Command extend() {
23+
public Command extend() {
2324
return Commands.runOnce(() -> io.setPneumatic(true), this);
2425
}
2526

26-
private Command retract() {
27+
public Command retract() {
2728
return Commands.runOnce(() -> io.setPneumatic(false), this);
2829
}
30+
31+
public Command allowExtend(boolean allowExtend) {
32+
return Commands.runOnce(() -> canExtend = allowExtend);
33+
}
2934
}

0 commit comments

Comments
 (0)