Skip to content

Commit 99ae816

Browse files
committed
partial new state setup for drive
1 parent d79c533 commit 99ae816

File tree

5 files changed

+22
-26
lines changed

5 files changed

+22
-26
lines changed

gradlew

100644100755
File mode changed.

src/main/java/frc/team5115/RobotContainer.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ public class RobotContainer {
6969
private boolean slowMode = false;
7070
private boolean hasFaults = true;
7171
private double faultPrintTimeout = 0;
72-
private boolean intakeMode = false;
7372

74-
/** The container for the robot. Contains subsystems, OI devices, and commands. */
73+
/** The container for the robot. Contains subsystems, IO devices, and commands. */
7574
public RobotContainer() {
7675
AutoConstants.precomputeAlignmentPoses(); // Computes robot starting pose with vision
7776
switch (Constants.currentMode) {
@@ -284,6 +283,9 @@ private Command offsetGyro() {
284283

285284
public void teleopInit() {
286285
drivetrain.setTeleopCurrentLimit();
286+
arm.sensorTrigger
287+
.onTrue(outtake.setLock(true))
288+
.onFalse(Commands.sequence(Commands.waitSeconds(1), outtake.setLock(false)));
287289
// drivetrain.offsetGyro(Rotation2d.fromDegrees(-90));
288290
}
289291

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

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import frc.team5115.subsystems.arm.Arm;
1313
import frc.team5115.subsystems.drive.Drivetrain;
1414
import frc.team5115.subsystems.intakewheel.IntakeWheel;
15-
import frc.team5115.subsystems.outtake.Outtake;
15+
1616
import java.util.function.BooleanSupplier;
1717
import java.util.function.DoubleSupplier;
1818

@@ -71,24 +71,7 @@ public static Command joystickDrive(
7171
drivetrain);
7272
}
7373

74-
public static Command modeSwap(boolean intakeMode, IntakeWheel intakeWheel, Arm arm) {
75-
return Commands.either(
76-
intakeMode(),
77-
scoringMode(),
78-
() -> intakeMode);
79-
}
80-
81-
public static Command intakeMode(IntakeWheel intakeWheel, Arm arm, Outtake outtake) {
82-
return Commands.repeatingSequence(
83-
Commands.parallel(intakeWheel.intake(), arm.deploy(), outtake.retract(), outtake.allowExtend(false)),
84-
(arm.waitForSensorState(true, Double.POSITIVE_INFINITY)),
85-
arm.stow(),
86-
arm.waitForSetpoint(5.0),
87-
intakeWheel.setSpeed(-1));
88-
}
89-
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));
74+
public Command xferLunite(Arm arm, IntakeWheel intakeWheel) {
75+
return Commands.sequence(arm.deploy(), intakeWheel.intake(), arm.waitForSensorState(true, Double.POSITIVE_INFINITY), arm.stow(), intakeWheel.setSpeed(-1), Commands.waitSeconds(1));
9376
}
9477
}

src/main/java/frc/team5115/subsystems/arm/Arm.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import edu.wpi.first.wpilibj2.command.Command;
99
import edu.wpi.first.wpilibj2.command.Commands;
1010
import edu.wpi.first.wpilibj2.command.SubsystemBase;
11+
import edu.wpi.first.wpilibj2.command.button.Trigger;
1112
import frc.team5115.Constants;
1213
import java.util.ArrayList;
1314
import org.littletonrobotics.junction.Logger;
@@ -18,6 +19,7 @@ public class Arm extends SubsystemBase {
1819
private final ArmFeedforward feedforward;
1920
private final PIDController pid;
2021
private final double ks;
22+
public final Trigger sensorTrigger;
2123

2224
public Arm(ArmIO io) {
2325
this.io = io;
@@ -43,6 +45,8 @@ public Arm(ArmIO io) {
4345

4446
pid.setTolerance(5);
4547
pid.setSetpoint(75.0);
48+
49+
sensorTrigger = new Trigger(() -> (inputs.luniteDetected == true));
4650
}
4751

4852
public void getSparks(ArrayList<SparkMax> sparks) {

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

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

1314
public Outtake(OuttakeIO io) {
1415
this.io = io;
@@ -21,14 +22,20 @@ public void periodic() {
2122
}
2223

2324
public Command extend() {
24-
return Commands.runOnce(() -> io.setPneumatic(true), this);
25+
return Commands.runOnce(
26+
() -> {
27+
if (!locked || lockOverride) {
28+
io.setPneumatic(true);
29+
}
30+
},
31+
this);
2532
}
2633

2734
public Command retract() {
2835
return Commands.runOnce(() -> io.setPneumatic(false), this);
2936
}
3037

31-
public Command allowExtend(boolean allowExtend) {
32-
return Commands.runOnce(() -> canExtend = allowExtend);
38+
public Command setLock(boolean lock) {
39+
return Commands.runOnce(() -> locked = lock);
3340
}
3441
}

0 commit comments

Comments
 (0)