From 94de44728c0a2a7957e113db5b42c7940e3e42cc Mon Sep 17 00:00:00 2001 From: TheRealGrayden Date: Thu, 5 Mar 2026 19:41:17 -0500 Subject: [PATCH] Added intake subsystem --- src/main/java/frc/robot/Constants.java | 6 +- .../java/frc/robot/subsystems/Intake.java | 98 +++++++++++++++++++ 2 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 src/main/java/frc/robot/subsystems/Intake.java diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index be5911a..16168d8 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -60,6 +60,10 @@ public final class Constants { public static final int PIGEON_ID = 1; } - + public static class IntakeConstants { + public static final int EXTEND_CHANNEL = 0; + public static final int RETRACT_CHANNEL = 1; + public static final int INTAKE_MOTOR_ID = 2; + } } diff --git a/src/main/java/frc/robot/subsystems/Intake.java b/src/main/java/frc/robot/subsystems/Intake.java new file mode 100644 index 0000000..0ebfee1 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/Intake.java @@ -0,0 +1,98 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package frc.robot.subsystems; + +import org.fairportrobotics.frc.posty.TestableSubsystem; +import org.fairportrobotics.frc.posty.test.PostTest; + +import com.ctre.phoenix6.hardware.TalonFX; +import frc.robot.Constants; +import static org.fairportrobotics.frc.posty.assertions.Assertions.*; + +import edu.wpi.first.wpilibj.DigitalOutput; +import edu.wpi.first.wpilibj2.command.Command; + +public class Intake extends TestableSubsystem { + /** Creates a new ExampleSubsystem. */ + public Intake() + { + extendRelay = new DigitalOutput(Constants.IntakeConstants.EXTEND_CHANNEL); + retractRelay = new DigitalOutput(Constants.IntakeConstants.RETRACT_CHANNEL); + intakeMotor = new TalonFX(Constants.IntakeConstants.INTAKE_MOTOR_ID); + retractRelay.set(false); + extendRelay.set(false); + } + + public void neutral() + { + retractRelay.set(false); + extendRelay.set(false); + } + + public void extend() + { + retractRelay.set(false); + extendRelay.set(true); + } + + public void retract() + { + extendRelay.set(false); + retractRelay.set(true); + } + + public void setSpeed(double speed) + { + intakeMotor.set(speed); + } + + private DigitalOutput extendRelay; + private DigitalOutput retractRelay; + private TalonFX intakeMotor; + + /** + * Example command factory method. + * + * @return a command + */ + public Command exampleMethodCommand() { + // Inline construction of command goes here. + // Subsystem::RunOnce implicitly requires `this` subsystem. + return runOnce( + () -> { + /* one-time action goes here */ + }); + } + + /** + * An example method querying a boolean state of the subsystem (for example, a digital sensor). + * + * @return value of some boolean subsystem state, such as a digital sensor. + */ + public boolean exampleCondition() { + // Query some boolean state, such as a digital sensor. + return false; + } + + @Override + public void periodic() { + // This method will be called once per scheduler run + } + + @Override + public void simulationPeriodic() { + // This method will be called once per scheduler run during simulation + } + + @PostTest(name = "A friendly name", enabled = true) + public void myFailingPostTest(){ + assertThat(true).isFalse(); + } + + @PostTest(enabled = true) + public void myPassingPostTest(){ + assertThat("Hello World").endWith("World"); + } +}