working new intake

This commit is contained in:
Shatcar
2026-03-28 15:56:54 -06:00
parent d010829c21
commit 65c76aca95
7 changed files with 50 additions and 35 deletions
@@ -164,7 +164,7 @@ public class RobotContainer {
public RobotContainer() { public RobotContainer() {
configureSINGLEBindings(); configureButtonBindings();
// Called on first robot enable // Called on first robot enable
DeferredBlock.addBlock(() -> { DeferredBlock.addBlock(() -> {
@@ -7,12 +7,12 @@ public final class BuildConstants {
public static final String MAVEN_GROUP = ""; public static final String MAVEN_GROUP = "";
public static final String MAVEN_NAME = "2026KPopRobotHunters"; public static final String MAVEN_NAME = "2026KPopRobotHunters";
public static final String VERSION = "unspecified"; public static final String VERSION = "unspecified";
public static final int GIT_REVISION = 185; public static final int GIT_REVISION = 188;
public static final String GIT_SHA = "7eba3d8faa208df9222599c53db1e11da82d7a96"; public static final String GIT_SHA = "d010829c21aa6f5bd1787cfcab1c02107fb353ff";
public static final String GIT_DATE = "2026-03-25 11:39:55 MDT"; 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 GIT_BRANCH = "New-Intake";
public static final String BUILD_DATE = "2026-03-28 09:26:32 MDT"; public static final String BUILD_DATE = "2026-03-28 15:50:49 MDT";
public static final long BUILD_UNIX_TIME = 1774711592752L; public static final long BUILD_UNIX_TIME = 1774734649429L;
public static final int DIRTY = 1; public static final int DIRTY = 1;
private BuildConstants(){} private BuildConstants(){}
@@ -109,7 +109,7 @@ public class Intake extends SubsystemBase {
break; break;
case Retracting: case Retracting:
io.armOutput(IntakeConstants.ARM_RETRACT_PERCENT_OUTPUT.get()); io.armOutput(IntakeConstants.ARM_RETRACT_PERCENT_OUTPUT.get());
io.setRollerOutput(state, 0); io.setRollerOutput(state, IntakeConstants.ROLLER_RETRACT_PERCENT_OUTPUT.get());
break; break;
case Bouncing: case Bouncing:
io.setRollerOutput(state, 0); io.setRollerOutput(state, 0);
@@ -131,8 +131,9 @@ public class Intake extends SubsystemBase {
io.armOutput(percentOutput); io.armOutput(percentOutput);
break; break;
case Idle: case Idle:
io.armOutput(0);
// io.setArmAngle(state, Rotations.of(IntakeConstants.ARM_LIMIT_RETRACTED.get())); // io.setArmAngle(state, Rotations.of(IntakeConstants.ARM_LIMIT_RETRACTED.get()));
io.setRollerOutput(state, 0); // io.setRollerOutput(state, 0);
break; break;
} }
// if (state.retractedLimit){ // if (state.retractedLimit){
@@ -13,7 +13,7 @@ public class IntakeConstants {
public static final double ARM_MOTOR_GEAR_RATIO = 125; public static final double ARM_MOTOR_GEAR_RATIO = 125;
public static final double ROLLER_MOTOR_GEAR_RATIO = 3; 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_LOWER = Degrees.of(90);
// public static final Angle ARM_LIMIT_UPPER = 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_RETRACTED = new ConfigurableDouble("Arm angle retracted", 0.);
public static final ConfigurableDouble ARM_LIMIT_EXTENDED = new ConfigurableDouble("Arm angle extended", 0.33); 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.4); 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.4); 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", .70);
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 ConfigurableDouble ROLL = new ConfigurableDouble("Arm angle extended", 0.25);
// public static final AngularVelocity ROLLER_MAX_VELOCITY = RotationsPerSecond.of(4.0); // public static final AngularVelocity ROLLER_MAX_VELOCITY = RotationsPerSecond.of(4.0);
@@ -77,10 +80,14 @@ public class IntakeConstants {
static { static {
ARM_MOTOR_CONFIG.limitSwitch ARM_MOTOR_CONFIG.limitSwitch
.reverseLimitSwitchType(Type.kNormallyClosed)
.limitSwitchPositionSensor(FeedbackSensor.kPrimaryEncoder) .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() // public static final TalonFXConfiguration ARM_MOTOR_CONFIG = new TalonFXConfiguration()
@@ -17,8 +17,9 @@ public interface IntakeIO {
public class IntakeState { public class IntakeState {
double currentBounceTime = 0; double currentBounceTime = 0;
boolean extendedLimit = false; boolean retractedLimitSwitch = false;
boolean retractedLimit = false; boolean extendedSoftLimit = false;
boolean retractedSoftLimit = false;
Angle intakeEncoder = Rotations.of(0); Angle intakeEncoder = Rotations.of(0);
Angle armAngle = Rotations.of(0); Angle armAngle = Rotations.of(0);
@@ -10,6 +10,8 @@ import com.ctre.phoenix6.controls.DutyCycleOut;
import com.ctre.phoenix6.controls.PositionDutyCycle; import com.ctre.phoenix6.controls.PositionDutyCycle;
import com.ctre.phoenix6.controls.PositionVoltage; import com.ctre.phoenix6.controls.PositionVoltage;
import com.ctre.phoenix6.hardware.TalonFX; import com.ctre.phoenix6.hardware.TalonFX;
import com.revrobotics.PersistMode;
import com.revrobotics.ResetMode;
import com.revrobotics.spark.SparkMax; import com.revrobotics.spark.SparkMax;
import edu.wpi.first.math.trajectory.TrapezoidProfile; import edu.wpi.first.math.trajectory.TrapezoidProfile;
@@ -37,7 +39,9 @@ public class IntakeReal implements IntakeIO {
m_armMotor = armMotor; m_armMotor = armMotor;
m_rollerMotor = rollerMotor; m_rollerMotor = rollerMotor;
m_encoder = jankCoder; 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() { private boolean retractedLimit() {
return m_encoder.get() >= IntakeConstants.ARM_LIMIT_EXTENDED.get(); return m_encoder.get() <= IntakeConstants.ARM_LIMIT_RETRACTED.get();
} }
private boolean extendedLimit() { private boolean extendedLimit() {
return m_encoder.get() <= IntakeConstants.ARM_LIMIT_RETRACTED.get(); return m_encoder.get() >= IntakeConstants.ARM_LIMIT_EXTENDED.get();
} }
@Override @Override
public void armOutput(double percentOutput){ public void armOutput(double percentOutput){
if(retractedLimit()) { // if(retractedLimit()) {
percentOutput = Math.max(percentOutput, 0); // percentOutput = Math.max(percentOutput, 0);
} else if (extendedLimit()) { // }
if (extendedLimit()) {
percentOutput = Math.min(percentOutput, 0); percentOutput = Math.min(percentOutput, 0);
} }
@@ -98,6 +104,9 @@ public class IntakeReal implements IntakeIO {
@Override @Override
public void updateInputs(IntakeState state) { public void updateInputs(IntakeState state) {
m_encoder.update();
state.armAngle = Rotations.of(m_armMotor.getEncoder().getPosition()).div(IntakeConstants.ARM_MOTOR_GEAR_RATIO); 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.armMotorVelocity = RotationsPerSecond.of(m_armMotor.getEncoder().getVelocity()).div(IntakeConstants.ARM_MOTOR_GEAR_RATIO);
// state.armMotorAcceleration = RotationsPerSecondPerSecond.of(m_armMotor.getEncoder().ge); // state.armMotorAcceleration = RotationsPerSecondPerSecond.of(m_armMotor.getEncoder().ge);
@@ -106,17 +115,15 @@ public class IntakeReal implements IntakeIO {
state.rollerOutput = m_rollerMotor.get(); state.rollerOutput = m_rollerMotor.get();
state.rollerMotorCurrent = Amps.of(m_rollerMotor.getOutputCurrent()); state.rollerMotorCurrent = Amps.of(m_rollerMotor.getOutputCurrent());
state.retractedLimit = retractedLimit(); state.retractedSoftLimit = retractedLimit();
state.extendedLimit = extendedLimit(); state.extendedSoftLimit = extendedLimit();
state.armAngle = m_encoder.getRotations();
state.intakeEncoder = m_encoder.getRotations();
state.retractedLimitSwitch = m_armMotor.getReverseLimitSwitch().isPressed();
if(state.retractedLimitSwitch) {
// if(state.retractedLimit) { m_encoder.resetRotations();
// // Set the arm motor to be zero if the limit switch is pressed }
// m_armMotor.setPosition(0., 0);
// }
} }
@Override @Override
@@ -75,7 +75,6 @@ public class JankCoder {
} catch (Exception e) { } catch (Exception e) {
// e.printStackTrace(); // e.printStackTrace();
System.out.println("ENCODER: Unable to write to trim file `" + m_encoder.getSourceChannel() + "`!?!"); System.out.println("ENCODER: Unable to write to trim file `" + m_encoder.getSourceChannel() + "`!?!");
rotations = 0;
} }
} }