From 768e85f61159edd65092c6e41e56a0426f90fe81 Mon Sep 17 00:00:00 2001 From: Logan Hollowood <98189655+GearBoxFox@users.noreply.github.com> Date: Sun, 12 Jan 2025 16:23:56 -0500 Subject: [PATCH] proto intake --- build.gradle | 2 +- src/main/java/frc/robot/BuildConstants.java | 10 +++---- src/main/java/frc/robot/RobotContainer.java | 29 +++++++++++++++++-- .../subsystems/drive/DriveConstants.java | 4 +-- .../{drive => }/intake/IntakeConstants.java | 2 +- .../{drive => }/intake/IntakeIO.java | 4 +-- .../subsystems/intake/IntakeIOProto.java | 29 +++++++++++++++++++ .../{drive => }/intake/IntakeIOTalon.java | 4 +-- .../{drive => }/intake/IntakeSubsystem.java | 2 +- 9 files changed, 70 insertions(+), 16 deletions(-) rename src/main/java/frc/robot/subsystems/{drive => }/intake/IntakeConstants.java (92%) rename src/main/java/frc/robot/subsystems/{drive => }/intake/IntakeIO.java (90%) create mode 100644 src/main/java/frc/robot/subsystems/intake/IntakeIOProto.java rename src/main/java/frc/robot/subsystems/{drive => }/intake/IntakeIOTalon.java (97%) rename src/main/java/frc/robot/subsystems/{drive => }/intake/IntakeSubsystem.java (95%) diff --git a/build.gradle b/build.gradle index 6144ebf..cbf82da 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id "java" - id "edu.wpi.first.GradleRIO" version "2025.1.1" + id "edu.wpi.first.GradleRIO" version "2025.2.1" id "io.freefair.lombok" version "8.4" id "com.peterabeles.gversion" version "1.10" id "org.sonarqube" version "4.4.1.3373" diff --git a/src/main/java/frc/robot/BuildConstants.java b/src/main/java/frc/robot/BuildConstants.java index c8516a0..cd95abc 100644 --- a/src/main/java/frc/robot/BuildConstants.java +++ b/src/main/java/frc/robot/BuildConstants.java @@ -7,12 +7,12 @@ public final class BuildConstants { public static final String MAVEN_GROUP = ""; public static final String MAVEN_NAME = "2025Reefscape"; public static final String VERSION = "unspecified"; - public static final int GIT_REVISION = 35; - public static final String GIT_SHA = "8674f2facd6148db82f6d5a34d2d6eb8c13f0b3c"; - public static final String GIT_DATE = "2025-01-10 21:32:01 EST"; + public static final int GIT_REVISION = 38; + public static final String GIT_SHA = "3247b4284f4e00bc01d2ba380d636b3d9f9fb3d4"; + public static final String GIT_DATE = "2025-01-12 13:32:06 EST"; public static final String GIT_BRANCH = "intake"; - public static final String BUILD_DATE = "2025-01-11 16:11:33 EST"; - public static final long BUILD_UNIX_TIME = 1736629893778L; + public static final String BUILD_DATE = "2025-01-12 16:15:02 EST"; + public static final long BUILD_UNIX_TIME = 1736716502078L; public static final int DIRTY = 1; private BuildConstants(){} diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index b0f40bd..108fae3 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -14,6 +14,9 @@ import frc.robot.subsystems.drive.module.ModuleIO; import frc.robot.subsystems.drive.module.ModuleIOSim; import frc.robot.subsystems.drive.module.ModuleIOSparkMax; +import frc.robot.subsystems.intake.IntakeIO; +import frc.robot.subsystems.intake.IntakeIOProto; +import frc.robot.subsystems.intake.IntakeSubsystem; import org.ironmaple.simulation.SimulatedArena; import org.ironmaple.simulation.drivesims.SwerveDriveSimulation; import org.littletonrobotics.junction.Logger; @@ -23,9 +26,11 @@ public class RobotContainer { private final CommandXboxController driveController = new CommandXboxController(0); DriveSubsystem driveSubsystem; + private final IntakeSubsystem intakeSubsystem; + public RobotContainer() { switch (Constants.getMode()) { - case REAL -> + case REAL -> { driveSubsystem = new DriveSubsystem( new GyroIOPigeon2(), new ModuleIOSparkMax(DriveConstants.MODULE_CONSTANTS[0]), @@ -33,6 +38,8 @@ public RobotContainer() { new ModuleIOSparkMax(DriveConstants.MODULE_CONSTANTS[2]), new ModuleIOSparkMax(DriveConstants.MODULE_CONSTANTS[3]) ); + intakeSubsystem = new IntakeSubsystem(new IntakeIOProto()); + } case SIM -> { driveSimulation = new SwerveDriveSimulation(DriveConstants.MAPLE_SIM_CONFIG, new Pose2d(3, 3, new Rotation2d())); @@ -46,8 +53,10 @@ public RobotContainer() { ); SimulatedArena.getInstance().resetFieldForAuto(); + + intakeSubsystem = new IntakeSubsystem(new IntakeIO() {}); } - case REPLAY -> + case REPLAY -> { driveSubsystem = new DriveSubsystem( new GyroIO() { }, @@ -56,6 +65,11 @@ public RobotContainer() { new ModuleIO() {}, new ModuleIO() {} ); + intakeSubsystem = new IntakeSubsystem(new IntakeIO() {}); + } + default -> { + intakeSubsystem = new IntakeSubsystem(new IntakeIO() {}); + } } configureBindings(); } @@ -67,6 +81,17 @@ private void configureBindings() { () -> -driveController.getLeftX(), () -> -driveController.getRightX() )); + + driveController.a().whileTrue( + Commands.run(() -> intakeSubsystem.setIntakePower(6.0), intakeSubsystem) + ).whileFalse( + Commands.run(() -> intakeSubsystem.setIntakePower(0.0)) + ); + driveController.b().whileTrue( + Commands.run(() -> intakeSubsystem.setIntakePower(-6.0), intakeSubsystem) + ).whileFalse( + Commands.run(() -> intakeSubsystem.setIntakePower(0.0)) + ); } public Command getAutonomousCommand() { diff --git a/src/main/java/frc/robot/subsystems/drive/DriveConstants.java b/src/main/java/frc/robot/subsystems/drive/DriveConstants.java index 0e0e8f2..c04400c 100644 --- a/src/main/java/frc/robot/subsystems/drive/DriveConstants.java +++ b/src/main/java/frc/robot/subsystems/drive/DriveConstants.java @@ -69,7 +69,7 @@ public class DriveConstants { .driveId(4) .steerId(5) .encoderId(6) - .encoderOffset(Rotation2d.fromDegrees(-101.60).unaryMinus()) + .encoderOffset(Rotation2d.fromDegrees(-101.60).unaryMinus().plus(Rotation2d.k180deg)) .steerInverted(true) .turnInverted(false) .build(), @@ -87,7 +87,7 @@ public class DriveConstants { .driveId(10) .steerId(11) .encoderId(12) - .encoderOffset(Rotation2d.fromDegrees(60.20).unaryMinus()) + .encoderOffset(Rotation2d.fromDegrees(60.20).unaryMinus().plus(Rotation2d.k180deg)) .steerInverted(true) .turnInverted(false) .build() diff --git a/src/main/java/frc/robot/subsystems/drive/intake/IntakeConstants.java b/src/main/java/frc/robot/subsystems/intake/IntakeConstants.java similarity index 92% rename from src/main/java/frc/robot/subsystems/drive/intake/IntakeConstants.java rename to src/main/java/frc/robot/subsystems/intake/IntakeConstants.java index 93fb6fb..28ce112 100644 --- a/src/main/java/frc/robot/subsystems/drive/intake/IntakeConstants.java +++ b/src/main/java/frc/robot/subsystems/intake/IntakeConstants.java @@ -1,4 +1,4 @@ -package frc.robot.subsystems.drive.intake; +package frc.robot.subsystems.intake; public class IntakeConstants { public static final int INTAKE_ID = 0; diff --git a/src/main/java/frc/robot/subsystems/drive/intake/IntakeIO.java b/src/main/java/frc/robot/subsystems/intake/IntakeIO.java similarity index 90% rename from src/main/java/frc/robot/subsystems/drive/intake/IntakeIO.java rename to src/main/java/frc/robot/subsystems/intake/IntakeIO.java index bf6ed58..64703e4 100644 --- a/src/main/java/frc/robot/subsystems/drive/intake/IntakeIO.java +++ b/src/main/java/frc/robot/subsystems/intake/IntakeIO.java @@ -1,4 +1,4 @@ -package frc.robot.subsystems.drive.intake; +package frc.robot.subsystems.intake; import edu.wpi.first.math.geometry.Rotation2d; import org.littletonrobotics.junction.AutoLog; @@ -11,7 +11,7 @@ class IntakeIOInputs { public double pivotVoltage = 0.0; public double intakeVoltage = 0.0; public double pivotDraw = 0.0; - public double intakeDraw = 0.0; + public double intakeCurrentDraw = 0.0; public double pivotAppliedVolts = 0.0; public double intakeAppliedVolts = 0.0; public double pivotTemperature = 0.0; diff --git a/src/main/java/frc/robot/subsystems/intake/IntakeIOProto.java b/src/main/java/frc/robot/subsystems/intake/IntakeIOProto.java new file mode 100644 index 0000000..db7ecf7 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/intake/IntakeIOProto.java @@ -0,0 +1,29 @@ +package frc.robot.subsystems.intake; + +import com.ctre.phoenix6.configs.TalonFXConfiguration; +import com.ctre.phoenix6.hardware.TalonFX; +import com.ctre.phoenix6.signals.NeutralModeValue; + +public class IntakeIOProto implements IntakeIO { + private final TalonFX intake; + + public IntakeIOProto() { + intake = new TalonFX(17); + + var config = new TalonFXConfiguration(); + config.MotorOutput.NeutralMode = NeutralModeValue.Brake; + + intake.getConfigurator().apply(config); + } + + @Override + public void updateInputs(IntakeIOInputsAutoLogged inputs) { + inputs.intakeAppliedVolts = intake.getMotorVoltage().getValueAsDouble(); + inputs.intakeCurrentDraw = intake.getSupplyCurrent().getValueAsDouble(); + } + + @Override + public void setMotorVoltageIntake(double voltage) { + intake.setVoltage(voltage); + } +} diff --git a/src/main/java/frc/robot/subsystems/drive/intake/IntakeIOTalon.java b/src/main/java/frc/robot/subsystems/intake/IntakeIOTalon.java similarity index 97% rename from src/main/java/frc/robot/subsystems/drive/intake/IntakeIOTalon.java rename to src/main/java/frc/robot/subsystems/intake/IntakeIOTalon.java index 0bbac1f..7cc07db 100644 --- a/src/main/java/frc/robot/subsystems/drive/intake/IntakeIOTalon.java +++ b/src/main/java/frc/robot/subsystems/intake/IntakeIOTalon.java @@ -1,4 +1,4 @@ -package frc.robot.subsystems.drive.intake; +package frc.robot.subsystems.intake; import com.ctre.phoenix6.BaseStatusSignal; import com.ctre.phoenix6.StatusSignal; @@ -104,7 +104,7 @@ public void updateInputs (IntakeIOInputsAutoLogged inputs){ ); inputs.intakeVoltage = intakeVoltageSignal.refresh().getValueAsDouble(); inputs.pivotVoltage = pivotVoltageSignal.refresh().getValueAsDouble(); - inputs.intakeDraw = intakeDrawSignal.refresh().getValueAsDouble(); + inputs.intakeCurrentDraw = intakeDrawSignal.refresh().getValueAsDouble(); inputs.pivotDraw = pivotDrawSignal.refresh().getValueAsDouble(); inputs.intakeAppliedVolts = intakeAppliedVoltsSignal.refresh().getValueAsDouble(); inputs.pivotAppliedVolts = pivotAppliedVoltsSignal.refresh().getValueAsDouble(); diff --git a/src/main/java/frc/robot/subsystems/drive/intake/IntakeSubsystem.java b/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java similarity index 95% rename from src/main/java/frc/robot/subsystems/drive/intake/IntakeSubsystem.java rename to src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java index caa5b40..1485a65 100644 --- a/src/main/java/frc/robot/subsystems/drive/intake/IntakeSubsystem.java +++ b/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java @@ -1,4 +1,4 @@ -package frc.robot.subsystems.drive.intake; +package frc.robot.subsystems.intake; import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.SubsystemBase;