|
1 | 1 | package frc.robot.constants; |
2 | 2 |
|
3 | | -public class CoralConstants {} |
| 3 | +import static edu.wpi.first.units.Units.RotationsPerSecond; |
| 4 | + |
| 5 | +import com.ctre.phoenix6.configs.CurrentLimitsConfigs; |
| 6 | +import com.ctre.phoenix6.configs.HardwareLimitSwitchConfigs; |
| 7 | +import com.ctre.phoenix6.configs.MotionMagicConfigs; |
| 8 | +import com.ctre.phoenix6.configs.MotorOutputConfigs; |
| 9 | +import com.ctre.phoenix6.configs.Slot0Configs; |
| 10 | +import com.ctre.phoenix6.configs.TalonFXSConfiguration; |
| 11 | +import com.ctre.phoenix6.signals.ForwardLimitSourceValue; |
| 12 | +import com.ctre.phoenix6.signals.ForwardLimitTypeValue; |
| 13 | +import com.ctre.phoenix6.signals.GravityTypeValue; |
| 14 | +import com.ctre.phoenix6.signals.NeutralModeValue; |
| 15 | +import com.ctre.phoenix6.signals.ReverseLimitSourceValue; |
| 16 | +import com.ctre.phoenix6.signals.ReverseLimitTypeValue; |
| 17 | +import edu.wpi.first.units.measure.AngularVelocity; |
| 18 | + |
| 19 | +public class CoralConstants { |
| 20 | + public static int kCoralFxId = 0; |
| 21 | + |
| 22 | + public static final AngularVelocity kCloseEnough = RotationsPerSecond.of(0.1); |
| 23 | + |
| 24 | + public static final AngularVelocity kIntakingSpeed = RotationsPerSecond.of(-1); |
| 25 | + public static final AngularVelocity kEjectingSpeed = RotationsPerSecond.of(1); |
| 26 | + |
| 27 | + // Coral Talon FX Config |
| 28 | + public static TalonFXSConfiguration getFXConfig() { |
| 29 | + TalonFXSConfiguration fxsConfig = new TalonFXSConfiguration(); |
| 30 | + |
| 31 | + CurrentLimitsConfigs current = |
| 32 | + new CurrentLimitsConfigs() |
| 33 | + .withStatorCurrentLimit(10) |
| 34 | + .withStatorCurrentLimitEnable(false) |
| 35 | + .withSupplyCurrentLimit(10) |
| 36 | + .withSupplyCurrentLowerLimit(8) |
| 37 | + .withSupplyCurrentLowerTime(0.02) |
| 38 | + .withSupplyCurrentLimitEnable(true); |
| 39 | + fxsConfig.CurrentLimits = current; |
| 40 | + |
| 41 | + HardwareLimitSwitchConfigs hwLimit = |
| 42 | + new HardwareLimitSwitchConfigs() |
| 43 | + .withForwardLimitAutosetPositionEnable(false) |
| 44 | + .withForwardLimitEnable(false) |
| 45 | + .withForwardLimitType(ForwardLimitTypeValue.NormallyOpen) |
| 46 | + .withForwardLimitSource(ForwardLimitSourceValue.LimitSwitchPin) |
| 47 | + .withReverseLimitAutosetPositionEnable(false) |
| 48 | + .withReverseLimitEnable(true) |
| 49 | + .withReverseLimitType(ReverseLimitTypeValue.NormallyOpen) |
| 50 | + .withReverseLimitSource(ReverseLimitSourceValue.LimitSwitchPin); |
| 51 | + fxsConfig.HardwareLimitSwitch = hwLimit; |
| 52 | + |
| 53 | + Slot0Configs slot0 = |
| 54 | + new Slot0Configs() |
| 55 | + .withKP(0) |
| 56 | + .withKI(0) |
| 57 | + .withKD(0) |
| 58 | + .withGravityType(GravityTypeValue.Elevator_Static) |
| 59 | + .withKG(0) |
| 60 | + .withKS(0) |
| 61 | + .withKV(0) |
| 62 | + .withKA(0); |
| 63 | + fxsConfig.Slot0 = slot0; |
| 64 | + |
| 65 | + MotionMagicConfigs motionMagic = |
| 66 | + new MotionMagicConfigs() |
| 67 | + .withMotionMagicAcceleration(0) |
| 68 | + .withMotionMagicCruiseVelocity(0) |
| 69 | + .withMotionMagicExpo_kA(0) |
| 70 | + .withMotionMagicExpo_kV(0) |
| 71 | + .withMotionMagicJerk(0); |
| 72 | + fxsConfig.MotionMagic = motionMagic; |
| 73 | + |
| 74 | + MotorOutputConfigs motorOut = |
| 75 | + new MotorOutputConfigs() |
| 76 | + .withDutyCycleNeutralDeadband(0.01) |
| 77 | + .withNeutralMode(NeutralModeValue.Coast); |
| 78 | + fxsConfig.MotorOutput = motorOut; |
| 79 | + |
| 80 | + return fxsConfig; |
| 81 | + } |
| 82 | +} |
0 commit comments