|
1 | 1 | package frc.robot.constants; |
2 | 2 |
|
3 | | -public class ClimbConstants {} |
| 3 | +import static edu.wpi.first.units.Units.Degrees; |
| 4 | +import static edu.wpi.first.units.Units.DegreesPerSecond; |
| 5 | + |
| 6 | +import com.ctre.phoenix6.configs.CurrentLimitsConfigs; |
| 7 | +import com.ctre.phoenix6.configs.HardwareLimitSwitchConfigs; |
| 8 | +import com.ctre.phoenix6.configs.MotionMagicConfigs; |
| 9 | +import com.ctre.phoenix6.configs.MotorOutputConfigs; |
| 10 | +import com.ctre.phoenix6.configs.Slot0Configs; |
| 11 | +import com.ctre.phoenix6.configs.SoftwareLimitSwitchConfigs; |
| 12 | +import com.ctre.phoenix6.configs.TalonFXConfiguration; |
| 13 | +import com.ctre.phoenix6.signals.ForwardLimitSourceValue; |
| 14 | +import com.ctre.phoenix6.signals.ForwardLimitTypeValue; |
| 15 | +import com.ctre.phoenix6.signals.GravityTypeValue; |
| 16 | +import com.ctre.phoenix6.signals.NeutralModeValue; |
| 17 | +import com.ctre.phoenix6.signals.ReverseLimitSourceValue; |
| 18 | +import com.ctre.phoenix6.signals.ReverseLimitTypeValue; |
| 19 | + |
| 20 | +import edu.wpi.first.units.measure.Angle; |
| 21 | +import edu.wpi.first.units.measure.AngularVelocity; |
| 22 | + |
| 23 | +public class ClimbConstants { |
| 24 | + public static int kWheelFxId = 0; |
| 25 | + public static int kArmFxId = 0; |
| 26 | + |
| 27 | + public static final AngularVelocity kWheelCloseEnough = DegreesPerSecond.of(5.0); |
| 28 | + public static final Angle kArmCloseEnough = Degrees.of(5.0); |
| 29 | + public static final Angle kArmMaxFwd = Degrees.of(100); |
| 30 | + public static final Angle kArmMaxRev = Degrees.of(-100); |
| 31 | + public static final Angle kArmZeroTicks = Degrees.of(1530); |
| 32 | + |
| 33 | + public static TalonFXConfiguration getWheelFXConfig() { |
| 34 | + TalonFXConfiguration wheelFxConfig = new TalonFXConfiguration(); |
| 35 | + |
| 36 | + CurrentLimitsConfigs current = |
| 37 | + new CurrentLimitsConfigs() |
| 38 | + .withStatorCurrentLimit(10) |
| 39 | + .withStatorCurrentLimitEnable(false) |
| 40 | + .withStatorCurrentLimit(20) |
| 41 | + .withSupplyCurrentLimit(10) |
| 42 | + .withSupplyCurrentLowerLimit(8) |
| 43 | + .withSupplyCurrentLowerTime(0.02) |
| 44 | + .withSupplyCurrentLimitEnable(true); |
| 45 | + wheelFxConfig.CurrentLimits = current; |
| 46 | + |
| 47 | + HardwareLimitSwitchConfigs hwLimit = |
| 48 | + new HardwareLimitSwitchConfigs() |
| 49 | + .withForwardLimitAutosetPositionEnable(false) |
| 50 | + .withForwardLimitEnable(false) |
| 51 | + .withForwardLimitType(ForwardLimitTypeValue.NormallyOpen) |
| 52 | + .withForwardLimitSource(ForwardLimitSourceValue.LimitSwitchPin) |
| 53 | + .withReverseLimitAutosetPositionEnable(false) |
| 54 | + .withReverseLimitEnable(false) |
| 55 | + .withReverseLimitType(ReverseLimitTypeValue.NormallyOpen) |
| 56 | + .withReverseLimitSource(ReverseLimitSourceValue.LimitSwitchPin); |
| 57 | + wheelFxConfig.HardwareLimitSwitch = hwLimit; |
| 58 | + |
| 59 | + Slot0Configs slot0 = |
| 60 | + new Slot0Configs() |
| 61 | + .withKP(0) |
| 62 | + .withKI(0) |
| 63 | + .withKD(0) |
| 64 | + .withGravityType(GravityTypeValue.Elevator_Static) |
| 65 | + .withKG(0) |
| 66 | + .withKS(0) |
| 67 | + .withKV(0) |
| 68 | + .withKA(0); |
| 69 | + wheelFxConfig.Slot0 = slot0; |
| 70 | + |
| 71 | + MotionMagicConfigs motionMagic = |
| 72 | + new MotionMagicConfigs() |
| 73 | + .withMotionMagicAcceleration(0) |
| 74 | + .withMotionMagicCruiseVelocity(0) |
| 75 | + .withMotionMagicExpo_kA(0) |
| 76 | + .withMotionMagicExpo_kV(0) |
| 77 | + .withMotionMagicJerk(0); |
| 78 | + wheelFxConfig.MotionMagic = motionMagic; |
| 79 | + |
| 80 | + MotorOutputConfigs motorOut = |
| 81 | + new MotorOutputConfigs() |
| 82 | + .withDutyCycleNeutralDeadband(0.01) |
| 83 | + .withNeutralMode(NeutralModeValue.Coast); |
| 84 | + wheelFxConfig.MotorOutput = motorOut; |
| 85 | + |
| 86 | + return wheelFxConfig; |
| 87 | + } |
| 88 | + |
| 89 | + public static TalonFXConfiguration getArmFxConfig() { |
| 90 | + TalonFXConfiguration armFxConfig = new TalonFXConfiguration(); |
| 91 | + |
| 92 | + CurrentLimitsConfigs current = |
| 93 | + new CurrentLimitsConfigs() |
| 94 | + .withStatorCurrentLimit(10) |
| 95 | + .withStatorCurrentLimitEnable(false) |
| 96 | + .withStatorCurrentLimit(20) |
| 97 | + .withSupplyCurrentLimit(10) |
| 98 | + .withSupplyCurrentLowerLimit(8) |
| 99 | + .withSupplyCurrentLowerTime(0.02) |
| 100 | + .withSupplyCurrentLimitEnable(true); |
| 101 | + armFxConfig.CurrentLimits = current; |
| 102 | + |
| 103 | + HardwareLimitSwitchConfigs hwLimit = |
| 104 | + new HardwareLimitSwitchConfigs() |
| 105 | + .withForwardLimitAutosetPositionEnable(false) |
| 106 | + .withForwardLimitEnable(false) |
| 107 | + .withForwardLimitType(ForwardLimitTypeValue.NormallyOpen) |
| 108 | + .withForwardLimitSource(ForwardLimitSourceValue.LimitSwitchPin) |
| 109 | + .withReverseLimitAutosetPositionEnable(false) |
| 110 | + .withReverseLimitEnable(false) |
| 111 | + .withReverseLimitType(ReverseLimitTypeValue.NormallyOpen) |
| 112 | + .withReverseLimitSource(ReverseLimitSourceValue.LimitSwitchPin); |
| 113 | + armFxConfig.HardwareLimitSwitch = hwLimit; |
| 114 | + |
| 115 | + SoftwareLimitSwitchConfigs swLimit = |
| 116 | + new SoftwareLimitSwitchConfigs() |
| 117 | + .withForwardSoftLimitEnable(true) |
| 118 | + .withForwardSoftLimitThreshold(kArmMaxFwd) |
| 119 | + .withReverseSoftLimitEnable(true) |
| 120 | + .withReverseSoftLimitThreshold(kArmMaxRev); |
| 121 | + armFxConfig.SoftwareLimitSwitch = swLimit; |
| 122 | + |
| 123 | + Slot0Configs slot0 = |
| 124 | + new Slot0Configs() |
| 125 | + .withKP(0) |
| 126 | + .withKI(0) |
| 127 | + .withKD(0) |
| 128 | + .withGravityType(GravityTypeValue.Elevator_Static) |
| 129 | + .withKG(0) |
| 130 | + .withKS(0) |
| 131 | + .withKV(0) |
| 132 | + .withKA(0); |
| 133 | + armFxConfig.Slot0 = slot0; |
| 134 | + |
| 135 | + MotionMagicConfigs motionMagic = |
| 136 | + new MotionMagicConfigs() |
| 137 | + .withMotionMagicAcceleration(0) |
| 138 | + .withMotionMagicCruiseVelocity(0) |
| 139 | + .withMotionMagicExpo_kA(0) |
| 140 | + .withMotionMagicExpo_kV(0) |
| 141 | + .withMotionMagicJerk(0); |
| 142 | + armFxConfig.MotionMagic = motionMagic; |
| 143 | + |
| 144 | + MotorOutputConfigs motorOut = |
| 145 | + new MotorOutputConfigs() |
| 146 | + .withDutyCycleNeutralDeadband(0.01) |
| 147 | + .withNeutralMode(NeutralModeValue.Coast); |
| 148 | + armFxConfig.MotorOutput = motorOut; |
| 149 | + |
| 150 | + return armFxConfig; |
| 151 | + } |
| 152 | +} |
0 commit comments