11package frc .robot .constants ;
22
3- public class AlgaeConstants {}
3+ import static edu .wpi .first .units .Units .Degrees ;
4+ import static edu .wpi .first .units .Units .Rotations ;
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+ import edu .wpi .first .units .measure .*;
20+ public class AlgaeConstants {
21+
22+
23+ public static int kFxId = 4 ; //CHANGE TO MOTOR NUMBER
24+
25+ public static final Angle kCloseEnough = Degrees .of (5 );
26+ public static final Angle kMaxFwd = Rotations .of (100 );
27+ public static final Angle kMaxRev = Rotations .of (-100 );
28+ public static final Angle kZeroTicks = Rotations .of (1530 );
29+
30+ // Example Talon FX Config
31+ public static TalonFXConfiguration getFXConfig () {
32+ TalonFXConfiguration fxConfig = new TalonFXConfiguration ();
33+
34+ CurrentLimitsConfigs current =
35+ new CurrentLimitsConfigs ()
36+ .withStatorCurrentLimit (10 )
37+ .withStatorCurrentLimitEnable (false )
38+ .withStatorCurrentLimit (20 )
39+ .withSupplyCurrentLimit (10 )
40+ .withSupplyCurrentLowerLimit (8 )
41+ .withSupplyCurrentLowerTime (0.02 )
42+ .withSupplyCurrentLimitEnable (true );
43+ fxConfig .CurrentLimits = current ;
44+
45+ HardwareLimitSwitchConfigs hwLimit =
46+ new HardwareLimitSwitchConfigs ()
47+ .withForwardLimitAutosetPositionEnable (false )
48+ .withForwardLimitEnable (false )
49+ .withForwardLimitType (ForwardLimitTypeValue .NormallyOpen )
50+ .withForwardLimitSource (ForwardLimitSourceValue .LimitSwitchPin )
51+ .withReverseLimitAutosetPositionEnable (false )
52+ .withReverseLimitEnable (false )
53+ .withReverseLimitType (ReverseLimitTypeValue .NormallyOpen )
54+ .withReverseLimitSource (ReverseLimitSourceValue .LimitSwitchPin );
55+ fxConfig .HardwareLimitSwitch = hwLimit ;
56+
57+ SoftwareLimitSwitchConfigs swLimit =
58+ new SoftwareLimitSwitchConfigs ()
59+ .withForwardSoftLimitEnable (true )
60+ .withForwardSoftLimitThreshold (kMaxFwd )
61+ .withReverseSoftLimitEnable (true )
62+ .withReverseSoftLimitThreshold (kMaxRev );
63+ fxConfig .SoftwareLimitSwitch = swLimit ;
64+
65+ Slot0Configs slot0 =
66+ new Slot0Configs ()
67+ .withKP (0 )
68+ .withKI (0 )
69+ .withKD (0 )
70+ .withGravityType (GravityTypeValue .Elevator_Static )
71+ .withKG (0 )
72+ .withKS (0 )
73+ .withKV (0 )
74+ .withKA (0 );
75+ fxConfig .Slot0 = slot0 ;
76+
77+ MotionMagicConfigs motionMagic =
78+ new MotionMagicConfigs ()
79+ .withMotionMagicAcceleration (0 )
80+ .withMotionMagicCruiseVelocity (0 )
81+ .withMotionMagicExpo_kA (0 )
82+ .withMotionMagicExpo_kV (0 )
83+ .withMotionMagicJerk (0 );
84+ fxConfig .MotionMagic = motionMagic ;
85+
86+ MotorOutputConfigs motorOut =
87+ new MotorOutputConfigs ()
88+ .withDutyCycleNeutralDeadband (0.01 )
89+ .withNeutralMode (NeutralModeValue .Coast );
90+ fxConfig .MotorOutput = motorOut ;
91+
92+ return fxConfig ;
93+ }
94+ }
0 commit comments