From d609c71f82ccd47207dd9bcaf2a0b55b8b558d79 Mon Sep 17 00:00:00 2001 From: Xander99-9 Date: Sat, 7 Feb 2026 13:14:10 -0500 Subject: [PATCH 01/12] added intake, not tested --- .../subsystems/IntakeInOutSubsystem.java | 155 ++++++++++++++++++ .../intake/IntakeInOutSubsystem.java | 106 ++++++++++++ .../intake/IntakeUpDownSubsystem.java | 6 + 2026-2706-Robot-Code/vendordeps/REVLib.json | 133 +++++++++++++++ vendordeps/WPILibNewCommands.json | 39 +++++ 5 files changed, 439 insertions(+) create mode 100644 2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/IntakeInOutSubsystem.java create mode 100644 2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/intake/IntakeInOutSubsystem.java create mode 100644 2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/intake/IntakeUpDownSubsystem.java create mode 100644 2026-2706-Robot-Code/vendordeps/REVLib.json create mode 100644 vendordeps/WPILibNewCommands.json diff --git a/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/IntakeInOutSubsystem.java b/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/IntakeInOutSubsystem.java new file mode 100644 index 0000000..1bdf19f --- /dev/null +++ b/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/IntakeInOutSubsystem.java @@ -0,0 +1,155 @@ +// 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.IntakeInOutSubsystem; +import edu.wpi.first.math.controller.PIDController; +import edu.wpi.first.wpilibj2.command.SubsystemBase; + +import com.revrobotics.spark.SparkMax; + +import com.revrobotics.spark.SparkBase; +import com.revrobotics.spark.SparkFlex; +import com.revrobotics.spark.SparkLowLevel.MotorType; +import frc.robot.Constants.*; + + + +/** + * The Intake class represents the intake subsystem of the robot. + * It controls the intake motor and provides methods to set the motor power, + * stop the motor, and get the motor's RPM. + */ +public class IntakeInOutSubsystem extends SubsystemBase { + private SparkFlex intakeMotor; + + /** + * Constructs a new Intake subsystem. + * Initializes the intake motor and PID controller. + */ + public Intake() { + intakeMotor = new SparkFlex(45, MotorType.kBrushless); + + } + + /** + * Sets the power of the intake motor. + * + * @param power The power to set for the intake motor. + */ + public void setIntakePower(double power) { + + intakeMotor.set(-power*0.75); + // System.out.println(power); + + } + + /** + * Stops the intake motor. + */ + public void stopIntake(){ + + intakeMotorLeftSide.set(0); + intakeMotorRightSide.set(0); + intakeMotorTop.set(0); + + } + + /** + * Gets the raw RPM of the intake motor. + * + * @return The raw RPM of the intake motor. + */ + public double getRawMotorRPM(){ + + return intakeMotorLeftSide.getEncoder().getVelocity(); + + } + + /** + * Gets the RPM of the intake motor, converted using a conversion factor. + * + * @return The converted RPM of the intake motor. + */ + public double getRPM(){ + + return getRawMotorRPM() * IntakeConstants.kRPMConversionFactor; + + } + + /** + * Gets the PID controller for the side intake motor. + * + * @return The PID controller for the side intake motor. + */ + public PIDController getSidePIDController(){ + return sidePIDController; + } + + /** + * Gets the PID controller for the top intake motor. + * + * @return The PID controller for the top intake motor. + */ + public PIDController getTopPIDController(){ + return topPIDController; + } + + public void setBothPowers(double side_power, double top_power) { + intakeMotorLeftSide.set(-side_power); + intakeMotorRightSide.set(-side_power); + intakeMotorTop.set(top_power); + } + + /** + * Sets the power of the side intake motor. + * + * @param power The power to set for the side intake motor. + */ + public void setSideIntakePower(double power) { + + intakeMotorLeftSide.set(power); + + } + + /** + * Sets the power of the top intake motor. + * + * @param power The power to set for the top intake motor. + */ + public void setTopIntakePower(double power) { + + intakeMotorTop.set(power); + + } + + /** + * Gets the raw RPM of the side intake motor. + * + * @return The raw RPM of the side intake motor. + */ + public double getSideMotorRPM() { + return intakeMotorLeftSide.getEncoder().getVelocity(); + } + + /** + * Gets the raw RPM of the top intake motor. + * + * @return The raw RPM of the top intake motor. + */ + public double getTopMotorRPM() { + return intakeMotorTop.getEncoder().getVelocity(); + } + /** + * Periodically updates the SmartDashboard with the intake motor's RPM and current. + * This method is called automatically to update sensor status on the dashboard. + */ + @Override + public void periodic() { + if (UtilityConstants.debugMode){ + SmartDashboard.putNumber("Intake RPM", getRPM()); + SmartDashboard.putNumber("Intake Current", intakeMotorLeftSide.getOutputCurrent()); + } + } + +} \ No newline at end of file diff --git a/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/intake/IntakeInOutSubsystem.java b/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/intake/IntakeInOutSubsystem.java new file mode 100644 index 0000000..e3f0892 --- /dev/null +++ b/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/intake/IntakeInOutSubsystem.java @@ -0,0 +1,106 @@ +// 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.intake; +import edu.wpi.first.math.controller.PIDController; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; +import edu.wpi.first.wpilibj2.command.SubsystemBase; + +import com.revrobotics.spark.SparkMax; + +import com.revrobotics.spark.SparkBase; +import com.revrobotics.spark.SparkFlex; +import com.revrobotics.spark.SparkLowLevel.MotorType; +import frc.robot.Constants.*; + + + +/** + * The Intake class represents the intake subsystem of the robot. + * It controls the intake motor and provides methods to set the motor power, + * stop the motor, and get the motor's RPM. + */ +public class IntakeInOutSubsystem extends SubsystemBase { + private SparkFlex intakeMotor; + + /** + * Constructs a new Intake subsystem. + * Initializes the intake motor and PID controller. + */ + public IntakeInOutSubsystem() { + intakeMotor = new SparkFlex(45, MotorType.kBrushless); + + } + + /** + * Sets the power of the intake motor. + * + * @param power The power to set for the intake motor. + */ + public void setIntakePower(double power) { + + intakeMotor.set(-power*0.75); + // System.out.println(power); + + } + + /** + * Stops the intake motor. + */ + public void stopIntake(){ + + intakeMotor.set(0); + + } + + /** + * Gets the raw RPM of the intake motor. + * + * @return The raw RPM of the intake motor. + */ + public double getRawMotorRPM(){ + + return intakeMotor.getEncoder().getVelocity(); + + } + + /** + * Gets the RPM of the intake motor, converted using a conversion factor. + * + * @return The converted RPM of the intake motor. + */ + public double getRPM(){ + + return getRawMotorRPM() * RobotConstants.kRPMConversionFactor; + + } + + public void setBothPowers(double side_power, double top_power) { + intakeMotor.set(-side_power); + } + + /** + * Sets the power of the intake motor. + * + * @param power The power to set for the side intake motor. + */ + public void setSideIntakePower(double power) { + + intakeMotor.set(power); + + } + + /** + * Periodically updates the SmartDashboard with the intake motor's RPM and current. + * This method is called automatically to update sensor status on the dashboard. + */ + @Override + public void periodic() { + if (UtilityConstants.debugMode){ + SmartDashboard.putNumber("Intake RPM", getRPM()); + SmartDashboard.putNumber("Intake Current", intakeMotor.getOutputCurrent()); + } + } + +} \ No newline at end of file diff --git a/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/intake/IntakeUpDownSubsystem.java b/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/intake/IntakeUpDownSubsystem.java new file mode 100644 index 0000000..e3a5e19 --- /dev/null +++ b/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/intake/IntakeUpDownSubsystem.java @@ -0,0 +1,6 @@ +// 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.intake; + diff --git a/2026-2706-Robot-Code/vendordeps/REVLib.json b/2026-2706-Robot-Code/vendordeps/REVLib.json new file mode 100644 index 0000000..d35e593 --- /dev/null +++ b/2026-2706-Robot-Code/vendordeps/REVLib.json @@ -0,0 +1,133 @@ +{ + "fileName": "REVLib.json", + "name": "REVLib", + "version": "2026.0.1", + "frcYear": "2026", + "uuid": "3f48eb8c-50fe-43a6-9cb7-44c86353c4cb", + "mavenUrls": [ + "https://maven.revrobotics.com/" + ], + "jsonUrl": "https://software-metadata.revrobotics.com/REVLib-2026.json", + "javaDependencies": [ + { + "groupId": "com.revrobotics.frc", + "artifactId": "REVLib-java", + "version": "2026.0.1" + } + ], + "jniDependencies": [ + { + "groupId": "com.revrobotics.frc", + "artifactId": "REVLib-driver", + "version": "2026.0.1", + "skipInvalidPlatforms": true, + "isJar": false, + "validPlatforms": [ + "windowsx86-64", + "linuxarm64", + "linuxx86-64", + "linuxathena", + "linuxarm32", + "osxuniversal" + ] + }, + { + "groupId": "com.revrobotics.frc", + "artifactId": "RevLibBackendDriver", + "version": "2026.0.1", + "skipInvalidPlatforms": true, + "isJar": false, + "validPlatforms": [ + "windowsx86-64", + "linuxarm64", + "linuxx86-64", + "linuxathena", + "linuxarm32", + "osxuniversal" + ] + }, + { + "groupId": "com.revrobotics.frc", + "artifactId": "RevLibWpiBackendDriver", + "version": "2026.0.1", + "skipInvalidPlatforms": true, + "isJar": false, + "validPlatforms": [ + "windowsx86-64", + "linuxarm64", + "linuxx86-64", + "linuxathena", + "linuxarm32", + "osxuniversal" + ] + } + ], + "cppDependencies": [ + { + "groupId": "com.revrobotics.frc", + "artifactId": "REVLib-cpp", + "version": "2026.0.1", + "libName": "REVLib", + "headerClassifier": "headers", + "sharedLibrary": false, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "windowsx86-64", + "linuxarm64", + "linuxx86-64", + "linuxathena", + "linuxarm32", + "osxuniversal" + ] + }, + { + "groupId": "com.revrobotics.frc", + "artifactId": "REVLib-driver", + "version": "2026.0.1", + "libName": "REVLibDriver", + "headerClassifier": "headers", + "sharedLibrary": false, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "windowsx86-64", + "linuxarm64", + "linuxx86-64", + "linuxathena", + "linuxarm32", + "osxuniversal" + ] + }, + { + "groupId": "com.revrobotics.frc", + "artifactId": "RevLibBackendDriver", + "version": "2026.0.1", + "libName": "BackendDriver", + "sharedLibrary": true, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "windowsx86-64", + "linuxarm64", + "linuxx86-64", + "linuxathena", + "linuxarm32", + "osxuniversal" + ] + }, + { + "groupId": "com.revrobotics.frc", + "artifactId": "RevLibWpiBackendDriver", + "version": "2026.0.1", + "libName": "REVLibWpi", + "sharedLibrary": true, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "windowsx86-64", + "linuxarm64", + "linuxx86-64", + "linuxathena", + "linuxarm32", + "osxuniversal" + ] + } + ] +} \ No newline at end of file diff --git a/vendordeps/WPILibNewCommands.json b/vendordeps/WPILibNewCommands.json new file mode 100644 index 0000000..69348e4 --- /dev/null +++ b/vendordeps/WPILibNewCommands.json @@ -0,0 +1,39 @@ +{ + "fileName": "WPILibNewCommands.json", + "name": "WPILib-New-Commands", + "version": "1.0.0", + "uuid": "111e20f7-815e-48f8-9dd6-e675ce75b266", + "frcYear": "2026", + "mavenUrls": [], + "jsonUrl": "", + "javaDependencies": [ + { + "groupId": "edu.wpi.first.wpilibNewCommands", + "artifactId": "wpilibNewCommands-java", + "version": "wpilib" + } + ], + "jniDependencies": [], + "cppDependencies": [ + { + "groupId": "edu.wpi.first.wpilibNewCommands", + "artifactId": "wpilibNewCommands-cpp", + "version": "wpilib", + "libName": "wpilibNewCommands", + "headerClassifier": "headers", + "sourcesClassifier": "sources", + "sharedLibrary": true, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "linuxsystemcore", + "linuxathena", + "linuxarm32", + "linuxarm64", + "windowsx86-64", + "windowsx86", + "linuxx86-64", + "osxuniversal" + ] + } + ] +} \ No newline at end of file From 92ab4e9b8dba1993763ec97d67d727e0c7d93ad5 Mon Sep 17 00:00:00 2001 From: Xander99-9 Date: Sat, 7 Feb 2026 14:29:24 -0500 Subject: [PATCH 02/12] added constants values --- .../src/main/java/frc/robot/Constants.java | 8 + .../subsystems/IntakeInOutSubsystem.java | 155 ------------------ 2 files changed, 8 insertions(+), 155 deletions(-) delete mode 100644 2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/IntakeInOutSubsystem.java diff --git a/2026-2706-Robot-Code/src/main/java/frc/robot/Constants.java b/2026-2706-Robot-Code/src/main/java/frc/robot/Constants.java index c50ba05..4fa0119 100644 --- a/2026-2706-Robot-Code/src/main/java/frc/robot/Constants.java +++ b/2026-2706-Robot-Code/src/main/java/frc/robot/Constants.java @@ -16,4 +16,12 @@ public final class Constants { public static class OperatorConstants { public static final int kDriverControllerPort = 0; } + public static class RobotConstants { + public static final int kSelectorSwitchPort = 0; + public static final int kRPMConversionFactor = 1 / 3; + } + + public static class UtilityConstants { + public static final boolean debugMode = true; +} } diff --git a/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/IntakeInOutSubsystem.java b/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/IntakeInOutSubsystem.java deleted file mode 100644 index 1bdf19f..0000000 --- a/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/IntakeInOutSubsystem.java +++ /dev/null @@ -1,155 +0,0 @@ -// 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.IntakeInOutSubsystem; -import edu.wpi.first.math.controller.PIDController; -import edu.wpi.first.wpilibj2.command.SubsystemBase; - -import com.revrobotics.spark.SparkMax; - -import com.revrobotics.spark.SparkBase; -import com.revrobotics.spark.SparkFlex; -import com.revrobotics.spark.SparkLowLevel.MotorType; -import frc.robot.Constants.*; - - - -/** - * The Intake class represents the intake subsystem of the robot. - * It controls the intake motor and provides methods to set the motor power, - * stop the motor, and get the motor's RPM. - */ -public class IntakeInOutSubsystem extends SubsystemBase { - private SparkFlex intakeMotor; - - /** - * Constructs a new Intake subsystem. - * Initializes the intake motor and PID controller. - */ - public Intake() { - intakeMotor = new SparkFlex(45, MotorType.kBrushless); - - } - - /** - * Sets the power of the intake motor. - * - * @param power The power to set for the intake motor. - */ - public void setIntakePower(double power) { - - intakeMotor.set(-power*0.75); - // System.out.println(power); - - } - - /** - * Stops the intake motor. - */ - public void stopIntake(){ - - intakeMotorLeftSide.set(0); - intakeMotorRightSide.set(0); - intakeMotorTop.set(0); - - } - - /** - * Gets the raw RPM of the intake motor. - * - * @return The raw RPM of the intake motor. - */ - public double getRawMotorRPM(){ - - return intakeMotorLeftSide.getEncoder().getVelocity(); - - } - - /** - * Gets the RPM of the intake motor, converted using a conversion factor. - * - * @return The converted RPM of the intake motor. - */ - public double getRPM(){ - - return getRawMotorRPM() * IntakeConstants.kRPMConversionFactor; - - } - - /** - * Gets the PID controller for the side intake motor. - * - * @return The PID controller for the side intake motor. - */ - public PIDController getSidePIDController(){ - return sidePIDController; - } - - /** - * Gets the PID controller for the top intake motor. - * - * @return The PID controller for the top intake motor. - */ - public PIDController getTopPIDController(){ - return topPIDController; - } - - public void setBothPowers(double side_power, double top_power) { - intakeMotorLeftSide.set(-side_power); - intakeMotorRightSide.set(-side_power); - intakeMotorTop.set(top_power); - } - - /** - * Sets the power of the side intake motor. - * - * @param power The power to set for the side intake motor. - */ - public void setSideIntakePower(double power) { - - intakeMotorLeftSide.set(power); - - } - - /** - * Sets the power of the top intake motor. - * - * @param power The power to set for the top intake motor. - */ - public void setTopIntakePower(double power) { - - intakeMotorTop.set(power); - - } - - /** - * Gets the raw RPM of the side intake motor. - * - * @return The raw RPM of the side intake motor. - */ - public double getSideMotorRPM() { - return intakeMotorLeftSide.getEncoder().getVelocity(); - } - - /** - * Gets the raw RPM of the top intake motor. - * - * @return The raw RPM of the top intake motor. - */ - public double getTopMotorRPM() { - return intakeMotorTop.getEncoder().getVelocity(); - } - /** - * Periodically updates the SmartDashboard with the intake motor's RPM and current. - * This method is called automatically to update sensor status on the dashboard. - */ - @Override - public void periodic() { - if (UtilityConstants.debugMode){ - SmartDashboard.putNumber("Intake RPM", getRPM()); - SmartDashboard.putNumber("Intake Current", intakeMotorLeftSide.getOutputCurrent()); - } - } - -} \ No newline at end of file From ad58985d246eb41f28abb2ce82b63544881e76d2 Mon Sep 17 00:00:00 2001 From: Xander99-9 Date: Sat, 7 Feb 2026 14:38:56 -0500 Subject: [PATCH 03/12] some fixs to make thing easier to read --- .../src/main/java/frc/robot/Constants.java | 1 + ...OutSubsystem.java => IntakeSubsystem.java} | 27 +++++-------------- .../intake/IntakeUpDownSubsystem.java | 6 ----- 3 files changed, 7 insertions(+), 27 deletions(-) rename 2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/intake/{IntakeInOutSubsystem.java => IntakeSubsystem.java} (77%) delete mode 100644 2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/intake/IntakeUpDownSubsystem.java diff --git a/2026-2706-Robot-Code/src/main/java/frc/robot/Constants.java b/2026-2706-Robot-Code/src/main/java/frc/robot/Constants.java index 4fa0119..f9e4292 100644 --- a/2026-2706-Robot-Code/src/main/java/frc/robot/Constants.java +++ b/2026-2706-Robot-Code/src/main/java/frc/robot/Constants.java @@ -19,6 +19,7 @@ public static class OperatorConstants { public static class RobotConstants { public static final int kSelectorSwitchPort = 0; public static final int kRPMConversionFactor = 1 / 3; + public static final int kIntakeMotorID = 45; } public static class UtilityConstants { diff --git a/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/intake/IntakeInOutSubsystem.java b/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java similarity index 77% rename from 2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/intake/IntakeInOutSubsystem.java rename to 2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java index e3f0892..de153fc 100644 --- a/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/intake/IntakeInOutSubsystem.java +++ b/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java @@ -9,9 +9,9 @@ import com.revrobotics.spark.SparkMax; -import com.revrobotics.spark.SparkBase; -import com.revrobotics.spark.SparkFlex; import com.revrobotics.spark.SparkLowLevel.MotorType; + +import frc.robot.Constants; import frc.robot.Constants.*; @@ -21,15 +21,15 @@ * It controls the intake motor and provides methods to set the motor power, * stop the motor, and get the motor's RPM. */ -public class IntakeInOutSubsystem extends SubsystemBase { - private SparkFlex intakeMotor; +public class IntakeSubsystem extends SubsystemBase { + private SparkMax intakeMotor; /** * Constructs a new Intake subsystem. * Initializes the intake motor and PID controller. */ - public IntakeInOutSubsystem() { - intakeMotor = new SparkFlex(45, MotorType.kBrushless); + public IntakeSubsystem() { + intakeMotor = new SparkMax(Constants.RobotConstants.kIntakeMotorID, MotorType.kBrushless); } @@ -76,21 +76,6 @@ public double getRPM(){ } - public void setBothPowers(double side_power, double top_power) { - intakeMotor.set(-side_power); - } - - /** - * Sets the power of the intake motor. - * - * @param power The power to set for the side intake motor. - */ - public void setSideIntakePower(double power) { - - intakeMotor.set(power); - - } - /** * Periodically updates the SmartDashboard with the intake motor's RPM and current. * This method is called automatically to update sensor status on the dashboard. diff --git a/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/intake/IntakeUpDownSubsystem.java b/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/intake/IntakeUpDownSubsystem.java deleted file mode 100644 index e3a5e19..0000000 --- a/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/intake/IntakeUpDownSubsystem.java +++ /dev/null @@ -1,6 +0,0 @@ -// 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.intake; - From 9b6cef92b956c1c98ce9a48821c1542c03837378 Mon Sep 17 00:00:00 2001 From: Xander99-9 Date: Sun, 8 Feb 2026 18:58:34 -0500 Subject: [PATCH 04/12] intake --- .../frc/robot/subsystems/{intake => }/IntakeSubsystem.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename 2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/{intake => }/IntakeSubsystem.java (96%) diff --git a/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java b/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/IntakeSubsystem.java similarity index 96% rename from 2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java rename to 2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/IntakeSubsystem.java index de153fc..ca106ce 100644 --- a/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java +++ b/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/IntakeSubsystem.java @@ -2,7 +2,7 @@ // 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.intake; +package frc.robot.subsystems; import edu.wpi.first.math.controller.PIDController; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj2.command.SubsystemBase; @@ -26,7 +26,7 @@ public class IntakeSubsystem extends SubsystemBase { /** * Constructs a new Intake subsystem. - * Initializes the intake motor and PID controller. + * Initializes the intake motor. */ public IntakeSubsystem() { intakeMotor = new SparkMax(Constants.RobotConstants.kIntakeMotorID, MotorType.kBrushless); @@ -49,7 +49,7 @@ public void setIntakePower(double power) { * Stops the intake motor. */ public void stopIntake(){ - + intakeMotor.set(0); } From 764eb6dbaf52228280af0cf2ade5a03848590b44 Mon Sep 17 00:00:00 2001 From: Xander99-9 Date: Fri, 13 Feb 2026 19:34:45 -0500 Subject: [PATCH 05/12] added intake command --- .../src/main/java/frc/robot/Constants.java | 2 ++ .../frc/robot/commands/RunIntakeCommand.java | 29 +++++++++++++++++++ .../frc/robot/subsystems/IntakeSubsystem.java | 27 +++++++++++++---- 3 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 2026-2706-Robot-Code/src/main/java/frc/robot/commands/RunIntakeCommand.java diff --git a/2026-2706-Robot-Code/src/main/java/frc/robot/Constants.java b/2026-2706-Robot-Code/src/main/java/frc/robot/Constants.java index f9e4292..ec4f213 100644 --- a/2026-2706-Robot-Code/src/main/java/frc/robot/Constants.java +++ b/2026-2706-Robot-Code/src/main/java/frc/robot/Constants.java @@ -20,6 +20,8 @@ public static class RobotConstants { public static final int kSelectorSwitchPort = 0; public static final int kRPMConversionFactor = 1 / 3; public static final int kIntakeMotorID = 45; + public static final int kIntakeUpDownMotorID = 22; + public static final double kIntakeSpeed = 0.5; } public static class UtilityConstants { diff --git a/2026-2706-Robot-Code/src/main/java/frc/robot/commands/RunIntakeCommand.java b/2026-2706-Robot-Code/src/main/java/frc/robot/commands/RunIntakeCommand.java new file mode 100644 index 0000000..bc37d9b --- /dev/null +++ b/2026-2706-Robot-Code/src/main/java/frc/robot/commands/RunIntakeCommand.java @@ -0,0 +1,29 @@ +package frc.robot.commands; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.IntakeSubsystem; + +public class RunIntakeCommand extends Command { + + private final IntakeSubsystem intake; + + public RunIntakeCommand(IntakeSubsystem intake) { + this.intake = intake; + addRequirements(intake); + } + + @Override + public void initialize() { + intake.startIntake(); + } + + @Override + public void end(boolean interrupted) { + intake.stopIntake(); + } + + @Override + public boolean isFinished() { + return false; + } +} diff --git a/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/IntakeSubsystem.java b/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/IntakeSubsystem.java index ca106ce..6547ea4 100644 --- a/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/IntakeSubsystem.java +++ b/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/IntakeSubsystem.java @@ -23,6 +23,7 @@ */ public class IntakeSubsystem extends SubsystemBase { private SparkMax intakeMotor; + private SparkMax intakeUpDownMotor; /** * Constructs a new Intake subsystem. @@ -30,18 +31,16 @@ public class IntakeSubsystem extends SubsystemBase { */ public IntakeSubsystem() { intakeMotor = new SparkMax(Constants.RobotConstants.kIntakeMotorID, MotorType.kBrushless); + intakeUpDownMotor = new SparkMax(Constants.RobotConstants.kIntakeMotorID, MotorType.kBrushless); } /** - * Sets the power of the intake motor. - * - * @param power The power to set for the intake motor. + * Sets the speed of the intake motor. */ - public void setIntakePower(double power) { + public void startIntake() { - intakeMotor.set(-power*0.75); - // System.out.println(power); + intakeMotor.set(RobotConstants.kIntakeSpeed); } @@ -76,6 +75,22 @@ public double getRPM(){ } + /** + * Lifts the intake up. + */ + public void liftIntake(){ + intakeUpDownMotor.set(0.80); + intakeUpDownMotor.set(0); + } + + /** + * Lowers the intake down. + */ + public void lowerIntake(){ + intakeUpDownMotor.set(-0.80); + intakeUpDownMotor.set(0); + } + /** * Periodically updates the SmartDashboard with the intake motor's RPM and current. * This method is called automatically to update sensor status on the dashboard. From 4fbb789248276eef83289f124af676e8e583599c Mon Sep 17 00:00:00 2001 From: Xander99-9 Date: Fri, 13 Feb 2026 20:58:42 -0500 Subject: [PATCH 06/12] added Controller bindings and reverse intake --- .../src/main/java/frc/robot/Constants.java | 4 +- .../main/java/frc/robot/RobotContainer.java | 47 ++++++++++++------- .../commands/RunIntakeCommandReversed.java | 29 ++++++++++++ .../frc/robot/subsystems/IntakeSubsystem.java | 13 ++++- 4 files changed, 72 insertions(+), 21 deletions(-) create mode 100644 2026-2706-Robot-Code/src/main/java/frc/robot/commands/RunIntakeCommandReversed.java diff --git a/2026-2706-Robot-Code/src/main/java/frc/robot/Constants.java b/2026-2706-Robot-Code/src/main/java/frc/robot/Constants.java index ec4f213..d3348a9 100644 --- a/2026-2706-Robot-Code/src/main/java/frc/robot/Constants.java +++ b/2026-2706-Robot-Code/src/main/java/frc/robot/Constants.java @@ -19,8 +19,8 @@ public static class OperatorConstants { public static class RobotConstants { public static final int kSelectorSwitchPort = 0; public static final int kRPMConversionFactor = 1 / 3; - public static final int kIntakeMotorID = 45; - public static final int kIntakeUpDownMotorID = 22; + public static final int kIntakeMotorID = 22; + public static final int kIntakeUpDownMotorID = 24; public static final double kIntakeSpeed = 0.5; } diff --git a/2026-2706-Robot-Code/src/main/java/frc/robot/RobotContainer.java b/2026-2706-Robot-Code/src/main/java/frc/robot/RobotContainer.java index a33249e..8812f58 100644 --- a/2026-2706-Robot-Code/src/main/java/frc/robot/RobotContainer.java +++ b/2026-2706-Robot-Code/src/main/java/frc/robot/RobotContainer.java @@ -7,10 +7,16 @@ import frc.robot.Constants.OperatorConstants; import frc.robot.commands.Autos; import frc.robot.commands.ExampleCommand; +import frc.robot.commands.RunIntakeCommand; +import frc.robot.commands.RunIntakeCommandReversed; +import edu.wpi.first.wpilibj2.command.Commands; import frc.robot.subsystems.ExampleSubsystem; +import frc.robot.subsystems.IntakeSubsystem; +import edu.wpi.first.wpilibj.XboxController; import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.button.CommandXboxController; import edu.wpi.first.wpilibj2.command.button.Trigger; +import edu.wpi.first.wpilibj2.command.button.JoystickButton; /** * This class is where the bulk of the robot should be declared. Since Command-based is a @@ -19,19 +25,33 @@ * subsystems, commands, and trigger mappings) should be declared here. */ public class RobotContainer { - // The robot's subsystems and commands are defined here... - private final ExampleSubsystem m_exampleSubsystem = new ExampleSubsystem(); - // Replace with CommandPS4Controller or CommandJoystick if needed - private final CommandXboxController m_driverController = - new CommandXboxController(OperatorConstants.kDriverControllerPort); + // Subsystem + private final IntakeSubsystem intakeSubsystem = new IntakeSubsystem(); + + // Controller + private final XboxController driverController = new XboxController(0); - /** The container for the robot. Contains subsystems, OI devices, and commands. */ public RobotContainer() { - // Configure the trigger bindings - configureBindings(); + configureButtonBindings(); } + private void configureButtonBindings() { + + // Toggle intake ON/OFF + JoystickButton intakeToggleButton = + new JoystickButton(driverController, XboxController.Button.kA.value); + + intakeToggleButton.toggleOnTrue(new RunIntakeCommand(intakeSubsystem)); + + // Run intake in reverse while held + JoystickButton reverseButton = + new JoystickButton(driverController, XboxController.Button.kB.value); + + reverseButton.whileTrue(new RunIntakeCommandReversed(intakeSubsystem)); + } + + /** * 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 @@ -42,13 +62,7 @@ public RobotContainer() { * joysticks}. */ private void configureBindings() { - // Schedule `ExampleCommand` when `exampleCondition` changes to `true` - new Trigger(m_exampleSubsystem::exampleCondition) - .onTrue(new ExampleCommand(m_exampleSubsystem)); - - // Schedule `exampleMethodCommand` when the Xbox controller's B button is pressed, - // cancelling on release. - m_driverController.b().whileTrue(m_exampleSubsystem.exampleMethodCommand()); + } /** @@ -57,7 +71,6 @@ private void configureBindings() { * @return the command to run in autonomous */ public Command getAutonomousCommand() { - // An example command will be run in autonomous - return Autos.exampleAuto(m_exampleSubsystem); + return Commands.none(); } } diff --git a/2026-2706-Robot-Code/src/main/java/frc/robot/commands/RunIntakeCommandReversed.java b/2026-2706-Robot-Code/src/main/java/frc/robot/commands/RunIntakeCommandReversed.java new file mode 100644 index 0000000..42707f0 --- /dev/null +++ b/2026-2706-Robot-Code/src/main/java/frc/robot/commands/RunIntakeCommandReversed.java @@ -0,0 +1,29 @@ +package frc.robot.commands; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.IntakeSubsystem; + +public class RunIntakeCommandReversed extends Command { + + private final IntakeSubsystem intake; + + public RunIntakeCommandReversed(IntakeSubsystem intake) { + this.intake = intake; + addRequirements(intake); + } + + @Override + public void initialize() { + intake.reverseIntake(); + } + + @Override + public void end(boolean interrupted) { + intake.stopIntake(); + } + + @Override + public boolean isFinished() { + return false; + } +} diff --git a/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/IntakeSubsystem.java b/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/IntakeSubsystem.java index 6547ea4..4e85b1e 100644 --- a/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/IntakeSubsystem.java +++ b/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/IntakeSubsystem.java @@ -31,12 +31,12 @@ public class IntakeSubsystem extends SubsystemBase { */ public IntakeSubsystem() { intakeMotor = new SparkMax(Constants.RobotConstants.kIntakeMotorID, MotorType.kBrushless); - intakeUpDownMotor = new SparkMax(Constants.RobotConstants.kIntakeMotorID, MotorType.kBrushless); + intakeUpDownMotor = new SparkMax(Constants.RobotConstants.kIntakeUpDownMotorID, MotorType.kBrushless); } /** - * Sets the speed of the intake motor. + * Starts the intake motor. */ public void startIntake() { @@ -44,6 +44,15 @@ public void startIntake() { } + /** + * Starts the intake motor, but backwards. + */ + public void reverseIntake() { + + intakeMotor.set(-RobotConstants.kIntakeSpeed); + + } + /** * Stops the intake motor. */ From 2cc4e6dc4119fd7da2a46df747fb3b2d8fa54c9d Mon Sep 17 00:00:00 2001 From: Xander99-9 Date: Sat, 14 Feb 2026 11:09:38 -0500 Subject: [PATCH 07/12] adding controls to raise and lower intake --- .../src/main/java/frc/robot/Constants.java | 5 +++ .../main/java/frc/robot/RobotContainer.java | 9 ++++-- .../robot/commands/IntakeDownUpCommand.java | 29 +++++++++++++++++ .../frc/robot/subsystems/IntakeSubsystem.java | 31 ++++++++++++------- 4 files changed, 60 insertions(+), 14 deletions(-) create mode 100644 2026-2706-Robot-Code/src/main/java/frc/robot/commands/IntakeDownUpCommand.java diff --git a/2026-2706-Robot-Code/src/main/java/frc/robot/Constants.java b/2026-2706-Robot-Code/src/main/java/frc/robot/Constants.java index d3348a9..c6a195e 100644 --- a/2026-2706-Robot-Code/src/main/java/frc/robot/Constants.java +++ b/2026-2706-Robot-Code/src/main/java/frc/robot/Constants.java @@ -19,9 +19,14 @@ public static class OperatorConstants { public static class RobotConstants { public static final int kSelectorSwitchPort = 0; public static final int kRPMConversionFactor = 1 / 3; + public static final int kIntakeMotorID = 22; public static final int kIntakeUpDownMotorID = 24; public static final double kIntakeSpeed = 0.5; + public static final double kUpPosition = 0.0; + public static final double kDownPosition = 12.0; + public static final double kTolerance = 0.3; + } public static class UtilityConstants { diff --git a/2026-2706-Robot-Code/src/main/java/frc/robot/RobotContainer.java b/2026-2706-Robot-Code/src/main/java/frc/robot/RobotContainer.java index 8812f58..7d8bc47 100644 --- a/2026-2706-Robot-Code/src/main/java/frc/robot/RobotContainer.java +++ b/2026-2706-Robot-Code/src/main/java/frc/robot/RobotContainer.java @@ -7,6 +7,7 @@ import frc.robot.Constants.OperatorConstants; import frc.robot.commands.Autos; import frc.robot.commands.ExampleCommand; +import frc.robot.commands.IntakeDownUpCommand; import frc.robot.commands.RunIntakeCommand; import frc.robot.commands.RunIntakeCommandReversed; import edu.wpi.first.wpilibj2.command.Commands; @@ -42,12 +43,16 @@ private void configureButtonBindings() { JoystickButton intakeToggleButton = new JoystickButton(driverController, XboxController.Button.kA.value); - intakeToggleButton.toggleOnTrue(new RunIntakeCommand(intakeSubsystem)); - // Run intake in reverse while held JoystickButton reverseButton = new JoystickButton(driverController, XboxController.Button.kB.value); + // Toggle intake to go up and down + JoystickButton intakeDownUpButton = + new JoystickButton(driverController, XboxController.Button.kX.value); + + intakeDownUpButton.toggleOnTrue(new IntakeDownUpCommand(intakeSubsystem)); + intakeToggleButton.toggleOnTrue(new RunIntakeCommand(intakeSubsystem)); reverseButton.whileTrue(new RunIntakeCommandReversed(intakeSubsystem)); } diff --git a/2026-2706-Robot-Code/src/main/java/frc/robot/commands/IntakeDownUpCommand.java b/2026-2706-Robot-Code/src/main/java/frc/robot/commands/IntakeDownUpCommand.java new file mode 100644 index 0000000..089152a --- /dev/null +++ b/2026-2706-Robot-Code/src/main/java/frc/robot/commands/IntakeDownUpCommand.java @@ -0,0 +1,29 @@ +package frc.robot.commands; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.IntakeSubsystem; + +public class IntakeDownUpCommand extends Command { + + private final IntakeSubsystem intake; + + public IntakeDownUpCommand(IntakeSubsystem intake) { + this.intake = intake; + addRequirements(intake); + } + + @Override + public void initialize() { + intake.moveIntakeDown(); + } + + @Override + public void end(boolean interrupted) { + intake.moveIntakeUp(); + } + + @Override + public boolean isFinished() { + return false; + } +} diff --git a/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/IntakeSubsystem.java b/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/IntakeSubsystem.java index 4e85b1e..d6ba49b 100644 --- a/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/IntakeSubsystem.java +++ b/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/IntakeSubsystem.java @@ -3,12 +3,14 @@ // the WPILib BSD license file in the root directory of this project. package frc.robot.subsystems; -import edu.wpi.first.math.controller.PIDController; + import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj2.command.SubsystemBase; +import com.revrobotics.spark.SparkClosedLoopController; +import com.revrobotics.spark.SparkBase.ControlType; +import com.revrobotics.RelativeEncoder; import com.revrobotics.spark.SparkMax; - import com.revrobotics.spark.SparkLowLevel.MotorType; import frc.robot.Constants; @@ -24,6 +26,8 @@ public class IntakeSubsystem extends SubsystemBase { private SparkMax intakeMotor; private SparkMax intakeUpDownMotor; + private final RelativeEncoder intakeUpDownEncoder; + private final SparkClosedLoopController intakeUpDownPID; /** * Constructs a new Intake subsystem. @@ -31,7 +35,12 @@ public class IntakeSubsystem extends SubsystemBase { */ public IntakeSubsystem() { intakeMotor = new SparkMax(Constants.RobotConstants.kIntakeMotorID, MotorType.kBrushless); + intakeUpDownMotor = new SparkMax(Constants.RobotConstants.kIntakeUpDownMotorID, MotorType.kBrushless); + intakeUpDownEncoder = intakeUpDownMotor.getEncoder(); + intakeUpDownPID = intakeUpDownMotor.getClosedLoopController(); + + intakeUpDownEncoder.setPosition(0.0); } @@ -85,20 +94,18 @@ public double getRPM(){ } /** - * Lifts the intake up. + * Moves the intake down. */ - public void liftIntake(){ - intakeUpDownMotor.set(0.80); - intakeUpDownMotor.set(0); - } + public void moveIntakeDown() { + intakeUpDownPID.setSetpoint(RobotConstants.kDownPosition, ControlType.kPosition); +} /** - * Lowers the intake down. + * Moves the intake up. */ - public void lowerIntake(){ - intakeUpDownMotor.set(-0.80); - intakeUpDownMotor.set(0); - } + public void moveIntakeUp() { + intakeUpDownPID.setSetpoint(RobotConstants.kUpPosition, ControlType.kPosition); +} /** * Periodically updates the SmartDashboard with the intake motor's RPM and current. From e3b497818ab2a516bdf62af7e2f6440d8b10bb0f Mon Sep 17 00:00:00 2001 From: Xander99-9 Date: Sat, 14 Feb 2026 11:49:49 -0500 Subject: [PATCH 08/12] changed the motor ID --- .wpilib/wpilib_preferences.json | 6 ++++++ 2026-2706-Robot-Code/src/main/java/frc/robot/Constants.java | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .wpilib/wpilib_preferences.json diff --git a/.wpilib/wpilib_preferences.json b/.wpilib/wpilib_preferences.json new file mode 100644 index 0000000..5cef20d --- /dev/null +++ b/.wpilib/wpilib_preferences.json @@ -0,0 +1,6 @@ +{ + "currentLanguage": "none", + "enableCppIntellisense": false, + "projectYear": "none", + "teamNumber": 2706 +} \ No newline at end of file diff --git a/2026-2706-Robot-Code/src/main/java/frc/robot/Constants.java b/2026-2706-Robot-Code/src/main/java/frc/robot/Constants.java index c6a195e..ee76940 100644 --- a/2026-2706-Robot-Code/src/main/java/frc/robot/Constants.java +++ b/2026-2706-Robot-Code/src/main/java/frc/robot/Constants.java @@ -21,10 +21,10 @@ public static class RobotConstants { public static final int kRPMConversionFactor = 1 / 3; public static final int kIntakeMotorID = 22; - public static final int kIntakeUpDownMotorID = 24; + public static final int kIntakeUpDownMotorID = 23; public static final double kIntakeSpeed = 0.5; public static final double kUpPosition = 0.0; - public static final double kDownPosition = 12.0; + public static final double kDownPosition = 40.0; public static final double kTolerance = 0.3; } From bb6b2782201c850a6b58243d5ed99eaf5482e782 Mon Sep 17 00:00:00 2001 From: Xander99-9 Date: Sat, 14 Feb 2026 11:50:36 -0500 Subject: [PATCH 09/12] fixed santax error --- .../src/main/java/frc/robot/RobotContainer.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/2026-2706-Robot-Code/src/main/java/frc/robot/RobotContainer.java b/2026-2706-Robot-Code/src/main/java/frc/robot/RobotContainer.java index 60849f0..882cb1f 100644 --- a/2026-2706-Robot-Code/src/main/java/frc/robot/RobotContainer.java +++ b/2026-2706-Robot-Code/src/main/java/frc/robot/RobotContainer.java @@ -110,8 +110,6 @@ public Command getAutonomousCommand() { //null; default: return null; - }}} - - return Commands.none(); + } } } From 269cb04eae651590946eabeaa045525f5a5202d1 Mon Sep 17 00:00:00 2001 From: Xander99-9 Date: Fri, 20 Feb 2026 20:34:03 -0500 Subject: [PATCH 10/12] changed names to. make things more clear, added seperate commands to make things easier --- .../main/java/frc/robot/RobotContainer.java | 4 ++-- ...nUpCommand.java => IntakeDownCommand.java} | 11 +++------ .../frc/robot/commands/IntakeUpCommand.java | 24 +++++++++++++++++++ ...mand.java => RunIntakeCommandForward.java} | 4 ++-- 4 files changed, 31 insertions(+), 12 deletions(-) rename 2026-2706-Robot-Code/src/main/java/frc/robot/commands/{IntakeDownUpCommand.java => IntakeDownCommand.java} (62%) create mode 100644 2026-2706-Robot-Code/src/main/java/frc/robot/commands/IntakeUpCommand.java rename 2026-2706-Robot-Code/src/main/java/frc/robot/commands/{RunIntakeCommand.java => RunIntakeCommandForward.java} (80%) diff --git a/2026-2706-Robot-Code/src/main/java/frc/robot/RobotContainer.java b/2026-2706-Robot-Code/src/main/java/frc/robot/RobotContainer.java index 882cb1f..8fbcc40 100644 --- a/2026-2706-Robot-Code/src/main/java/frc/robot/RobotContainer.java +++ b/2026-2706-Robot-Code/src/main/java/frc/robot/RobotContainer.java @@ -12,7 +12,7 @@ import frc.robot.commands.IntakeDownUpCommand; -import frc.robot.commands.RunIntakeCommand; +import frc.robot.commands.RunIntakeCommandForward; import frc.robot.commands.RunIntakeCommandReversed; import edu.wpi.first.wpilibj2.command.Commands; import frc.robot.subsystems.ExampleSubsystem; @@ -59,7 +59,7 @@ private void configureButtonBindings() { new JoystickButton(driverController, XboxController.Button.kX.value); intakeDownUpButton.toggleOnTrue(new IntakeDownUpCommand(intakeSubsystem)); - intakeToggleButton.toggleOnTrue(new RunIntakeCommand(intakeSubsystem)); + intakeToggleButton.toggleOnTrue(new RunIntakeCommandForward(intakeSubsystem)); reverseButton.whileTrue(new RunIntakeCommandReversed(intakeSubsystem)); } diff --git a/2026-2706-Robot-Code/src/main/java/frc/robot/commands/IntakeDownUpCommand.java b/2026-2706-Robot-Code/src/main/java/frc/robot/commands/IntakeDownCommand.java similarity index 62% rename from 2026-2706-Robot-Code/src/main/java/frc/robot/commands/IntakeDownUpCommand.java rename to 2026-2706-Robot-Code/src/main/java/frc/robot/commands/IntakeDownCommand.java index 089152a..2ad3495 100644 --- a/2026-2706-Robot-Code/src/main/java/frc/robot/commands/IntakeDownUpCommand.java +++ b/2026-2706-Robot-Code/src/main/java/frc/robot/commands/IntakeDownCommand.java @@ -3,11 +3,11 @@ import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.IntakeSubsystem; -public class IntakeDownUpCommand extends Command { +public class IntakeDownCommand extends Command { private final IntakeSubsystem intake; - public IntakeDownUpCommand(IntakeSubsystem intake) { + public IntakeDownCommand(IntakeSubsystem intake) { this.intake = intake; addRequirements(intake); } @@ -17,13 +17,8 @@ public void initialize() { intake.moveIntakeDown(); } - @Override - public void end(boolean interrupted) { - intake.moveIntakeUp(); - } - @Override public boolean isFinished() { - return false; + return true; } } diff --git a/2026-2706-Robot-Code/src/main/java/frc/robot/commands/IntakeUpCommand.java b/2026-2706-Robot-Code/src/main/java/frc/robot/commands/IntakeUpCommand.java new file mode 100644 index 0000000..270013e --- /dev/null +++ b/2026-2706-Robot-Code/src/main/java/frc/robot/commands/IntakeUpCommand.java @@ -0,0 +1,24 @@ +package frc.robot.commands; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.IntakeSubsystem; + +public class IntakeUpCommand extends Command { + + private final IntakeSubsystem intake; + + public IntakeUpCommand(IntakeSubsystem intake) { + this.intake = intake; + addRequirements(intake); + } + + @Override + public void initialize() { + intake.moveIntakeUp(); + } + + @Override + public boolean isFinished() { + return true; + } +} diff --git a/2026-2706-Robot-Code/src/main/java/frc/robot/commands/RunIntakeCommand.java b/2026-2706-Robot-Code/src/main/java/frc/robot/commands/RunIntakeCommandForward.java similarity index 80% rename from 2026-2706-Robot-Code/src/main/java/frc/robot/commands/RunIntakeCommand.java rename to 2026-2706-Robot-Code/src/main/java/frc/robot/commands/RunIntakeCommandForward.java index bc37d9b..5a4c466 100644 --- a/2026-2706-Robot-Code/src/main/java/frc/robot/commands/RunIntakeCommand.java +++ b/2026-2706-Robot-Code/src/main/java/frc/robot/commands/RunIntakeCommandForward.java @@ -3,11 +3,11 @@ import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.IntakeSubsystem; -public class RunIntakeCommand extends Command { +public class RunIntakeCommandForward extends Command { private final IntakeSubsystem intake; - public RunIntakeCommand(IntakeSubsystem intake) { + public RunIntakeCommandForward(IntakeSubsystem intake) { this.intake = intake; addRequirements(intake); } From 844d2564d5a1267c048f96f2dc22981f1a984df5 Mon Sep 17 00:00:00 2001 From: Xander99-9 Date: Sat, 21 Feb 2026 11:55:20 -0500 Subject: [PATCH 11/12] addded PID and a soft limit. not tested --- .../src/main/java/frc/robot/Constants.java | 4 ++++ .../main/java/frc/robot/RobotContainer.java | 17 +++++++++++------ .../frc/robot/subsystems/IntakeSubsystem.java | 19 ++++++++++++++++++- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/2026-2706-Robot-Code/src/main/java/frc/robot/Constants.java b/2026-2706-Robot-Code/src/main/java/frc/robot/Constants.java index ee76940..4eb0162 100644 --- a/2026-2706-Robot-Code/src/main/java/frc/robot/Constants.java +++ b/2026-2706-Robot-Code/src/main/java/frc/robot/Constants.java @@ -26,6 +26,10 @@ public static class RobotConstants { public static final double kUpPosition = 0.0; public static final double kDownPosition = 40.0; public static final double kTolerance = 0.3; + + public static final double kUpDownP = 0.1; + public static final double kUpDownI = 0.0; + public static final double kUpDownD = 0.0; } diff --git a/2026-2706-Robot-Code/src/main/java/frc/robot/RobotContainer.java b/2026-2706-Robot-Code/src/main/java/frc/robot/RobotContainer.java index 8fbcc40..3d857bd 100644 --- a/2026-2706-Robot-Code/src/main/java/frc/robot/RobotContainer.java +++ b/2026-2706-Robot-Code/src/main/java/frc/robot/RobotContainer.java @@ -7,11 +7,11 @@ import frc.robot.Constants.OperatorConstants; import frc.robot.commands.Autos; -import frc.robot.commands.ExampleCommand; import edu.wpi.first.wpilibj2.command.PrintCommand; -import frc.robot.commands.IntakeDownUpCommand; +import frc.robot.commands.IntakeDownCommand; +import frc.robot.commands.IntakeUpCommand; import frc.robot.commands.RunIntakeCommandForward; import frc.robot.commands.RunIntakeCommandReversed; import edu.wpi.first.wpilibj2.command.Commands; @@ -54,11 +54,16 @@ private void configureButtonBindings() { JoystickButton reverseButton = new JoystickButton(driverController, XboxController.Button.kB.value); - // Toggle intake to go up and down - JoystickButton intakeDownUpButton = - new JoystickButton(driverController, XboxController.Button.kX.value); + // Toggle intake to go down + JoystickButton intakeDownButton = + new JoystickButton(driverController, XboxController.Button.kRightStick.value); - intakeDownUpButton.toggleOnTrue(new IntakeDownUpCommand(intakeSubsystem)); + // Toggle intake to go up + JoystickButton intakeUpButton = + new JoystickButton(driverController, XboxController.Button.kRightBumper.value); + + intakeDownButton.toggleOnTrue(new IntakeDownCommand(intakeSubsystem)); + intakeUpButton.toggleOnTrue(new IntakeUpCommand(intakeSubsystem)); intakeToggleButton.toggleOnTrue(new RunIntakeCommandForward(intakeSubsystem)); reverseButton.whileTrue(new RunIntakeCommandReversed(intakeSubsystem)); } diff --git a/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/IntakeSubsystem.java b/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/IntakeSubsystem.java index d6ba49b..88b9497 100644 --- a/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/IntakeSubsystem.java +++ b/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/IntakeSubsystem.java @@ -11,6 +11,10 @@ import com.revrobotics.spark.SparkBase.ControlType; import com.revrobotics.RelativeEncoder; import com.revrobotics.spark.SparkMax; +import com.revrobotics.spark.config.SparkMaxConfig; +import com.revrobotics.ResetMode; +import com.revrobotics.PersistMode; +import com.revrobotics.spark.SparkSoftLimit.SoftLimitDirection; import com.revrobotics.spark.SparkLowLevel.MotorType; import frc.robot.Constants; @@ -39,9 +43,22 @@ public IntakeSubsystem() { intakeUpDownMotor = new SparkMax(Constants.RobotConstants.kIntakeUpDownMotorID, MotorType.kBrushless); intakeUpDownEncoder = intakeUpDownMotor.getEncoder(); intakeUpDownPID = intakeUpDownMotor.getClosedLoopController(); - + + // Resets the position to 0, turn the robot off while in up position to prevent things breaking. intakeUpDownEncoder.setPosition(0.0); + SparkMaxConfig upDownConfig = new SparkMaxConfig(); + upDownConfig.closedLoop + .p(RobotConstants.kUpDownP) + .i(RobotConstants.kUpDownI) + .d(RobotConstants.kUpDownD); + + upDownConfig.softLimit + .forwardSoftLimit(RobotConstants.kUpPosition) + .forwardSoftLimitEnabled(true) + .reverseSoftLimit(RobotConstants.kDownPosition) + .reverseSoftLimitEnabled(true); + intakeUpDownMotor.configure(upDownConfig, ResetMode.kResetSafeParameters, PersistMode.kPersistParameters); } /** From e847bc919730bd3ab077f7d16318f94858dd1d8f Mon Sep 17 00:00:00 2001 From: Xander99-9 Date: Fri, 27 Feb 2026 19:21:28 -0500 Subject: [PATCH 12/12] Tested and works --- .../src/main/java/frc/robot/Constants.java | 10 +++++----- .../src/main/java/frc/robot/RobotContainer.java | 4 ++-- .../java/frc/robot/subsystems/IntakeSubsystem.java | 11 +++++------ 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/2026-2706-Robot-Code/src/main/java/frc/robot/Constants.java b/2026-2706-Robot-Code/src/main/java/frc/robot/Constants.java index 4eb0162..07c41d8 100644 --- a/2026-2706-Robot-Code/src/main/java/frc/robot/Constants.java +++ b/2026-2706-Robot-Code/src/main/java/frc/robot/Constants.java @@ -20,14 +20,14 @@ public static class RobotConstants { public static final int kSelectorSwitchPort = 0; public static final int kRPMConversionFactor = 1 / 3; - public static final int kIntakeMotorID = 22; - public static final int kIntakeUpDownMotorID = 23; + public static final int kIntakeMotorID = 15; + public static final int kIntakeUpDownMotorID = 30; public static final double kIntakeSpeed = 0.5; - public static final double kUpPosition = 0.0; - public static final double kDownPosition = 40.0; + public static final double kUpPosition = 20; + public static final double kDownPosition = -20; //must be a negitive public static final double kTolerance = 0.3; - public static final double kUpDownP = 0.1; + public static final double kUpDownP = 0.2; public static final double kUpDownI = 0.0; public static final double kUpDownD = 0.0; diff --git a/2026-2706-Robot-Code/src/main/java/frc/robot/RobotContainer.java b/2026-2706-Robot-Code/src/main/java/frc/robot/RobotContainer.java index 3d857bd..fdbafd0 100644 --- a/2026-2706-Robot-Code/src/main/java/frc/robot/RobotContainer.java +++ b/2026-2706-Robot-Code/src/main/java/frc/robot/RobotContainer.java @@ -56,11 +56,11 @@ private void configureButtonBindings() { // Toggle intake to go down JoystickButton intakeDownButton = - new JoystickButton(driverController, XboxController.Button.kRightStick.value); + new JoystickButton(driverController, XboxController.Button.kX.value); // Toggle intake to go up JoystickButton intakeUpButton = - new JoystickButton(driverController, XboxController.Button.kRightBumper.value); + new JoystickButton(driverController, XboxController.Button.kY.value); intakeDownButton.toggleOnTrue(new IntakeDownCommand(intakeSubsystem)); intakeUpButton.toggleOnTrue(new IntakeUpCommand(intakeSubsystem)); diff --git a/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/IntakeSubsystem.java b/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/IntakeSubsystem.java index 88b9497..4c5e004 100644 --- a/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/IntakeSubsystem.java +++ b/2026-2706-Robot-Code/src/main/java/frc/robot/subsystems/IntakeSubsystem.java @@ -11,6 +11,7 @@ import com.revrobotics.spark.SparkBase.ControlType; import com.revrobotics.RelativeEncoder; import com.revrobotics.spark.SparkMax; +import com.revrobotics.spark.config.SoftLimitConfig; import com.revrobotics.spark.config.SparkMaxConfig; import com.revrobotics.ResetMode; import com.revrobotics.PersistMode; @@ -65,7 +66,6 @@ public IntakeSubsystem() { * Starts the intake motor. */ public void startIntake() { - intakeMotor.set(RobotConstants.kIntakeSpeed); } @@ -74,8 +74,7 @@ public void startIntake() { * Starts the intake motor, but backwards. */ public void reverseIntake() { - - intakeMotor.set(-RobotConstants.kIntakeSpeed); + intakeMotor.set(-RobotConstants.kIntakeSpeed); } @@ -104,11 +103,11 @@ public double getRawMotorRPM(){ * * @return The converted RPM of the intake motor. */ - public double getRPM(){ + /*public double getRPM(){ return getRawMotorRPM() * RobotConstants.kRPMConversionFactor; - } + }*/ /** * Moves the intake down. @@ -131,7 +130,7 @@ public void moveIntakeUp() { @Override public void periodic() { if (UtilityConstants.debugMode){ - SmartDashboard.putNumber("Intake RPM", getRPM()); + SmartDashboard.putNumber("Intake RPM", getRawMotorRPM()); SmartDashboard.putNumber("Intake Current", intakeMotor.getOutputCurrent()); } }