11package frc .robot .constants ;
22
3- public class ElevatorConstants {}
3+ import org .littletonrobotics .junction .AutoLog ;
4+ import org .strykeforce .telemetry .TelemetryService ;
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 .InvertedValue ;
17+ import com .ctre .phoenix6 .signals .NeutralModeValue ;
18+ import com .ctre .phoenix6 .signals .ReverseLimitSourceValue ;
19+ import com .ctre .phoenix6 .signals .ReverseLimitTypeValue ;
20+
21+ public class ElevatorConstants {
22+
23+ public static final double kCloseEnough ;
24+ public static final double kMaxFwd ;
25+ public static final double kMaxRev ;
26+ public static final double kZeroTicks ;
27+
28+ public static final int kFxIDMain = 20 ;
29+ public static final int kFxIDFollow = 21 ;
30+
31+ //Make constants for Level 1 and have all the others be offsets of those constants
32+
33+ public static TalonFXConfiguration getBothFXConfig () {
34+ TalonFXConfiguration fxConfig = new TalonFXConfiguration ();
35+
36+ CurrentLimitsConfigs current =
37+ new CurrentLimitsConfigs ()
38+ .withStatorCurrentLimit ()
39+ .withStatorCurrentLimitEnable ()
40+ .withSupplyCurrentLimit ()
41+ .withSupplyCurrentThreshold ()
42+ .withSupplyCurrentLimitEnable ()
43+ .withSupplyTimeThreshold ();
44+ fxConfig .CurrentLimits = current ;
45+
46+ HardwareLimitSwitchConfigs hwLimit =
47+ new HardwareLimitSwitchConfigs ()
48+ .withForwardLimitAutosetPositionEnable ()
49+ .withForwardLimitEnable ()
50+ .withForwardLimitType (ForwardLimitTypeValue .NormallyOpen )
51+ .withForwardLimitSource (ForwardLimitSourceValue .LimitSwitchPin )
52+ .withReverseLimitAutosetPositionEnable (false )
53+ .withReverseLimitEnable (false )
54+ .withReverseLimitType (ReverseLimitTypeValue .NormallyOpen )
55+ .withReverseLimitSource (ReverseLimitSourceValue .LimitSwitchPin );
56+ fxConfig .HardwareLimitSwitch = hwLimit ;
57+
58+ SoftwareLimitSwitchConfigs swLimit =
59+ new SoftwareLimitSwitchConfigs ()
60+ .withForwardSoftLimitEnable (false )
61+ .withForwardSoftLimitThreshold (kMaxFwd )
62+ .withReverseSoftLimitEnable (false )
63+ .withReverseSoftLimitThreshold (kMaxRev );
64+ fxConfig .SoftwareLimitSwitch = swLimit ;
65+
66+ Slot0Configs slot0 =
67+ new Slot0Configs ()
68+ .withKP (0.4 )
69+ .withKI (0.1 )
70+ .withKD (0 )
71+ .withGravityType (GravityTypeValue .Elevator_Static )
72+ .withKG (0 )
73+ .withKS (0 )
74+ .withKV (0.12 )
75+ .withKA (0 );
76+ fxConfig .Slot0 = slot0 ;
77+
78+ MotionMagicConfigs motionMagic =
79+ new MotionMagicConfigs ()
80+ .withMotionMagicAcceleration (130 )
81+ .withMotionMagicCruiseVelocity (0 )
82+ .withMotionMagicExpo_kA (0 )
83+ .withMotionMagicExpo_kV (0 )
84+ .withMotionMagicJerk (1000 );
85+ fxConfig .MotionMagic = motionMagic ;
86+
87+ MotorOutputConfigs motorOut =
88+ new MotorOutputConfigs ()
89+ .withDutyCycleNeutralDeadband (0.01 )
90+ .withNeutralMode (NeutralModeValue .Coast )
91+ .withInverted (InvertedValue .CounterClockwise_Positive );
92+ fxConfig .MotorOutput = motorOut ;
93+
94+ return fxConfig ;
95+ }
96+ }
0 commit comments