Merge branch 'New-Intake' into DenverAutos

This commit is contained in:
mimigamin
2026-04-02 16:11:07 -06:00
10 changed files with 703 additions and 118 deletions
@@ -404,7 +404,7 @@ public class RobotContainer {
new Trigger(() -> getDeadbandedOperatorController().getPOV() == 0)
.onTrue(new InstantCommand(() -> {
m_robotIntake.setMode(IntakeMode.Bouncing);
m_robotIntake.setMode(IntakeMode.RectractTorque);
}))
.onFalse(new InstantCommand(() -> {
m_robotIntake.setMode(IntakeMode.Idle);
+2 -2
View File
@@ -101,7 +101,7 @@ public class RobotMap {
//Configure Intake 20,21
SparkMax arm = new SparkMax(IntakeConstants.ARM_ID.id, com.revrobotics.spark.SparkLowLevel.MotorType.kBrushless);
SparkMax roller = new SparkMax(IntakeConstants.ROLLER_ID.id, com.revrobotics.spark.SparkLowLevel.MotorType.kBrushless);
TalonFX roller = new TalonFX(IntakeConstants.ROLLER_ID.id, Constants.CANIVORE_CANBUS);
// DigitalInput armLimitSwitch = new DigitalInput(IntakeConstants.ARM_LIMIT_SWITCH_CHANNEL);
// DigitalInput basinLimitSwitch = new DigitalInput(ElevatorConstants.BASIN_LIMIT_SWITCH);
// DigitalInput endeffectorLimitSwitch = new DigitalInput(ElevatorConstants.ENDEFFECTOR_LIMIT_SWITCH);
@@ -120,7 +120,7 @@ public class RobotMap {
FaultTalonFX.addDevice(shooter2, "Shooter2");
FaultTalonFX.addDevice(indexer, "Indexer");
FaultSparkMax.addDevice(arm, "Arm");
FaultSparkMax.addDevice(roller, "Roller");
FaultTalonFX.addDevice(roller, "Roller");
FaultTalonFX.addDevice(swerveDrivetrainReal.getModule(0).getDriveMotor(), "Module 0 Drive");
FaultTalonFX.addDevice(swerveDrivetrainReal.getModule(0).getSteerMotor(), "Module 0 Steer");
@@ -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 = 191;
public static final String GIT_SHA = "9021f480beaf35912eb54a845ec87522fef5337a";
public static final String GIT_DATE = "2026-03-30 18:57:14 MDT";
public static final int GIT_REVISION = 198;
public static final String GIT_SHA = "958bdc46fd90b8388750f8bf1a95b62ff91b2092";
public static final String GIT_DATE = "2026-03-31 20:51:47 MDT";
public static final String GIT_BRANCH = "New-Intake";
public static final String BUILD_DATE = "2026-03-30 19:50:05 MDT";
public static final long BUILD_UNIX_TIME = 1774921805228L;
public static final String BUILD_DATE = "2026-04-01 17:29:06 MDT";
public static final long BUILD_UNIX_TIME = 1775086146983L;
public static final int DIRTY = 1;
private BuildConstants(){}
@@ -37,8 +37,10 @@ public class Intake extends SubsystemBase {
Retracting,
Idle,
RectractTorque,
Bouncing
}
private boolean overCompressed = false;
private IntakeMode mode = IntakeMode.Idle;
@@ -85,6 +87,7 @@ public class Intake extends SubsystemBase {
// return FieldZone.InShootZone;
// }
@Override
public void periodic() {
// FaultReporter.register(this); // TODO Implement fault reporter
@@ -94,8 +97,17 @@ public class Intake extends SubsystemBase {
Logger.processInputs("Intake", state);
Logger.recordOutput("Intake/IntakeState", this.mode);
io.updateInputs(state);
if (state.armMotorCurrent.in(Amps) < IntakeConstants.INTAKE_SQUEEZE_CURRENT_LOWER_THRESHOLD.get()){
overCompressed = false;
} else if (state.armMotorCurrent.in(Amps) > IntakeConstants.INTAKE_SQUEEZE_CURRENT_UPPER_THRESHOLD.get()) {
overCompressed = true;
}
Logger.recordOutput("overCompressed", overCompressed);
// getCurrentTime
switch (mode) {
@@ -154,6 +166,19 @@ public class Intake extends SubsystemBase {
io.setRollerOutput(state, 0);
}
break;
case RectractTorque:
io.setRollerOutput(state, IntakeConstants.ROLLER_RETRACT_PERCENT_OUTPUT.get());
if (!overCompressed){
io.armOutput(IntakeConstants.ARM_SQUEEZE_PERCENT_OUTPUT.get());
} else if (overCompressed) {
io.armOutput(IntakeConstants.ARM_REDUCED_SQUEEZE_PERCENT_OUTPUT.get());
}
if(state.intakeEncoder.in(Rotations) > IntakeConstants.ARM_REVERSE_ROLLER_RANGE.get()) {
io.setRollerOutput(state, IntakeConstants.ROLLER_RETRACT_PERCENT_OUTPUT.get());
} else {
io.setRollerOutput(state, 0);
}
break;
case Idle:
io.armOutput(0);
io.setRollerOutput(state, 0);
@@ -1,5 +1,9 @@
package frc4388.robot.subsystems.intake;
import com.ctre.phoenix6.configs.CurrentLimitsConfigs;
import com.ctre.phoenix6.configs.MotorOutputConfigs;
import com.ctre.phoenix6.configs.TalonFXConfiguration;
import com.ctre.phoenix6.signals.NeutralModeValue;
import com.revrobotics.spark.FeedbackSensor;
import com.revrobotics.spark.config.SparkMaxConfig;
import com.revrobotics.spark.config.LimitSwitchConfig.Behavior;
@@ -25,6 +29,12 @@ public class IntakeConstants {
public static final ConfigurableDouble INTAKE_BOUNCE_VELOCITY_LIMIT = new ConfigurableDouble("Intake Bounce Velocity Limit", 4);
//squeeze constants
public static final ConfigurableDouble INTAKE_SQUEEZE_CURRENT_LOWER_THRESHOLD = new ConfigurableDouble("Intake Squeeze Current LOWER THRESHOLD", 20);
public static final ConfigurableDouble INTAKE_SQUEEZE_CURRENT_UPPER_THRESHOLD = new ConfigurableDouble("Intake Squeeze Current UPPER THRESHOLD", 25);
public static final ConfigurableDouble ARM_SQUEEZE_PERCENT_OUTPUT = new ConfigurableDouble("Arm squeeze % output", -0.1);
public static final ConfigurableDouble ARM_REDUCED_SQUEEZE_PERCENT_OUTPUT = new ConfigurableDouble("Arm reduce squeeze % output", -0.02);
//IDs
@@ -43,7 +53,7 @@ public class IntakeConstants {
// public static final Angle ARM_LIMIT_UPPER = Degrees.of(-90);
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.5);
public static final ConfigurableDouble ARM_LIMIT_EXTENDED = new ConfigurableDouble("Arm angle extended", 1.75);
public static final ConfigurableDouble ARM_EXTEND_PERCENT_OUTPUT = new ConfigurableDouble("Arm extend % output", 0.2);
public static final ConfigurableDouble ARM_RETRACT_PERCENT_OUTPUT = new ConfigurableDouble("Arm retract % output", -0.2);
@@ -79,7 +89,7 @@ public class IntakeConstants {
// Motor configs
public static final SparkMaxConfig ARM_MOTOR_CONFIG = new SparkMaxConfig();
public static final SparkMaxConfig ROLELR_MOTOR_CONFIG = new SparkMaxConfig();
public static final CanDevice ROLLER_MOTOR_ID = new CanDevice("INTAKE_ROLLER", 21);
static {
ARM_MOTOR_CONFIG.limitSwitch
@@ -95,7 +105,7 @@ public class IntakeConstants {
ARM_MOTOR_CONFIG.idleMode(IdleMode.kBrake);
ROLELR_MOTOR_CONFIG.idleMode(IdleMode.kCoast);
// ROLLER_MOTOR_CONFIG.idleMode(IdleMode.kCoast);
}
// public static final TalonFXConfiguration ARM_MOTOR_CONFIG = new TalonFXConfiguration()
@@ -109,14 +119,14 @@ public class IntakeConstants {
// .withDutyCycleNeutralDeadband(0.04) // TODO: Figure out what this means
// );
// public static final TalonFXConfiguration ROLLER_MOTOR_CONFIG = new TalonFXConfiguration()
// .withCurrentLimits(
// new CurrentLimitsConfigs()
// .withStatorCurrentLimit(40) // TODO: tune???
// .withStatorCurrentLimitEnable(true)
// ).withMotorOutput(
// new MotorOutputConfigs()
// .withNeutralMode(NeutralModeValue.Coast) // Must be coast because this is spinny spinny
// .withDutyCycleNeutralDeadband(0.04) // TODO: Figure out what this means
// );
public static final TalonFXConfiguration ROLLER_MOTOR_CONFIG = new TalonFXConfiguration()
.withCurrentLimits(
new CurrentLimitsConfigs()
.withStatorCurrentLimit(40) // TODO: tune???
.withStatorCurrentLimitEnable(true)
).withMotorOutput(
new MotorOutputConfigs()
.withNeutralMode(NeutralModeValue.Coast) // Must be coast because this is spinny spinny
.withDutyCycleNeutralDeadband(0.04) // TODO: Figure out what this means
);
}
@@ -21,17 +21,18 @@ import edu.wpi.first.units.measure.Angle;
import edu.wpi.first.units.measure.Velocity;
import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.DutyCycleEncoder;
import frc4388.robot.subsystems.shooter.ShooterConstants;
import frc4388.utility.compute.JankCoder;
public class IntakeReal implements IntakeIO {
SparkMax m_armMotor;
SparkMax m_rollerMotor;
TalonFX m_rollerMotor;
JankCoder m_encoder;
public IntakeReal(
SparkMax armMotor,
SparkMax rollerMotor,
TalonFX rollerMotor,
JankCoder jankCoder
) {
// m_angleMotor = angleMotor;
@@ -41,7 +42,7 @@ public class IntakeReal implements IntakeIO {
m_encoder = jankCoder;
m_armMotor.configure(IntakeConstants.ARM_MOTOR_CONFIG, ResetMode.kNoResetSafeParameters, PersistMode.kPersistParameters);
m_rollerMotor.configure(IntakeConstants.ROLELR_MOTOR_CONFIG, ResetMode.kNoResetSafeParameters, PersistMode.kPersistParameters);
m_rollerMotor.getConfigurator().apply(IntakeConstants.ROLLER_MOTOR_CONFIG);
}
@@ -113,7 +114,7 @@ public class IntakeReal implements IntakeIO {
state.armMotorCurrent = Amps.of(m_armMotor.getOutputCurrent());
state.rollerOutput = m_rollerMotor.get();
state.rollerMotorCurrent = Amps.of(m_rollerMotor.getOutputCurrent());
// state.rollerMotorCurrent = Amps.of(m_rollerMotor.getOutputCurrent());
state.retractedSoftLimit = retractedLimit();
state.extendedSoftLimit = extendedLimit();
@@ -67,16 +67,16 @@ public final class SwerveDriveConstants {
// Operation
public static final double FORWARD_OFFSET = 90; // 0, 90, 180, 270
public static ConfigurableDouble FAR_OFFSET = new ConfigurableDouble("Far Offset", 0.05); // degrees to add to the angle when we are far away, to account for camera misalignment. TODO: find value.
public static final boolean DRIFT_CORRECTION_ENABLED = true;
public static final boolean INVERT_X = false;
public static final boolean INVERT_Y = true;
public static final boolean INVERT_ROTATION = false;
public static ConfigurableDouble FAR_OFFSET = new ConfigurableDouble("Far Offset", 0.05);
// public static final Trim POINTLESS_TRIM = new Trim("Pointless Trim", Double.MAX_VALUE, Double.MIN_VALUE, 0.1, 0);
public static final class ModuleSpecificConstants { //2026
private static final class ModuleSpecificConstants { //2025
//Front Left
private static final Angle FRONT_LEFT_ENCODER_OFFSET = Rotations.of(0.49707+0.350-0.03+0.0134+0.06-0.043);
private static final boolean FRONT_LEFT_DRIVE_MOTOR_INVERTED = false;
@@ -166,6 +166,7 @@ public final class SwerveDriveConstants {
public static final ConfigurableDouble AIM_kP = new ConfigurableDouble("Aim kP", 12);
public static final ConfigurableDouble AIM_kI = new ConfigurableDouble("Aim kI", 0);
public static final ConfigurableDouble AIM_kD = new ConfigurableDouble("Aim kD", 0.1);
public static final ConfigurableDouble HOLD_POSITION_kP = new ConfigurableDouble("Hold Position kP", 15);
// public static final Gains AIM_GAINS = new Gains(2.5, 0, 0.1);
}