mirror of
https://github.com/Team4388/2026KPopRobotHunters.git
synced 2026-06-09 00:38:03 -06:00
Limit Switch
This commit is contained in:
@@ -7,19 +7,24 @@ import java.util.function.Supplier;
|
||||
import org.littletonrobotics.junction.Logger;
|
||||
|
||||
import edu.wpi.first.math.geometry.Pose2d;
|
||||
import edu.wpi.first.wpilibj.DigitalInput;
|
||||
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
||||
import frc4388.robot.subsystems.intake.Intake.IntakeMode;
|
||||
|
||||
public class Intake extends SubsystemBase {
|
||||
public IntakeIO io;
|
||||
IntakeStateAutoLogged state = new IntakeStateAutoLogged();
|
||||
|
||||
Supplier<Pose2d> m_swervePoseSupplier;
|
||||
public DigitalInput m_armLimitSwitch;
|
||||
|
||||
public Intake(
|
||||
IntakeIO io
|
||||
IntakeIO io,
|
||||
DigitalInput m_armLimitSwitch
|
||||
// Supplier<Pose2d> swervePoseSupplier
|
||||
) {
|
||||
this.io = io;
|
||||
this.m_armLimitSwitch= m_armLimitSwitch;
|
||||
// this.m_swervePoseSupplier = swervePoseSupplier;
|
||||
}
|
||||
|
||||
@@ -56,6 +61,7 @@ public class Intake extends SubsystemBase {
|
||||
@Override
|
||||
public void periodic() {
|
||||
// FaultReporter.register(this); // TODO Implement fault reporter
|
||||
// System.out.println(m_armLimitSwitch.get());
|
||||
|
||||
|
||||
Logger.processInputs("Intake", state);
|
||||
@@ -68,7 +74,12 @@ public class Intake extends SubsystemBase {
|
||||
io.setRollerVelocity(state, RotationsPerSecond.of(IntakeConstants.ROLLER_ACTIVE.get()));
|
||||
break;
|
||||
case Retracted:
|
||||
io.setArmAngle(state, Rotations.of(IntakeConstants.ARM_LIMIT_RETRACTED.get()));
|
||||
if (!m_armLimitSwitch.get()){
|
||||
System.out.println("Triggered!");
|
||||
io.stopArm();
|
||||
} else {
|
||||
io.setArmAngle(state, Rotations.of(IntakeConstants.ARM_LIMIT_RETRACTED.get()));
|
||||
}
|
||||
io.setRollerVelocity(state, RotationsPerSecond.of(0));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import frc4388.utility.status.CanDevice;
|
||||
public class IntakeConstants {
|
||||
// Motor conversions
|
||||
|
||||
public static final double ARM_MOTOR_GEAR_RATIO = 100;
|
||||
public static final double ARM_MOTOR_GEAR_RATIO = 125;
|
||||
public static final double ROLLER_MOTOR_GEAR_RATIO = 3;
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ public class IntakeConstants {
|
||||
public static final TalonFXConfiguration ARM_MOTOR_CONFIG = new TalonFXConfiguration()
|
||||
.withCurrentLimits(
|
||||
new CurrentLimitsConfigs()
|
||||
.withStatorCurrentLimit(40) // TODO: tune???
|
||||
.withStatorCurrentLimit(15) // TODO: tune???
|
||||
.withStatorCurrentLimitEnable(true)
|
||||
).withMotorOutput(
|
||||
new MotorOutputConfigs()
|
||||
|
||||
@@ -33,6 +33,7 @@ public interface IntakeIO {
|
||||
// public default void setShooterAngle(ShooterState state, Angle angle) {}
|
||||
// public default void setShooterPitch(ShooterState state, Angle angle) {}
|
||||
public default void setArmAngle(IntakeState state, Angle angle) {}
|
||||
public default void stopArm() {}
|
||||
public default void setRollerVelocity(IntakeState state, AngularVelocity angularVelocity) {}
|
||||
|
||||
public default void updateInputs(IntakeState state) {}
|
||||
|
||||
@@ -78,6 +78,10 @@ public class IntakeReal implements IntakeIO {
|
||||
// PositionDutyCycle posRequest = new PositionDutyCycle(motorTargetAngle);
|
||||
m_armMotor.setControl(armPosition.withPosition(motorAngle));
|
||||
}
|
||||
@Override
|
||||
public void stopArm(){
|
||||
m_armMotor.set(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateInputs(IntakeState state) {
|
||||
|
||||
Reference in New Issue
Block a user