55package com .chaos131 .ctre ;
66
77import com .chaos131 .util .DashboardNumber ;
8+ import com .ctre .phoenix6 .configs .CurrentLimitsConfigs ;
9+ import com .ctre .phoenix6 .configs .ExternalFeedbackConfigs ;
810import com .ctre .phoenix6 .configs .Slot0Configs ;
911import com .ctre .phoenix6 .configs .TalonFXSConfiguration ;
1012import java .util .ArrayList ;
@@ -29,19 +31,99 @@ public ChaosTalonFxsTuner(String name, ChaosTalonFxs... talons) {
2931 m_talons = talons ;
3032 }
3133
34+ /** Creates tunables for the Slot0 number values using the first motor's config */
35+ public ChaosTalonFxsTuner withSlot0 () {
36+ return withSlot0 (m_talons [0 ].Configuration .Slot0 );
37+ }
38+
3239 /**
3340 * Creates tunables for the Slot0 number values
3441 *
3542 * @param initialConfig the starting Slot0 values
3643 */
37- public void tunableSlot0 (Slot0Configs initialConfig ) {
44+ public ChaosTalonFxsTuner withSlot0 (Slot0Configs initialConfig ) {
3845 tunable ("Slot0_kP" , initialConfig .kP , (config , newValue ) -> config .Slot0 .kP = newValue );
3946 tunable ("Slot0_kI" , initialConfig .kI , (config , newValue ) -> config .Slot0 .kI = newValue );
4047 tunable ("Slot0_kD" , initialConfig .kD , (config , newValue ) -> config .Slot0 .kD = newValue );
4148 tunable ("Slot0_kG" , initialConfig .kG , (config , newValue ) -> config .Slot0 .kG = newValue );
4249 tunable ("Slot0_kS" , initialConfig .kS , (config , newValue ) -> config .Slot0 .kS = newValue );
4350 tunable ("Slot0_kV" , initialConfig .kV , (config , newValue ) -> config .Slot0 .kV = newValue );
4451 tunable ("Slot0_kA" , initialConfig .kA , (config , newValue ) -> config .Slot0 .kA = newValue );
52+ return this ;
53+ }
54+
55+ /** Creates tunables for the CurrentLimitsConfigs number values using the first motor's config */
56+ public ChaosTalonFxsTuner withCurrentLimits () {
57+ return withCurrentLimits (m_talons [0 ].Configuration .CurrentLimits );
58+ }
59+
60+ /**
61+ * Creates tunables for the CurrentLimitsConfigs number values
62+ *
63+ * @param initialConfig the starting CurrentLimitsConfigs values
64+ */
65+ public ChaosTalonFxsTuner withCurrentLimits (CurrentLimitsConfigs initialConfig ) {
66+ tunable (
67+ "CurrentLimit_Stator" ,
68+ initialConfig .StatorCurrentLimit ,
69+ (config , newValue ) -> config .CurrentLimits .StatorCurrentLimit = newValue );
70+ tunable (
71+ "CurrentLimit_Supply" ,
72+ initialConfig .SupplyCurrentLimit ,
73+ (config , newValue ) -> config .CurrentLimits .SupplyCurrentLimit = newValue );
74+ tunable (
75+ "CurrentLimit_SupplyLower_Limit" ,
76+ initialConfig .SupplyCurrentLowerLimit ,
77+ (config , newValue ) -> config .CurrentLimits .SupplyCurrentLowerLimit = newValue );
78+ tunable (
79+ "CurrentLimit_SupplyLower_Time" ,
80+ initialConfig .SupplyCurrentLowerTime ,
81+ (config , newValue ) -> config .CurrentLimits .SupplyCurrentLowerTime = newValue );
82+ return this ;
83+ }
84+
85+ /**
86+ * Creates tunables for the ExternalFeedbackConfigs number values using the first motor's config
87+ */
88+ public ChaosTalonFxsTuner withFeedbackValues () {
89+ return withFeedbackValues (m_talons [0 ].Configuration .ExternalFeedback );
90+ }
91+
92+ /**
93+ * Creates tunables for the ExternalFeedbackConfigs number values
94+ *
95+ * @param initialConfig the starting ExternalFeedbackConfigs values
96+ */
97+ public ChaosTalonFxsTuner withFeedbackValues (ExternalFeedbackConfigs initialConfig ) {
98+ tunable (
99+ "Feedback_RotorToSensorRatio" ,
100+ initialConfig .RotorToSensorRatio ,
101+ (config , newValue ) -> config .ExternalFeedback .RotorToSensorRatio = newValue );
102+ tunable (
103+ "Feedback_SensorToMechanismRatio" ,
104+ initialConfig .SensorToMechanismRatio ,
105+ (config , newValue ) -> config .ExternalFeedback .SensorToMechanismRatio = newValue );
106+ return this ;
107+ }
108+
109+ /**
110+ * Adds all tunable values (currently Slot0, CurrentLimits, and FeedbackValues) using the first
111+ * motor's config
112+ */
113+ public ChaosTalonFxsTuner withAllConfigs () {
114+ return withAllConfigs (m_talons [0 ].Configuration );
115+ }
116+
117+ /**
118+ * Adds all tunable values (currently Slot0, CurrentLimits, and FeedbackValues)
119+ *
120+ * @param initialConfig the starting config
121+ */
122+ public ChaosTalonFxsTuner withAllConfigs (TalonFXSConfiguration initialConfig ) {
123+ withSlot0 (initialConfig .Slot0 );
124+ withCurrentLimits (initialConfig .CurrentLimits );
125+ withFeedbackValues (initialConfig .ExternalFeedback );
126+ return this ;
45127 }
46128
47129 /**
@@ -57,9 +139,8 @@ public DashboardNumber tunable(
57139 String valueName , double initialValue , BiConsumer <TalonFXSConfiguration , Double > onUpdate ) {
58140 DashboardNumber dsNumber =
59141 new DashboardNumber (
60- "TalonFxConfig/" + m_name + "/" + valueName ,
142+ m_name + "/" + valueName ,
61143 initialValue ,
62- true ,
63144 false ,
64145 newValue -> {
65146 for (ChaosTalonFxs chaosTalonFxs : m_talons ) {
0 commit comments