mirror of
https://github.com/Team4388/2026KPopRobotHunters.git
synced 2026-06-09 08:48:05 -06:00
swuidf
This commit is contained in:
@@ -35,6 +35,7 @@ public class Intake extends SubsystemBase {
|
||||
ExtendingRolling,
|
||||
|
||||
Retracting,
|
||||
ArmIdleRollingNot,
|
||||
|
||||
Idle,
|
||||
RectractTorque,
|
||||
@@ -79,7 +80,6 @@ public class Intake extends SubsystemBase {
|
||||
public double getRollerSpeed() {
|
||||
return state.rollerOutput;
|
||||
}
|
||||
|
||||
// public enum FieldZone {
|
||||
// // The robot should aim at the hub
|
||||
// InShootZone,
|
||||
@@ -136,7 +136,10 @@ public class Intake extends SubsystemBase {
|
||||
// io.setRollerOutput(state, 0);
|
||||
// }
|
||||
break;
|
||||
|
||||
case ArmIdleRollingNot:
|
||||
io.armOutput(0);
|
||||
io.setRollerOutput(state, IntakeConstants.ROLLER_RETRACT_PERCENT_OUTPUT.get());
|
||||
break;
|
||||
case Bouncing:
|
||||
// io.setRollerOutput(state, 0);
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ public class IntakeConstants {
|
||||
public static final double ROLLER_MOTOR_GEAR_RATIO = 3;
|
||||
public static final ConfigurableDouble ARM_ENCODER_OFFSET = new ConfigurableDouble("Arm Encoder Offset", 0);
|
||||
|
||||
public static final int ARM_LIMIT_SWITCH_CHANNEL = 9;
|
||||
public static final int ARM_LIMIT_SWITCH_CHANNEL = 7;
|
||||
|
||||
public static final ConfigurableDouble INTAKE_BOUNCE_HALF_PERIOD = new ConfigurableDouble("Bounce Half Period", 5.);
|
||||
public static final ConfigurableDouble INTAKE_BOUNCE_OUTPUT = new ConfigurableDouble("Bounce Output", 0.1);
|
||||
@@ -56,7 +56,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.75);
|
||||
public static final ConfigurableDouble ARM_LIMIT_EXTENDED = new ConfigurableDouble("Arm angle extended", 1.8); //new soft limt
|
||||
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.2);
|
||||
|
||||
@@ -108,9 +108,9 @@ public class IntakeConstants {
|
||||
.forwardLimitSwitchType(Type.kNormallyOpen)
|
||||
.forwardLimitSwitchTriggerBehavior(Behavior.kKeepMovingMotor)
|
||||
|
||||
.reverseLimitSwitchType(Type.kNormallyClosed)
|
||||
.reverseLimitSwitchPosition(0)
|
||||
.reverseLimitSwitchTriggerBehavior(Behavior.kStopMovingMotorAndSetPosition);
|
||||
.reverseLimitSwitchType(Type.kNormallyOpen)
|
||||
// .reverseLimitSwitchPosition(0)
|
||||
.reverseLimitSwitchTriggerBehavior(Behavior.kKeepMovingMotor);
|
||||
|
||||
ARM_MOTOR_CONFIG.idleMode(IdleMode.kBrake);
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ import static edu.wpi.first.units.Units.Amps;
|
||||
import static edu.wpi.first.units.Units.Rotations;
|
||||
import static edu.wpi.first.units.Units.RotationsPerSecond;
|
||||
|
||||
import org.littletonrobotics.junction.Logger;
|
||||
|
||||
import com.ctre.phoenix6.hardware.TalonFX;
|
||||
import com.revrobotics.PersistMode;
|
||||
import com.revrobotics.ResetMode;
|
||||
@@ -13,6 +15,8 @@ import com.revrobotics.spark.SparkMax;
|
||||
|
||||
import edu.wpi.first.units.measure.Angle;
|
||||
import edu.wpi.first.wpilibj.DigitalInput;
|
||||
import edu.wpi.first.wpilibj.Timer;
|
||||
import frc4388.robot.constants.Constants;
|
||||
import frc4388.utility.compute.JankCoder;
|
||||
|
||||
public class IntakeReal implements IntakeIO {
|
||||
@@ -23,6 +27,9 @@ public class IntakeReal implements IntakeIO {
|
||||
TalonFX m_rollerMotor;
|
||||
JankCoder m_encoder;
|
||||
DigitalInput m_armLimitSwitch;
|
||||
boolean m_limitTRIGGER = false;
|
||||
private final Timer m_limitTimer = new Timer();
|
||||
|
||||
|
||||
public IntakeReal(
|
||||
DigitalInput armLimitSwitch,
|
||||
@@ -78,9 +85,12 @@ public class IntakeReal implements IntakeIO {
|
||||
// m_rollerMotor.set(0);
|
||||
}
|
||||
|
||||
// private boolean retractedLimit() {
|
||||
// return m_encoder.get() <= IntakeConstants.ARM_LIMIT_RETRACTED.get();
|
||||
// }
|
||||
private boolean retractedLimit() {
|
||||
return m_armLimitSwitch.get();
|
||||
}
|
||||
private boolean retractedSoftLimit() {
|
||||
return m_encoder.get() <= IntakeConstants.ARM_LIMIT_RETRACTED.get();
|
||||
}
|
||||
private boolean extendedLimit() {
|
||||
return m_encoder.get() >= IntakeConstants.ARM_LIMIT_EXTENDED.get();
|
||||
}
|
||||
@@ -88,9 +98,9 @@ public class IntakeReal implements IntakeIO {
|
||||
@Override
|
||||
public void armOutput(double percentOutput){
|
||||
|
||||
// if(retractedLimit()) {
|
||||
// percentOutput = Math.max(percentOutput, 0);
|
||||
// }
|
||||
if(retractedSoftLimit()) {
|
||||
percentOutput = Math.max(percentOutput, 0);
|
||||
}
|
||||
|
||||
if (extendedLimit()) {
|
||||
percentOutput = Math.min(percentOutput, 0);
|
||||
@@ -120,16 +130,30 @@ public class IntakeReal implements IntakeIO {
|
||||
state.intakeEncoder = m_encoder.getRotations();
|
||||
state.encoderConnected = m_encoder.isConnected();
|
||||
|
||||
state.retractedLimitSwitch = m_armLimitSwitch.get();
|
||||
state.retractedLimitSwitch = retractedLimit();
|
||||
|
||||
if(state.retractedLimitSwitch) {
|
||||
m_encoder.resetRotations();
|
||||
}
|
||||
// if(state.retractedLimitSwitch && (state.armMotorVelocity.in(RotationsPerSecond) <0)) {
|
||||
// if (!m_limitTRIGGER) {
|
||||
// m_limitTRIGGER = true;
|
||||
// m_limitTimer.restart();
|
||||
// }
|
||||
// if (m_limitTimer.hasElapsed(1.0)) {
|
||||
// m_encoder.resetRotations();
|
||||
// }
|
||||
// } else {
|
||||
// m_limitTRIGGER = false;
|
||||
// m_limitTimer.reset();
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateGains() {
|
||||
m_encoder.loadRotations();
|
||||
// m_encoder.loadRotations();
|
||||
|
||||
|
||||
if(retractedLimit()) {
|
||||
m_encoder.resetRotations();
|
||||
}
|
||||
|
||||
// IntakeConstants.ARM_PID.kP = IntakeConstants.arm_kP.get();
|
||||
// IntakeConstants.ARM_PID.kI = IntakeConstants.arm_kI.get();
|
||||
|
||||
Reference in New Issue
Block a user