From 9eed572e985cd56cd5159d745b02d090dd446da4 Mon Sep 17 00:00:00 2001 From: Mehvoy Date: Mon, 14 Sep 2026 19:41:31 -0700 Subject: [PATCH 1/8] Made intake --- src/main/java/frc/robot/Hardware.java | 3 + .../subsystems/intake/IntakeSubsystem.java | 62 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java diff --git a/src/main/java/frc/robot/Hardware.java b/src/main/java/frc/robot/Hardware.java index bf233a5..6db2470 100644 --- a/src/main/java/frc/robot/Hardware.java +++ b/src/main/java/frc/robot/Hardware.java @@ -7,4 +7,7 @@ public final class Hardware { public static final int PDH_ID = 1; + + //TODO: better number when get robot + public static final int IntakeMotor = 99; } diff --git a/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java b/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java new file mode 100644 index 0000000..bbf84da --- /dev/null +++ b/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java @@ -0,0 +1,62 @@ +package frc.robot.subsystems.intake; + +import com.ctre.phoenix6.configs.TalonFXConfiguration; +import com.ctre.phoenix6.controls.VelocityTorqueCurrentFOC; +import com.ctre.phoenix6.hardware.TalonFX; +import com.ctre.phoenix6.signals.InvertedValue; +import com.ctre.phoenix6.signals.NeutralModeValue; + +import edu.wpi.first.wpilibj2.command.Command; +import edu.wpi.first.wpilibj2.command.SubsystemBase; +import frc.robot.Hardware; + +public class IntakeSubsystem extends SubsystemBase{ + private final VelocityTorqueCurrentFOC velocityRequest = new VelocityTorqueCurrentFOC(0); + + private final TalonFX intakeMotor; + + private static final double TARGET_RPS = 0.0; + + public IntakeSubsystem() { + intakeMotor = new TalonFX(Hardware.IntakeMotor); + motorConfigs(); + } + + private void motorConfigs() { + var talonFXConfigs = new TalonFXConfiguration(); + talonFXConfigs.MotorOutput.NeutralMode = NeutralModeValue.Coast; // KEEP THIS AT COAST + talonFXConfigs.MotorOutput.Inverted = InvertedValue.CounterClockwise_Positive; + + talonFXConfigs.CurrentLimits.StatorCurrentLimit = 80; + talonFXConfigs.CurrentLimits.SupplyCurrentLimit = 40; + talonFXConfigs.CurrentLimits.StatorCurrentLimitEnable = true; + talonFXConfigs.CurrentLimits.SupplyCurrentLimitEnable = true; + + talonFXConfigs.Slot0.kP = 0.0; + talonFXConfigs.Slot0.kS = 0.0; + talonFXConfigs.Slot0.kA = 0.0; + + // configurator + intakeMotor.getConfigurator().apply(talonFXConfigs); + } + + public Command startIntake() { + return runEnd( + () -> { + runIntake(TARGET_RPS); + }, + () -> { + stopIntake(); + } + ); + } + + private void runIntake(double velocity) { + intakeMotor.setControl(velocityRequest.withVelocity(velocity)); + } + + private void stopIntake() { + intakeMotor.stopMotor(); + } + +} From d8a239be0b5d848ea70b4dc688225a6e1635c858 Mon Sep 17 00:00:00 2001 From: Mehvoy Date: Mon, 14 Sep 2026 19:59:12 -0700 Subject: [PATCH 2/8] Named a command, ran spotless, and implemented controls --- src/main/java/frc/robot/Controls.java | 17 ++-- src/main/java/frc/robot/Hardware.java | 2 +- src/main/java/frc/robot/Subsystems.java | 10 +++ .../subsystems/intake/IntakeSubsystem.java | 78 +++++++++---------- 4 files changed, 54 insertions(+), 53 deletions(-) diff --git a/src/main/java/frc/robot/Controls.java b/src/main/java/frc/robot/Controls.java index 82098a5..ca20ab1 100644 --- a/src/main/java/frc/robot/Controls.java +++ b/src/main/java/frc/robot/Controls.java @@ -40,20 +40,9 @@ public class Controls { public Controls(Subsystems subsystems) { s = subsystems; - // Configure the trigger bindings - configureBindings(); + configureIntake(); } - /** - * Use this method to define your trigger->command mappings. Triggers can be created via the - * {@link Trigger#Trigger(java.util.function.BooleanSupplier)} constructor with an arbitrary - * predicate, or via the named factories in {@link - * edu.wpi.first.wpilibj2.command.button.CommandGenericHID}'s subclasses for {@link - * CommandXboxController Xbox}/{@link edu.wpi.first.wpilibj2.command.button.CommandPS4Controller - * PS4} controllers or {@link edu.wpi.first.wpilibj2.command.button.CommandJoystick Flight - * joysticks}. - */ - private void configureBindings() {} // takes the X value from the joystick, and applies a deadband and input scaling private double getDriveX() { @@ -86,4 +75,8 @@ private double getDriveRotate() { .withDeadband(SWERVE_DEADBAND) .withRotationalDeadband(SWERVE_DEADBAND) .withDriveRequestType(DriveRequestType.Velocity); + + private void configureIntake() { + driverController.rightBumper().whileTrue(s.intakeSubsystem.startIntake()); + } } diff --git a/src/main/java/frc/robot/Hardware.java b/src/main/java/frc/robot/Hardware.java index 6db2470..3284548 100644 --- a/src/main/java/frc/robot/Hardware.java +++ b/src/main/java/frc/robot/Hardware.java @@ -8,6 +8,6 @@ public final class Hardware { public static final int PDH_ID = 1; - //TODO: better number when get robot + // TODO: better number when get robot public static final int IntakeMotor = 99; } diff --git a/src/main/java/frc/robot/Subsystems.java b/src/main/java/frc/robot/Subsystems.java index 71f4545..c20d12d 100644 --- a/src/main/java/frc/robot/Subsystems.java +++ b/src/main/java/frc/robot/Subsystems.java @@ -1,19 +1,23 @@ package frc.robot; import static frc.robot.Subsystems.SubsystemConstants.DRIVEBASE_ENABLED; +import static frc.robot.Subsystems.SubsystemConstants.INTAKE_ENABLED; import edu.wpi.first.wpilibj.smartdashboard.Mechanism2d; import frc.robot.generated.AlphaTunerConstants; import frc.robot.subsystems.drivebase.CommandSwerveDrivetrain; +import frc.robot.subsystems.intake.IntakeSubsystem; public class Subsystems { // _ENABLED constants go here public static class SubsystemConstants { public static final boolean DRIVEBASE_ENABLED = true; + public static final boolean INTAKE_ENABLED = true; } public final CommandSwerveDrivetrain drivebaseSubsystem; + public final IntakeSubsystem intakeSubsystem; public Subsystems(Mechanism2d mechanism2d) { // Initialize subsystems here (don't forget to check if they're enabled!) @@ -33,5 +37,11 @@ public Subsystems(Mechanism2d mechanism2d) { } else { drivebaseSubsystem = null; } + + if (INTAKE_ENABLED) { + intakeSubsystem = new IntakeSubsystem(); + } else { + intakeSubsystem = null; + } } } diff --git a/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java b/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java index bbf84da..ca3ad4e 100644 --- a/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java +++ b/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java @@ -5,58 +5,56 @@ import com.ctre.phoenix6.hardware.TalonFX; import com.ctre.phoenix6.signals.InvertedValue; import com.ctre.phoenix6.signals.NeutralModeValue; - import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.SubsystemBase; import frc.robot.Hardware; -public class IntakeSubsystem extends SubsystemBase{ - private final VelocityTorqueCurrentFOC velocityRequest = new VelocityTorqueCurrentFOC(0); +public class IntakeSubsystem extends SubsystemBase { + private final VelocityTorqueCurrentFOC velocityRequest = new VelocityTorqueCurrentFOC(0); + + private final TalonFX intakeMotor; - private final TalonFX intakeMotor; + private static final double TARGET_RPS = 0.0; - private static final double TARGET_RPS = 0.0; + public IntakeSubsystem() { + intakeMotor = new TalonFX(Hardware.IntakeMotor); + motorConfigs(); + } - public IntakeSubsystem() { - intakeMotor = new TalonFX(Hardware.IntakeMotor); - motorConfigs(); - } + private void motorConfigs() { + var talonFXConfigs = new TalonFXConfiguration(); + talonFXConfigs.MotorOutput.NeutralMode = NeutralModeValue.Coast; // KEEP THIS AT COAST + talonFXConfigs.MotorOutput.Inverted = InvertedValue.CounterClockwise_Positive; - private void motorConfigs() { - var talonFXConfigs = new TalonFXConfiguration(); - talonFXConfigs.MotorOutput.NeutralMode = NeutralModeValue.Coast; // KEEP THIS AT COAST - talonFXConfigs.MotorOutput.Inverted = InvertedValue.CounterClockwise_Positive; + talonFXConfigs.CurrentLimits.StatorCurrentLimit = 80; + talonFXConfigs.CurrentLimits.SupplyCurrentLimit = 40; + talonFXConfigs.CurrentLimits.StatorCurrentLimitEnable = true; + talonFXConfigs.CurrentLimits.SupplyCurrentLimitEnable = true; - talonFXConfigs.CurrentLimits.StatorCurrentLimit = 80; - talonFXConfigs.CurrentLimits.SupplyCurrentLimit = 40; - talonFXConfigs.CurrentLimits.StatorCurrentLimitEnable = true; - talonFXConfigs.CurrentLimits.SupplyCurrentLimitEnable = true; + talonFXConfigs.Slot0.kP = 0.0; + talonFXConfigs.Slot0.kS = 0.0; + talonFXConfigs.Slot0.kA = 0.0; - talonFXConfigs.Slot0.kP = 0.0; - talonFXConfigs.Slot0.kS = 0.0; - talonFXConfigs.Slot0.kA = 0.0; - - // configurator - intakeMotor.getConfigurator().apply(talonFXConfigs); - } + // configurator + intakeMotor.getConfigurator().apply(talonFXConfigs); + } - public Command startIntake() { - return runEnd( + public Command startIntake() { + return runEnd( () -> { - runIntake(TARGET_RPS); + runIntake(TARGET_RPS); }, () -> { - stopIntake(); - } - ); - } - - private void runIntake(double velocity) { - intakeMotor.setControl(velocityRequest.withVelocity(velocity)); - } - - private void stopIntake() { - intakeMotor.stopMotor(); - } - + stopIntake(); + }) + .withName("Run Intake"); + } + + private void runIntake(double velocity) { + intakeMotor.setControl(velocityRequest.withVelocity(velocity)); + } + + private void stopIntake() { + intakeMotor.stopMotor(); + } } From 1fa0dcc296ff6a0bd1aefd77f5031fed1ba73a9d Mon Sep 17 00:00:00 2001 From: Mehvoy Date: Mon, 14 Sep 2026 20:00:19 -0700 Subject: [PATCH 3/8] Ran spotless bc i forgot --- src/main/java/frc/robot/Controls.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/frc/robot/Controls.java b/src/main/java/frc/robot/Controls.java index ca20ab1..1c8f051 100644 --- a/src/main/java/frc/robot/Controls.java +++ b/src/main/java/frc/robot/Controls.java @@ -12,7 +12,6 @@ import com.ctre.phoenix6.swerve.SwerveRequest; import edu.wpi.first.math.MathUtil; import edu.wpi.first.wpilibj2.command.button.CommandXboxController; -import edu.wpi.first.wpilibj2.command.button.Trigger; import frc.robot.generated.AlphaTunerConstants; /** @@ -43,7 +42,6 @@ public Controls(Subsystems subsystems) { configureIntake(); } - // takes the X value from the joystick, and applies a deadband and input scaling private double getDriveX() { // Joystick +Y is back From 62d6a05b56f69209dc19b9130d40d1322940de32 Mon Sep 17 00:00:00 2001 From: Mehvoy Date: Thu, 17 Sep 2026 20:03:32 -0700 Subject: [PATCH 4/8] fixed some changes, will do more --- src/main/java/frc/robot/Controls.java | 4 +++- src/main/java/frc/robot/Hardware.java | 2 +- .../java/frc/robot/subsystems/intake/IntakeSubsystem.java | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/frc/robot/Controls.java b/src/main/java/frc/robot/Controls.java index 1c8f051..ab8744b 100644 --- a/src/main/java/frc/robot/Controls.java +++ b/src/main/java/frc/robot/Controls.java @@ -75,6 +75,8 @@ private double getDriveRotate() { .withDriveRequestType(DriveRequestType.Velocity); private void configureIntake() { - driverController.rightBumper().whileTrue(s.intakeSubsystem.startIntake()); + if (s.intakeSubsystem != null) { + driverController.rightBumper().whileTrue(s.intakeSubsystem.startIntake()); + } } } diff --git a/src/main/java/frc/robot/Hardware.java b/src/main/java/frc/robot/Hardware.java index 3284548..81b53c4 100644 --- a/src/main/java/frc/robot/Hardware.java +++ b/src/main/java/frc/robot/Hardware.java @@ -9,5 +9,5 @@ public final class Hardware { public static final int PDH_ID = 1; // TODO: better number when get robot - public static final int IntakeMotor = 99; + public static final int IntakeMotor = 0; } diff --git a/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java b/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java index ca3ad4e..59ee1ea 100644 --- a/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java +++ b/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java @@ -14,6 +14,7 @@ public class IntakeSubsystem extends SubsystemBase { private final TalonFX intakeMotor; + // TODO: set rps private static final double TARGET_RPS = 0.0; public IntakeSubsystem() { @@ -31,6 +32,7 @@ private void motorConfigs() { talonFXConfigs.CurrentLimits.StatorCurrentLimitEnable = true; talonFXConfigs.CurrentLimits.SupplyCurrentLimitEnable = true; + // TODO: set values talonFXConfigs.Slot0.kP = 0.0; talonFXConfigs.Slot0.kS = 0.0; talonFXConfigs.Slot0.kA = 0.0; @@ -40,7 +42,7 @@ private void motorConfigs() { } public Command startIntake() { - return runEnd( + return startEnd( () -> { runIntake(TARGET_RPS); }, From 62e3790865bb3ed4a1c59b46c644c12b52ebaa25 Mon Sep 17 00:00:00 2001 From: Mehvoy Date: Thu, 17 Sep 2026 20:25:49 -0700 Subject: [PATCH 5/8] added todo for last change --- src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java b/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java index 59ee1ea..5373ec8 100644 --- a/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java +++ b/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java @@ -18,6 +18,7 @@ public class IntakeSubsystem extends SubsystemBase { private static final double TARGET_RPS = 0.0; public IntakeSubsystem() { + // TODO: "if the motor is on the CANivore, pass the bus name or constant" intakeMotor = new TalonFX(Hardware.IntakeMotor); motorConfigs(); } From 37cf3b85769c3faac8610c8926d29f1216183942 Mon Sep 17 00:00:00 2001 From: Mehvoy Date: Thu, 17 Sep 2026 20:28:57 -0700 Subject: [PATCH 6/8] fixed merge errors and spotless --- src/main/java/frc/robot/Controls.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/frc/robot/Controls.java b/src/main/java/frc/robot/Controls.java index 17889be..7675772 100644 --- a/src/main/java/frc/robot/Controls.java +++ b/src/main/java/frc/robot/Controls.java @@ -11,6 +11,7 @@ import edu.wpi.first.math.MathUtil; import edu.wpi.first.wpilibj2.command.Commands; import edu.wpi.first.wpilibj2.command.button.CommandXboxController; +import edu.wpi.first.wpilibj2.command.button.Trigger; import frc.robot.generated.AlphaTunerConstants; import frc.robot.util.GetTargetFromPose; import frc.robot.util.tuning.WheelRadiusCharacterization; @@ -85,6 +86,8 @@ private void configureIntake() { if (s.intakeSubsystem != null) { driverController.rightBumper().whileTrue(s.intakeSubsystem.startIntake()); } + } + private void configureDrivebaseBindings() { if (s.drivebaseSubsystem == null) { // Stop running this method From 0317bf99bceeea9124dce39e58bf59cd392a424d Mon Sep 17 00:00:00 2001 From: Mehvoy Date: Mon, 21 Sep 2026 18:42:44 -0700 Subject: [PATCH 7/8] fixes --- .../robot/subsystems/intake/IntakeSubsystem.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java b/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java index 5373ec8..ae635a3 100644 --- a/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java +++ b/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java @@ -1,10 +1,12 @@ package frc.robot.subsystems.intake; +import com.ctre.phoenix6.StatusCode; import com.ctre.phoenix6.configs.TalonFXConfiguration; import com.ctre.phoenix6.controls.VelocityTorqueCurrentFOC; import com.ctre.phoenix6.hardware.TalonFX; import com.ctre.phoenix6.signals.InvertedValue; import com.ctre.phoenix6.signals.NeutralModeValue; +import edu.wpi.first.wpilibj.DriverStation; import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.SubsystemBase; import frc.robot.Hardware; @@ -15,7 +17,7 @@ public class IntakeSubsystem extends SubsystemBase { private final TalonFX intakeMotor; // TODO: set rps - private static final double TARGET_RPS = 0.0; + private static final double TARGET_RPS = 40.0; public IntakeSubsystem() { // TODO: "if the motor is on the CANivore, pass the bus name or constant" @@ -39,7 +41,14 @@ private void motorConfigs() { talonFXConfigs.Slot0.kA = 0.0; // configurator - intakeMotor.getConfigurator().apply(talonFXConfigs); + StatusCode status = StatusCode.StatusCodeNotInitialized; + for (int i = 0; i < 5; ++i) { + status = intakeMotor.getConfigurator().apply(talonFXConfigs); + if (status.isOK()) break; + } + if (!status.isOK()) { + DriverStation.reportError("Failed to apply IntakeMotor configs: " + status, false); + } } public Command startIntake() { From 49205af4494cee2bd4d9bbf3f4a0e73a1493aa7f Mon Sep 17 00:00:00 2001 From: Mehvoy Date: Mon, 21 Sep 2026 19:04:40 -0700 Subject: [PATCH 8/8] updated a comment --- src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java b/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java index ae635a3..1ea98e4 100644 --- a/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java +++ b/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java @@ -20,7 +20,7 @@ public class IntakeSubsystem extends SubsystemBase { private static final double TARGET_RPS = 40.0; public IntakeSubsystem() { - // TODO: "if the motor is on the CANivore, pass the bus name or constant" + // TODO: check with mech if motor on canivore or roborio intakeMotor = new TalonFX(Hardware.IntakeMotor); motorConfigs(); }