mirror of
https://github.com/Team4388/2026KPopRobotHunters.git
synced 2026-06-09 08:48:05 -06:00
new limit switch
This commit is contained in:
@@ -124,7 +124,7 @@ public class Intake extends SubsystemBase {
|
||||
|
||||
case ExtendingRolling:
|
||||
io.armOutput(IntakeConstants.ARM_EXTEND_PERCENT_OUTPUT.get());
|
||||
io.setRollerOutput(state, IntakeConstants. ROLLER_PERCENT_OUTPUT.get()); //getTargetRollerSpeed(ChassisOverallSpeed));
|
||||
io.setRollerOutput(state, IntakeConstants.ROLLER_PERCENT_OUTPUT.get()); //getTargetRollerSpeed(ChassisOverallSpeed));
|
||||
break;
|
||||
|
||||
case Retracting:
|
||||
|
||||
@@ -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 ConfigurableDouble INTAKE_BOUNCE_HALF_PERIOD = new ConfigurableDouble("Bounce Half Period", 5.);
|
||||
public static final ConfigurableDouble INTAKE_BOUNCE_OUTPUT = new ConfigurableDouble("Bounce Output", 0.1);
|
||||
@@ -60,6 +60,7 @@ public class IntakeConstants {
|
||||
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);
|
||||
|
||||
|
||||
public static final ConfigurableDouble ARM_REVERSE_ROLLER_RANGE = new ConfigurableDouble("Arm reverse roller range", 1.17);
|
||||
|
||||
public static final ConfigurableDouble ROLLER_PERCENT_OUTPUT = new ConfigurableDouble("Roller Percent Output", .50);
|
||||
|
||||
@@ -12,17 +12,20 @@ import com.revrobotics.spark.SparkLimitSwitch;
|
||||
import com.revrobotics.spark.SparkMax;
|
||||
|
||||
import edu.wpi.first.units.measure.Angle;
|
||||
import edu.wpi.first.wpilibj.DigitalInput;
|
||||
import frc4388.utility.compute.JankCoder;
|
||||
|
||||
public class IntakeReal implements IntakeIO {
|
||||
|
||||
SparkMax m_armMotor;
|
||||
RelativeEncoder arm_encoder;
|
||||
SparkLimitSwitch reverse_limit;
|
||||
// SparkLimitSwitch reverse_limit;
|
||||
TalonFX m_rollerMotor;
|
||||
JankCoder m_encoder;
|
||||
DigitalInput m_armLimitSwitch;
|
||||
|
||||
public IntakeReal(
|
||||
DigitalInput armLimitSwitch,
|
||||
SparkMax armMotor,
|
||||
TalonFX rollerMotor,
|
||||
JankCoder jankCoder
|
||||
@@ -31,7 +34,7 @@ public class IntakeReal implements IntakeIO {
|
||||
// m_pitchMotor = pitchMotor;
|
||||
m_armMotor = armMotor;
|
||||
arm_encoder = m_armMotor.getEncoder();
|
||||
reverse_limit = m_armMotor.getReverseLimitSwitch();
|
||||
m_armLimitSwitch = armLimitSwitch;
|
||||
m_rollerMotor = rollerMotor;
|
||||
m_encoder = jankCoder;
|
||||
|
||||
@@ -75,9 +78,9 @@ 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_encoder.get() <= IntakeConstants.ARM_LIMIT_RETRACTED.get();
|
||||
// }
|
||||
private boolean extendedLimit() {
|
||||
return m_encoder.get() >= IntakeConstants.ARM_LIMIT_EXTENDED.get();
|
||||
}
|
||||
@@ -94,6 +97,7 @@ public class IntakeReal implements IntakeIO {
|
||||
}
|
||||
|
||||
m_armMotor.set(percentOutput);
|
||||
// System.out.println(percentOutput);
|
||||
|
||||
}
|
||||
|
||||
@@ -110,13 +114,13 @@ public class IntakeReal implements IntakeIO {
|
||||
state.rollerOutput = m_rollerMotor.get();
|
||||
state.rollerMotorCurrent = m_rollerMotor.getStatorCurrent().getValue();
|
||||
|
||||
state.retractedSoftLimit = retractedLimit();
|
||||
// state.retractedSoftLimit = retractedLimit();
|
||||
state.extendedSoftLimit = extendedLimit();
|
||||
|
||||
state.intakeEncoder = m_encoder.getRotations();
|
||||
state.encoderConnected = m_encoder.isConnected();
|
||||
|
||||
state.retractedLimitSwitch = reverse_limit.isPressed();
|
||||
state.retractedLimitSwitch = m_armLimitSwitch.get();
|
||||
|
||||
if(state.retractedLimitSwitch) {
|
||||
m_encoder.resetRotations();
|
||||
|
||||
Reference in New Issue
Block a user