From 65c76aca95de81f342df7ff26a77e18856f22a83 Mon Sep 17 00:00:00 2001 From: Shatcar Date: Sat, 28 Mar 2026 15:56:54 -0600 Subject: [PATCH] working new intake --- .../java/frc4388/robot/RobotContainer.java | 2 +- .../robot/constants/BuildConstants.java | 10 ++--- .../robot/subsystems/intake/Intake.java | 5 ++- .../subsystems/intake/IntakeConstants.java | 25 ++++++++----- .../robot/subsystems/intake/IntakeIO.java | 5 ++- .../robot/subsystems/intake/IntakeReal.java | 37 +++++++++++-------- .../frc4388/utility/compute/JankCoder.java | 1 - 7 files changed, 50 insertions(+), 35 deletions(-) diff --git a/src/main/java/frc4388/robot/RobotContainer.java b/src/main/java/frc4388/robot/RobotContainer.java index 77ee3f6..3928609 100644 --- a/src/main/java/frc4388/robot/RobotContainer.java +++ b/src/main/java/frc4388/robot/RobotContainer.java @@ -164,7 +164,7 @@ public class RobotContainer { public RobotContainer() { - configureSINGLEBindings(); + configureButtonBindings(); // Called on first robot enable DeferredBlock.addBlock(() -> { diff --git a/src/main/java/frc4388/robot/constants/BuildConstants.java b/src/main/java/frc4388/robot/constants/BuildConstants.java index 78ac3f6..e304983 100644 --- a/src/main/java/frc4388/robot/constants/BuildConstants.java +++ b/src/main/java/frc4388/robot/constants/BuildConstants.java @@ -7,12 +7,12 @@ public final class BuildConstants { public static final String MAVEN_GROUP = ""; public static final String MAVEN_NAME = "2026KPopRobotHunters"; public static final String VERSION = "unspecified"; - public static final int GIT_REVISION = 185; - public static final String GIT_SHA = "7eba3d8faa208df9222599c53db1e11da82d7a96"; - public static final String GIT_DATE = "2026-03-25 11:39:55 MDT"; + public static final int GIT_REVISION = 188; + public static final String GIT_SHA = "d010829c21aa6f5bd1787cfcab1c02107fb353ff"; + public static final String GIT_DATE = "2026-03-28 13:30:33 MDT"; public static final String GIT_BRANCH = "New-Intake"; - public static final String BUILD_DATE = "2026-03-28 09:26:32 MDT"; - public static final long BUILD_UNIX_TIME = 1774711592752L; + public static final String BUILD_DATE = "2026-03-28 15:50:49 MDT"; + public static final long BUILD_UNIX_TIME = 1774734649429L; public static final int DIRTY = 1; private BuildConstants(){} diff --git a/src/main/java/frc4388/robot/subsystems/intake/Intake.java b/src/main/java/frc4388/robot/subsystems/intake/Intake.java index 3c28ce0..c16eb4a 100644 --- a/src/main/java/frc4388/robot/subsystems/intake/Intake.java +++ b/src/main/java/frc4388/robot/subsystems/intake/Intake.java @@ -109,7 +109,7 @@ public class Intake extends SubsystemBase { break; case Retracting: io.armOutput(IntakeConstants.ARM_RETRACT_PERCENT_OUTPUT.get()); - io.setRollerOutput(state, 0); + io.setRollerOutput(state, IntakeConstants.ROLLER_RETRACT_PERCENT_OUTPUT.get()); break; case Bouncing: io.setRollerOutput(state, 0); @@ -131,8 +131,9 @@ public class Intake extends SubsystemBase { io.armOutput(percentOutput); break; case Idle: + io.armOutput(0); // io.setArmAngle(state, Rotations.of(IntakeConstants.ARM_LIMIT_RETRACTED.get())); - io.setRollerOutput(state, 0); + // io.setRollerOutput(state, 0); break; } // if (state.retractedLimit){ diff --git a/src/main/java/frc4388/robot/subsystems/intake/IntakeConstants.java b/src/main/java/frc4388/robot/subsystems/intake/IntakeConstants.java index fd689e7..b71d075 100644 --- a/src/main/java/frc4388/robot/subsystems/intake/IntakeConstants.java +++ b/src/main/java/frc4388/robot/subsystems/intake/IntakeConstants.java @@ -13,7 +13,7 @@ public class IntakeConstants { public static final double ARM_MOTOR_GEAR_RATIO = 125; public static final double ROLLER_MOTOR_GEAR_RATIO = 3; - public static final double ARM_ENCODER_OFFSET = 0.; + public static final double ARM_ENCODER_OFFSET = -0.466; @@ -41,11 +41,14 @@ public class IntakeConstants { // public static final Angle ARM_LIMIT_LOWER = Degrees.of(90); // public static final Angle ARM_LIMIT_UPPER = Degrees.of(-90); - public static final ConfigurableDouble ARM_LIMIT_RETRACTED = new ConfigurableDouble("Arm angle retracted", 0.1); - public static final ConfigurableDouble ARM_LIMIT_EXTENDED = new ConfigurableDouble("Arm angle extended", 0.33); - public static final ConfigurableDouble ARM_EXTEND_PERCENT_OUTPUT = new ConfigurableDouble("Arm extend % output", 0.4); - public static final ConfigurableDouble ARM_RETRACT_PERCENT_OUTPUT = new ConfigurableDouble("Arm retract % output", -0.4); - public static final ConfigurableDouble ROLLER_PERCENT_OUTPUT = new ConfigurableDouble("Roller Percent Output", .70); + public static final ConfigurableDouble ARM_LIMIT_RETRACTED = new ConfigurableDouble("Arm angle retracted", 0.); + public static final ConfigurableDouble ARM_LIMIT_EXTENDED = new ConfigurableDouble("Arm angle extended", 1.8); + public static final ConfigurableDouble ARM_EXTEND_PERCENT_OUTPUT = new ConfigurableDouble("Arm extend % output", 0.1); + public static final ConfigurableDouble ARM_RETRACT_PERCENT_OUTPUT = new ConfigurableDouble("Arm retract % output", -0.1); + + public static final ConfigurableDouble ROLLER_PERCENT_OUTPUT = new ConfigurableDouble("Roller Percent Output", .80); + public static final ConfigurableDouble ROLLER_RETRACT_PERCENT_OUTPUT = new ConfigurableDouble("Roller Retract Output", .40); + // public static final ConfigurableDouble ROLL = new ConfigurableDouble("Arm angle extended", 0.25); // public static final AngularVelocity ROLLER_MAX_VELOCITY = RotationsPerSecond.of(4.0); @@ -77,10 +80,14 @@ public class IntakeConstants { static { ARM_MOTOR_CONFIG.limitSwitch - .reverseLimitSwitchType(Type.kNormallyClosed) .limitSwitchPositionSensor(FeedbackSensor.kPrimaryEncoder) - .forwardLimitSwitchPosition(0) - .forwardLimitSwitchTriggerBehavior(Behavior.kStopMovingMotorAndSetPosition); + + .forwardLimitSwitchType(Type.kNormallyOpen) + .forwardLimitSwitchTriggerBehavior(Behavior.kKeepMovingMotor) + + .reverseLimitSwitchType(Type.kNormallyClosed) + .reverseLimitSwitchPosition(0) + .reverseLimitSwitchTriggerBehavior(Behavior.kStopMovingMotorAndSetPosition); } // public static final TalonFXConfiguration ARM_MOTOR_CONFIG = new TalonFXConfiguration() diff --git a/src/main/java/frc4388/robot/subsystems/intake/IntakeIO.java b/src/main/java/frc4388/robot/subsystems/intake/IntakeIO.java index 6066fce..8a40309 100644 --- a/src/main/java/frc4388/robot/subsystems/intake/IntakeIO.java +++ b/src/main/java/frc4388/robot/subsystems/intake/IntakeIO.java @@ -17,8 +17,9 @@ public interface IntakeIO { public class IntakeState { double currentBounceTime = 0; - boolean extendedLimit = false; - boolean retractedLimit = false; + boolean retractedLimitSwitch = false; + boolean extendedSoftLimit = false; + boolean retractedSoftLimit = false; Angle intakeEncoder = Rotations.of(0); Angle armAngle = Rotations.of(0); diff --git a/src/main/java/frc4388/robot/subsystems/intake/IntakeReal.java b/src/main/java/frc4388/robot/subsystems/intake/IntakeReal.java index 59fc5ba..288b25a 100644 --- a/src/main/java/frc4388/robot/subsystems/intake/IntakeReal.java +++ b/src/main/java/frc4388/robot/subsystems/intake/IntakeReal.java @@ -10,6 +10,8 @@ import com.ctre.phoenix6.controls.DutyCycleOut; import com.ctre.phoenix6.controls.PositionDutyCycle; import com.ctre.phoenix6.controls.PositionVoltage; import com.ctre.phoenix6.hardware.TalonFX; +import com.revrobotics.PersistMode; +import com.revrobotics.ResetMode; import com.revrobotics.spark.SparkMax; import edu.wpi.first.math.trajectory.TrapezoidProfile; @@ -37,7 +39,9 @@ public class IntakeReal implements IntakeIO { m_armMotor = armMotor; m_rollerMotor = rollerMotor; m_encoder = jankCoder; - // m_armLimitSwitch = armLimitSwitch; + + m_armMotor.configure(IntakeConstants.ARM_MOTOR_CONFIG, ResetMode.kNoResetSafeParameters, PersistMode.kPersistParameters); + m_rollerMotor.configure(IntakeConstants.ROLELR_MOTOR_CONFIG, ResetMode.kNoResetSafeParameters, PersistMode.kPersistParameters); } @@ -77,18 +81,20 @@ public class IntakeReal implements IntakeIO { } private boolean retractedLimit() { - return m_encoder.get() >= IntakeConstants.ARM_LIMIT_EXTENDED.get(); + return m_encoder.get() <= IntakeConstants.ARM_LIMIT_RETRACTED.get(); } private boolean extendedLimit() { - return m_encoder.get() <= IntakeConstants.ARM_LIMIT_RETRACTED.get(); + return m_encoder.get() >= IntakeConstants.ARM_LIMIT_EXTENDED.get(); } @Override public void armOutput(double percentOutput){ - if(retractedLimit()) { - percentOutput = Math.max(percentOutput, 0); - } else if (extendedLimit()) { + // if(retractedLimit()) { + // percentOutput = Math.max(percentOutput, 0); + // } + + if (extendedLimit()) { percentOutput = Math.min(percentOutput, 0); } @@ -98,6 +104,9 @@ public class IntakeReal implements IntakeIO { @Override public void updateInputs(IntakeState state) { + m_encoder.update(); + + state.armAngle = Rotations.of(m_armMotor.getEncoder().getPosition()).div(IntakeConstants.ARM_MOTOR_GEAR_RATIO); state.armMotorVelocity = RotationsPerSecond.of(m_armMotor.getEncoder().getVelocity()).div(IntakeConstants.ARM_MOTOR_GEAR_RATIO); // state.armMotorAcceleration = RotationsPerSecondPerSecond.of(m_armMotor.getEncoder().ge); @@ -106,17 +115,15 @@ public class IntakeReal implements IntakeIO { state.rollerOutput = m_rollerMotor.get(); state.rollerMotorCurrent = Amps.of(m_rollerMotor.getOutputCurrent()); - state.retractedLimit = retractedLimit(); - state.extendedLimit = extendedLimit(); - state.armAngle = m_encoder.getRotations(); + state.retractedSoftLimit = retractedLimit(); + state.extendedSoftLimit = extendedLimit(); - + state.intakeEncoder = m_encoder.getRotations(); + state.retractedLimitSwitch = m_armMotor.getReverseLimitSwitch().isPressed(); - - // if(state.retractedLimit) { - // // Set the arm motor to be zero if the limit switch is pressed - // m_armMotor.setPosition(0., 0); - // } + if(state.retractedLimitSwitch) { + m_encoder.resetRotations(); + } } @Override diff --git a/src/main/java/frc4388/utility/compute/JankCoder.java b/src/main/java/frc4388/utility/compute/JankCoder.java index 801e69d..e04e3a8 100644 --- a/src/main/java/frc4388/utility/compute/JankCoder.java +++ b/src/main/java/frc4388/utility/compute/JankCoder.java @@ -75,7 +75,6 @@ public class JankCoder { } catch (Exception e) { // e.printStackTrace(); System.out.println("ENCODER: Unable to write to trim file `" + m_encoder.getSourceChannel() + "`!?!"); - rotations = 0; } }