77import com .chaos131 .util .DashboardNumber ;
88import com .ctre .phoenix6 .configs .Slot0Configs ;
99import com .ctre .phoenix6 .configs .TalonFXSConfiguration ;
10-
1110import java .util .ArrayList ;
1211import java .util .List ;
1312import java .util .function .BiConsumer ;
1413
15- /** This creates a class to easily tune TalonFXConfigs for 1 or more motors. */
14+ /** This creates a class to easily tune TalonFXSConfigurations for 1 or more motors. */
1615public class ChaosTalonFxsTuner {
1716 private String m_name ;
1817 private ChaosTalonFxs [] m_talons ;
19- private List <DashboardNumber > m_tunables = new ArrayList <>(); // Keep in list to prevent any garbage collection
18+ private List <DashboardNumber > m_tunables =
19+ new ArrayList <>(); // Keep in list to prevent any garbage collection
2020
2121 /**
22- * Creates a tuner for modifying numeric values of TalonFxConfigs .
22+ * Creates a tuner for modifying numeric values of TalonFXSConfigurations .
2323 *
2424 * @param name the name of the motor tuner
2525 * @param talons the list of talons to tune
@@ -30,27 +30,23 @@ public ChaosTalonFxsTuner(String name, ChaosTalonFxs... talons) {
3030 }
3131
3232 /**
33- * Creates a tunable value for the TalonFxConfiguration and will apply/burn the value to the motor
34- * when it changes.
33+ * Creates tunables for the Slot0 number values
3534 *
36- * @param valueName the name of the value (e.g., "SupplyCurrentLimit")
37- * @param initialValue the value to start at (is not applied by default)
38- * @param onUpdate the function to update the configuration
39- * @return the Dashboard number
35+ * @param initialConfig the starting Slot0 values
4036 */
4137 public void tunableSlot0 (Slot0Configs initialConfig ) {
42- tunable ("Slot0/kP " , initialConfig .kP , (config , newValue ) -> config .Slot0 .kP = newValue );
43- tunable ("Slot0/kI " , initialConfig .kI , (config , newValue ) -> config .Slot0 .kI = newValue );
44- tunable ("Slot0/kD " , initialConfig .kD , (config , newValue ) -> config .Slot0 .kD = newValue );
45- tunable ("Slot0/kG " , initialConfig .kG , (config , newValue ) -> config .Slot0 .kG = newValue );
46- tunable ("Slot0/kS " , initialConfig .kS , (config , newValue ) -> config .Slot0 .kS = newValue );
47- tunable ("Slot0/kV " , initialConfig .kV , (config , newValue ) -> config .Slot0 .kV = newValue );
48- tunable ("Slot0/kA " , initialConfig .kA , (config , newValue ) -> config .Slot0 .kA = newValue );
38+ tunable ("Slot0_kP " , initialConfig .kP , (config , newValue ) -> config .Slot0 .kP = newValue );
39+ tunable ("Slot0_kI " , initialConfig .kI , (config , newValue ) -> config .Slot0 .kI = newValue );
40+ tunable ("Slot0_kD " , initialConfig .kD , (config , newValue ) -> config .Slot0 .kD = newValue );
41+ tunable ("Slot0_kG " , initialConfig .kG , (config , newValue ) -> config .Slot0 .kG = newValue );
42+ tunable ("Slot0_kS " , initialConfig .kS , (config , newValue ) -> config .Slot0 .kS = newValue );
43+ tunable ("Slot0_kV " , initialConfig .kV , (config , newValue ) -> config .Slot0 .kV = newValue );
44+ tunable ("Slot0_kA " , initialConfig .kA , (config , newValue ) -> config .Slot0 .kA = newValue );
4945 }
5046
5147 /**
52- * Creates a tunable value for the TalonFxConfiguration and will apply/burn the value to the motor
53- * when it changes.
48+ * Creates a tunable value for the TalonFXSConfiguration and will apply/burn the value to the
49+ * motor when it changes.
5450 *
5551 * @param valueName the name of the value (e.g., "SupplyCurrentLimit")
5652 * @param initialValue the value to start at (is not applied by default)
@@ -59,17 +55,18 @@ public void tunableSlot0(Slot0Configs initialConfig) {
5955 */
6056 public DashboardNumber tunable (
6157 String valueName , double initialValue , BiConsumer <TalonFXSConfiguration , Double > onUpdate ) {
62- DashboardNumber dsNumber = new DashboardNumber (
63- "TalonFxConfig/" + m_name + "/" + valueName ,
64- initialValue ,
65- true ,
66- false ,
67- newValue -> {
68- for (ChaosTalonFxs chaosTalonFxs : m_talons ) {
69- onUpdate .accept (chaosTalonFxs .Configuration , newValue );
70- chaosTalonFxs .applyConfig ();
71- }
72- });
58+ DashboardNumber dsNumber =
59+ new DashboardNumber (
60+ "TalonFxConfig/" + m_name + "/" + valueName ,
61+ initialValue ,
62+ true ,
63+ false ,
64+ newValue -> {
65+ for (ChaosTalonFxs chaosTalonFxs : m_talons ) {
66+ onUpdate .accept (chaosTalonFxs .Configuration , newValue );
67+ chaosTalonFxs .applyConfig ();
68+ }
69+ });
7370 m_tunables .add (dsNumber );
7471 return dsNumber ;
7572 }
0 commit comments