001package com.ctre.phoenix.motorcontrol.can;
002
003import com.ctre.phoenix.ErrorCode;
004import com.ctre.phoenix.ErrorCollection;
005import com.ctre.phoenix.ParamEnum;
006import com.ctre.phoenix.motorcontrol.ControlMode;
007import com.ctre.phoenix.motorcontrol.DemandType;
008import com.ctre.phoenix.motorcontrol.FeedbackDevice;
009import com.ctre.phoenix.motorcontrol.InvertType;
010import com.ctre.phoenix.motorcontrol.MotorCommutation;
011import com.ctre.phoenix.motorcontrol.StatorCurrentLimitConfiguration;
012import com.ctre.phoenix.motorcontrol.SupplyCurrentLimitConfiguration;
013import com.ctre.phoenix.motorcontrol.TalonFXControlMode;
014import com.ctre.phoenix.motorcontrol.TalonFXFeedbackDevice;
015import com.ctre.phoenix.motorcontrol.TalonFXInvertType;
016import com.ctre.phoenix.motorcontrol.TalonFXSensorCollection;
017import com.ctre.phoenix.motorcontrol.TalonFXSimCollection;
018import com.ctre.phoenix.sensors.AbsoluteSensorRange;
019import com.ctre.phoenix.sensors.SensorInitializationStrategy;
020
021/**
022 * CTRE Talon FX Motor Controller when used on CAN Bus.
023 *
024 * <pre>
025 * {@code
026 * // Example usage of a TalonFX motor controller
027 * TalonFX motor = new TalonFX(0); // creates a new TalonFX with ID 0
028 *
029 * TalonFXConfiguration config = new TalonFXConfiguration();
030 * config.supplyCurrLimit.enable = true;
031 * config.supplyCurrLimit.triggerThresholdCurrent = 40; // the peak supply current, in amps
032 * config.supplyCurrLimit.triggerThresholdTime = 1.5; // the time at the peak supply current before the limit triggers, in sec
033 * config.supplyCurrLimit.currentLimit = 30; // the current to maintain if the peak supply limit is triggered
034 * motor.configAllSettings(config); // apply the config settings; this selects the quadrature encoder
035 *
036 * motor.set(TalonFXControlMode.PercentOutput, 0.5); // runs the motor at 50% power
037 *
038 * System.out.println(motor.getSelectedSensorPosition()); // prints the position of the selected sensor
039 * System.out.println(motor.getSelectedSensorVelocity()); // prints the velocity recorded by the selected sensor
040 * System.out.println(motor.getMotorOutputPercent()); // prints the percent output of the motor (0.5)
041 * System.out.println(motor.getStatorCurrent()); // prints the output current of the motor
042 *
043 * ErrorCode error = motor.getLastError(); // gets the last error generated by the motor controller
044 * Faults faults = new Faults();
045 * ErrorCode faultsError = motor.getFaults(faults); // fills faults with the current motor controller faults; returns the last error generated
046 *
047 * motor.setStatusFramePeriod(StatusFrame.Status_2_Feedback0, 10); // changes the period of the Status 2 frame (getSelectedSensor*()) to 10ms
048 * }
049 * </pre>
050 */
051public class TalonFX extends BaseTalon {
052
053    /**
054     * Constructor
055     * @param deviceNumber [0,62]
056         * @param canbus Name of the CANbus; can be a SocketCAN interface (on Linux),
057         *               or a CANivore device name or serial number
058     */
059    public TalonFX(int deviceNumber, String canbus) {
060        super(deviceNumber, "Talon FX", canbus);
061    }
062
063    /**
064     * Constructor
065     * @param deviceNumber [0,62]
066     */
067    public TalonFX(int deviceNumber) {
068        this(deviceNumber, "");
069    }
070
071    // ------ Set output routines. ----------//
072    /**
073     * Sets the appropriate output on the talon, depending on the mode.
074     * @param mode The output mode to apply.
075     * In PercentOutput, the output is between -1.0 and 1.0, with 0.0 as stopped.
076     * In Current mode, output value is in amperes.
077     * In Velocity mode, output value is in position change / 100ms.
078     * In Position mode, output value is in encoder ticks or an analog value,
079     *   depending on the sensor.
080     * In Follower mode, the output value is the integer device ID of the talon to
081     * duplicate.
082     *
083     * @param value The setpoint value, as described above.
084     *
085     *
086     *  Standard Driving Example:
087    *   _talonLeft.set(ControlMode.PercentOutput, leftJoy);
088    *   _talonRght.set(ControlMode.PercentOutput, rghtJoy);
089    */
090    public void set(TalonFXControlMode mode, double value) {
091        super.set(mode.toControlMode(), value);
092    }
093    /**
094     * @param mode Sets the appropriate output on the talon, depending on the mode.
095     * @param demand0 The output value to apply.
096     *  such as advanced feed forward and/or auxiliary close-looping in firmware.
097     * In PercentOutput, the output is between -1.0 and 1.0, with 0.0 as stopped.
098     * In Current mode, output value is in amperes.
099     * In Velocity mode, output value is in position change / 100ms.
100     * In Position mode, output value is in encoder ticks or an analog value,
101     *   depending on the sensor. See
102     * In Follower mode, the output value is the integer device ID of the talon to
103     * duplicate.
104     *
105     * @param demand1Type The demand type for demand1.
106     * Neutral: Ignore demand1 and apply no change to the demand0 output.
107     * AuxPID: Use demand1 to set the target for the auxiliary PID 1.  Auxiliary
108     *   PID is always executed as standard Position PID control.
109     * ArbitraryFeedForward: Use demand1 as an arbitrary additive value to the
110     *   demand0 output.  In PercentOutput the demand0 output is the motor output,
111    *   and in closed-loop modes the demand0 output is the output of PID0.
112    * @param demand1 Supplmental output value.
113    * AuxPID: Target position in Sensor Units
114    * ArbitraryFeedForward: Percent Output between -1.0 and 1.0
115    *
116    *
117    *  Arcade Drive Example:
118    *           _talonLeft.set(ControlMode.PercentOutput, joyForward, DemandType.ArbitraryFeedForward, +joyTurn);
119    *           _talonRght.set(ControlMode.PercentOutput, joyForward, DemandType.ArbitraryFeedForward, -joyTurn);
120    *
121    *   Drive Straight Example:
122    *   Note: Selected Sensor Configuration is necessary for both PID0 and PID1.
123    *           _talonLeft.follow(_talonRght, FollwerType.AuxOutput1);
124    *           _talonRght.set(ControlMode.PercentOutput, joyForward, DemandType.AuxPID, desiredRobotHeading);
125    *
126    *   Drive Straight to a Distance Example:
127    *   Note: Other configurations (sensor selection, PID gains, etc.) need to be set.
128    *           _talonLeft.follow(_talonRght, FollwerType.AuxOutput1);
129    *           _talonRght.set(ControlMode.MotionMagic, targetDistance, DemandType.AuxPID, desiredRobotHeading);
130    */
131    public void set(TalonFXControlMode mode, double demand0, DemandType demand1Type, double demand1) {
132        super.set(mode.toControlMode(), demand0, demand1Type, demand1);
133    }
134    //------ Invert behavior ----------//
135    /**
136     * Inverts the hbridge output of the motor controller in relation to the master if present
137     *
138     * This does not impact sensor phase and should not be used to correct sensor polarity.
139     *
140     * This will allow you to either:
141     *  - Spin counterclockwise (default)
142     *  - Spin Clockwise (invert direction)
143     *  - Always follow the master regardless of master's inversion
144     *  - Always oppose the master regardless of master's inversion
145     *
146     * @param invertType
147     *            Invert state to set.
148     */
149    public void setInverted(TalonFXInvertType invertType)
150    {
151        super.setInverted(invertType.toInvertType());
152    }
153
154    //------ sensor selection ----------//
155    /**
156     * Select the feedback device for the motor controller.
157     *
158     * @param feedbackDevice
159     *            Talon FX feedback Device to select.
160     * @param pidIdx
161     *            0 for Primary closed-loop. 1 for auxiliary closed-loop.
162     * @param timeoutMs
163     *            Timeout value in ms. If nonzero, function will wait for
164     *            config success and report an error if it times out.
165     *            If zero, no blocking or checking is performed.
166     * @return Error Code generated by function. 0 indicates no error.
167     */
168    public ErrorCode configSelectedFeedbackSensor(TalonFXFeedbackDevice feedbackDevice, int pidIdx, int timeoutMs) {
169        return super.configSelectedFeedbackSensor(feedbackDevice.toFeedbackDevice(), pidIdx, timeoutMs);
170    }
171    //------ Current Lim ----------//
172
173    /**
174     * Configures the supply (input) current limit.
175     * @param currLimitCfg  Current limit configuration
176     * @param timeoutMs
177     *            Timeout value in ms. If nonzero, function will wait for
178     *            config success and report an error if it times out.
179     *            If zero, no blocking or checking is performed.
180     * @return Error Code generated by function. 0 indicates no error.
181     */
182    public ErrorCode configSupplyCurrentLimit(SupplyCurrentLimitConfiguration currLimitCfg, int timeoutMs) {
183        double[] doubles = currLimitCfg.toArray();
184        return ErrorCode.valueOf(MotControllerJNI.ConfigSupplyCurrentLimit(getHandle(), doubles, timeoutMs));
185    }
186    /**
187     * Configures the supply (input) current limit.
188     * @param currLimitCfg  Current limit configuration
189     * @return Error Code generated by function. 0 indicates no error.
190     */
191    public ErrorCode configSupplyCurrentLimit(SupplyCurrentLimitConfiguration currLimitCfg) {
192        int timeoutMs = 50;
193        return configSupplyCurrentLimit(currLimitCfg, timeoutMs);
194    }
195    /**
196     * Configures the stator (output) current limit.
197     * @param currLimitCfg  Current limit configuration
198     * @param timeoutMs
199     *            Timeout value in ms. If nonzero, function will wait for
200     *            config success and report an error if it times out.
201     *            If zero, no blocking or checking is performed.
202     * @return Error Code generated by function. 0 indicates no error.
203     */
204    public ErrorCode configStatorCurrentLimit(StatorCurrentLimitConfiguration currLimitCfg, int timeoutMs)
205    {
206        double[] doubles = currLimitCfg.toArray();
207        return ErrorCode.valueOf(MotControllerJNI.ConfigStatorCurrentLimit(getHandle(), doubles, timeoutMs));
208    }
209    /**
210     * Configures the stator (output) current limit.
211     * @param currLimitCfg  Current limit configuration
212     * @return Error Code generated by function. 0 indicates no error.
213     */
214    public ErrorCode configStatorCurrentLimit(StatorCurrentLimitConfiguration currLimitCfg)
215    {
216        int timeoutMs = 50;
217        return configStatorCurrentLimit(currLimitCfg, timeoutMs);
218    }
219    /**
220     * Gets the supply (input) current limit configuration.
221     * @param currLimitConfigsToFill  Configuration object to fill with read values.
222     * @param timeoutMs
223     *            Timeout value in ms. If nonzero, function will wait for
224     *            config success and report an error if it times out.
225     * @return Error Code generated by function. 0 indicates no error.
226     */
227    public ErrorCode configGetSupplyCurrentLimit(SupplyCurrentLimitConfiguration currLimitConfigsToFill, int timeoutMs)
228    {
229        double toFill[] = new double[10];
230        int fillCnt = MotControllerJNI.ConfigGetSupplyCurrentLimit(getHandle(), toFill, timeoutMs);
231        currLimitConfigsToFill.deserialize(toFill);
232        return getLastError();
233    }
234    /**
235     * Gets the supply (input) current limit configuration.
236     * @param currLimitConfigsToFill  Configuration object to fill with read values..
237     * @return Error Code generated by function. 0 indicates no error.
238     */
239    public ErrorCode configGetSupplyCurrentLimit(SupplyCurrentLimitConfiguration currLimitConfigsToFill)
240    {
241        int timeoutMs = 50;
242        return configGetSupplyCurrentLimit(currLimitConfigsToFill, timeoutMs);
243    }
244    /**
245     * Gets the stator (output) current limit configuration.
246     * @param currLimitConfigsToFill  Configuration object to fill with read values.
247     * @param timeoutMs
248     *            Timeout value in ms. If nonzero, function will wait for
249     *            config success and report an error if it times out.
250     * @return Error Code generated by function. 0 indicates no error.
251     */
252    public ErrorCode configGetStatorCurrentLimit(StatorCurrentLimitConfiguration currLimitConfigsToFill, int timeoutMs)
253    {
254        double toFill[] = new double[10];
255        int fillCnt = MotControllerJNI.ConfigGetStatorCurrentLimit(getHandle(), toFill, timeoutMs);
256        currLimitConfigsToFill.deserialize(toFill);
257        return getLastError();
258    }
259    /**
260     * Gets the stator (output) current limit configuration.
261     * @param currLimitConfigsToFill  Configuration object to fill with read values.
262     * @return Error Code generated by function. 0 indicates no error.
263     */
264    public ErrorCode configGetStatorCurrentLimit(StatorCurrentLimitConfiguration currLimitConfigsToFill)
265    {
266        int timeoutMs = 50;
267        return configGetStatorCurrentLimit(currLimitConfigsToFill, timeoutMs);
268    }
269
270    /**
271     * Configure the motor commutation type.
272     *
273     * @param motorCommutation  Motor Commutation Type.
274     *
275     * @param timeoutMs
276     *            Timeout value in ms. If nonzero, function will wait for config
277     *            success and report an error if it times out. If zero, no
278     *            blocking or checking is performed.
279     */
280    public ErrorCode configMotorCommutation(MotorCommutation motorCommutation, int timeoutMs)
281    {
282        return ErrorCode.valueOf(MotControllerJNI.ConfigMotorCommutation(getHandle(), motorCommutation.value, timeoutMs));
283    }
284    /**
285     * Configure the motor commutation type.
286     *
287     * @param motorCommutation  Motor Commutation Type.
288     */
289    public ErrorCode configMotorCommutation(MotorCommutation motorCommutation)
290    {
291        int timeoutMs = 50;
292        return configMotorCommutation(motorCommutation, timeoutMs);
293    }
294
295    /**
296     * @param timeoutMs
297     *            Timeout value in ms. If nonzero, function will wait for config
298     *            success and report an error if it times out.
299     * @return  The motor commutation type.
300     */
301    public MotorCommutation configGetMotorCommutation(int timeoutMs)
302    {
303        return MotorCommutation.values()[MotControllerJNI.ConfigGetMotorCommutation(getHandle(), timeoutMs)];
304    }
305    /**
306     * @return  The motor commutation type.
307     */
308    public MotorCommutation configGetMotorCommutation()
309    {
310        int timeoutMs = 0;
311        return configGetMotorCommutation(timeoutMs);
312    }
313
314    /**
315     * Sets the signage and range of the "Absolute Position" signal.
316     * Choose unsigned for an absolute range of [0,+1) rotations, [0,360) deg, etc...
317     * Choose signed for an absolute range of [-0.5,+0.5) rotations, [-180,+180) deg, etc...
318     * @param absoluteSensorRange
319     *            Desired Sign/Range for the absolute position register.
320     * @param timeoutMs
321     *            Timeout value in ms. If nonzero, function will wait for
322     *            config success and report an error if it times out.
323     *            If zero, no blocking or checking is performed.
324     * @return Error Code generated by function. 0 indicates no error.
325     */
326    public ErrorCode configIntegratedSensorAbsoluteRange(AbsoluteSensorRange absoluteSensorRange, int timeoutMs)
327    {
328        return ErrorCode.valueOf(MotControllerJNI.ConfigIntegratedSensorAbsoluteRange(getHandle(), absoluteSensorRange.value, timeoutMs));
329    }
330
331    /**
332     * Sets the signage and range of the "Absolute Position" signal.
333     * Choose unsigned for an absolute range of [0,+1) rotations, [0,360) deg, etc...
334     * Choose signed for an absolute range of [-0.5,+0.5) rotations, [-180,+180) deg, etc...
335     * @param absoluteSensorRange
336     *            Desired Sign/Range for the absolute position register.
337     * @return Error Code generated by function. 0 indicates no error.
338     */
339    public ErrorCode configIntegratedSensorAbsoluteRange(AbsoluteSensorRange absoluteSensorRange)
340    {
341        int timeoutMs = 0;
342        return configIntegratedSensorAbsoluteRange(absoluteSensorRange, timeoutMs);
343    }
344    /**
345     * Adjusts the zero point for the integrated sensor absolute position register.
346     * The absolute position of the sensor will always have a discontinuity (360 -> 0 deg) or (+180 -> -180)
347     * and a hard-limited mechanism may have such a discontinuity in its functional range.
348     * In which case use this config to move the discontinuity outside of the function range.
349     * @param offsetDegrees
350     *            Offset in degrees
351     * @param timeoutMs
352     *            Timeout value in ms. If nonzero, function will wait for
353     *            config success and report an error if it times out.
354     *            If zero, no blocking or checking is performed.
355     * @return Error Code generated by function. 0 indicates no error.
356     */
357    public ErrorCode configIntegratedSensorOffset(double offsetDegrees, int timeoutMs)
358    {
359        return ErrorCode.valueOf(MotControllerJNI.ConfigIntegratedSensorOffset(getHandle(), offsetDegrees, timeoutMs));
360    }
361    /**
362     * Adjusts the zero point for the integrated sensor absolute position register.
363     * The absolute position of the sensor will always have a discontinuity (360 -> 0 deg) or (+180 -> -180)
364     * and a hard-limited mechanism may have such a discontinuity in its functional range.
365     * In which case use this config to move the discontinuity outside of the function range.
366     * @param offsetDegrees
367     *            Offset in degrees
368     * @return Error Code generated by function. 0 indicates no error.
369     */
370    public ErrorCode configIntegratedSensorOffset(double offsetDegrees)
371    {
372        int timeoutMs = 0;
373        return configIntegratedSensorOffset(offsetDegrees, timeoutMs);
374    }
375    /**
376     * Pick the strategy on how to initialize the integrated sensor register.  Depending on the mechanism,
377     * it may be desirable to auto set the Position register to match the Absolute Position (swerve for example).
378     * Or it may be desired to zero the sensor on boot (drivetrain translation sensor or a relative servo).
379     *
380     * TIP: Tuner's self-test feature will report what the boot sensor value will be in the event the product is reset.
381     *
382     * @param initializationStrategy
383     *            The sensor initialization strategy to use.  This will impact the behavior the next time product boots up.
384     * @param timeoutMs
385     *            Timeout value in ms. If nonzero, function will wait for
386     *            config success and report an error if it times out.
387     *            If zero, no blocking or checking is performed.
388     * @return Error Code generated by function. 0 indicates no error.
389     */
390    public ErrorCode configIntegratedSensorInitializationStrategy(SensorInitializationStrategy initializationStrategy, int timeoutMs)
391    {
392        return ErrorCode.valueOf(MotControllerJNI.ConfigIntegratedSensorInitializationStrategy(getHandle(), initializationStrategy.value, timeoutMs));
393    }
394    /**
395     * Pick the strategy on how to initialize the integrated sensor register.  Depending on the mechanism,
396     * it may be desirable to auto set the Position register to match the Absolute Position (swerve for example).
397     * Or it may be desired to zero the sensor on boot (drivetrain translation sensor or a relative servo).
398     *
399     * TIP: Tuner's self-test feature will report what the boot sensor value will be in the event the product is reset.
400     *
401     * @param initializationStrategy
402     *            The sensor initialization strategy to use.  This will impact the behavior the next time product boots up.
403     * @return Error Code generated by function. 0 indicates no error.
404     */
405    public ErrorCode configIntegratedSensorInitializationStrategy(SensorInitializationStrategy initializationStrategy)
406    {
407        int timeoutMs = 0;
408        return configIntegratedSensorInitializationStrategy(initializationStrategy, timeoutMs);
409    }
410
411    /**
412     * @return object that can get/set individual raw sensor values.
413     */
414    public TalonFXSensorCollection getSensorCollection() {
415        return super.getTalonFXSensorCollection();
416    }
417
418        /**
419         * @return object that can get/set simulation inputs.
420         */
421        public TalonFXSimCollection getSimCollection() {
422                return super.getTalonFXSimCollection();
423        }
424
425   /**
426     * Configures all PID set persistent settings (overloaded so timeoutMs is 50 ms
427     * and pidIdx is 0).
428     *
429         * @param pid               Object with all of the PID set persistant settings
430         * @param pidIdx            0 for Primary closed-loop. 1 for auxiliary closed-loop.
431     * @param timeoutMs
432     *              Timeout value in ms. If nonzero, function will wait for
433     *              config success and report an error if it times out.
434     *              If zero, no blocking or checking is performed.
435     *
436     * @return Error Code generated by function. 0 indicates no error.
437     */
438        protected ErrorCode configurePID(TalonFXPIDSetConfiguration pid, int pidIdx, int timeoutMs) {
439        return super.configurePID(pid, pidIdx, timeoutMs, false);
440        }
441    /**
442     * Configures all PID set persistent settings (overloaded so timeoutMs is 50 ms
443     * and pidIdx is 0).
444     *
445         * @param pid               Object with all of the PID set persistant settings
446     *
447     * @return Error Code generated by function. 0 indicates no error.
448     */
449        protected ErrorCode configurePID(TalonFXPIDSetConfiguration pid) {
450        return super.configurePID(pid);
451    }
452
453    /**
454     * Gets all PID set persistant settings.
455     *
456         * @param pid               Object with all of the PID set persistant settings
457         * @param pidIdx            0 for Primary closed-loop. 1 for auxiliary closed-loop.
458     * @param timeoutMs
459     *              Timeout value in ms. If nonzero, function will wait for
460     *              config success and report an error if it times out.
461     *              If zero, no blocking or checking is performed.
462     */
463    public void getPIDConfigs(TalonFXPIDSetConfiguration pid, int pidIdx, int timeoutMs){
464        super.getPIDConfigs(pid, pidIdx, timeoutMs);
465    }
466    /**
467     * Gets all PID set persistant settings (overloaded so timeoutMs is 50 ms
468     * and pidIdx is 0).
469     *
470         * @param pid               Object with all of the PID set persistant settings
471     */
472        public void getPIDConfigs(TalonFXPIDSetConfiguration pid) {
473        int pidIdx = 0;
474        int timeoutMs = 50;
475        getPIDConfigs(pid, pidIdx, timeoutMs);
476    }
477
478    /**
479     * Configures all persistent settings.
480     *
481     * @param allConfigs        Object with all of the persistant settings
482     * @param timeoutMs
483     *              Timeout value in ms. If nonzero, function will wait for
484     *              config success and report an error if it times out.
485     *              If zero, no blocking or checking is performed.
486     *
487     * @return Error Code generated by function. 0 indicates no error.
488     */
489    public ErrorCode configAllSettings(TalonFXConfiguration allConfigs, int timeoutMs)
490    {
491        ErrorCollection ec = new ErrorCollection();
492
493        ec.NewError(super.configAllSettings(allConfigs, timeoutMs));
494
495        if (TalonFXConfigUtil.SupplyCurrentLimitDifferent(allConfigs))
496        {
497            double[] doubles = allConfigs.supplyCurrLimit.toArray();
498            ec.NewError(MotControllerJNI.ConfigSupplyCurrentLimit(getHandle(), doubles, timeoutMs));
499        }
500        if (TalonFXConfigUtil.StatorCurrentDurationDifferent(allConfigs))
501        {
502            double[] doubles = allConfigs.statorCurrLimit.toArray();
503            ec.NewError(MotControllerJNI.ConfigStatorCurrentLimit(getHandle(), doubles, timeoutMs));
504        }
505        if (TalonFXConfigUtil.MotorCommutationDifferent(allConfigs))
506        {
507            ec.NewError(configMotorCommutation(allConfigs.motorCommutation, timeoutMs));
508        }
509        if (TalonFXConfigUtil.AbsoluteSensorRangeDifferent(allConfigs))
510        {
511            ec.NewError(configIntegratedSensorAbsoluteRange(allConfigs.absoluteSensorRange, timeoutMs));
512        }
513        if (TalonFXConfigUtil.IntegratedSensorOffsetDegreesDifferent(allConfigs))
514        {
515            ec.NewError(configIntegratedSensorOffset(allConfigs.integratedSensorOffsetDegrees, timeoutMs));
516        }
517        if (TalonFXConfigUtil.InitializationStrategyDifferent(allConfigs))
518        {
519            ec.NewError(configIntegratedSensorInitializationStrategy(allConfigs.initializationStrategy, timeoutMs));
520        }
521
522        return ec._worstError;
523    }
524    /**
525     * Configures all persistent settings.
526     *
527     * @param allConfigs        Object with all of the persistant settings
528     *
529     * @return Error Code generated by function. 0 indicates no error.
530     */
531    public ErrorCode configAllSettings(TalonFXConfiguration allConfigs)
532    {
533        int timeoutMs = 50;
534        return configAllSettings(allConfigs, timeoutMs);
535    }
536    /**
537     * Gets all persistant settings.
538     *
539     * @param allConfigs        Object with all of the persistant settings
540     * @param timeoutMs
541     *              Timeout value in ms. If nonzero, function will wait for
542     *              config success and report an error if it times out.
543     *              If zero, no blocking or checking is performed.
544     *
545     * @return Error Code generated by function. 0 indicates no error.
546     */
547    public ErrorCode getAllConfigs(TalonFXConfiguration allConfigs, int timeoutMs)
548    {
549        ErrorCollection ec = new ErrorCollection();
550
551        super.getAllConfigs(allConfigs, timeoutMs);
552        ec.NewError(configGetSupplyCurrentLimit(allConfigs.supplyCurrLimit, timeoutMs));
553        ec.NewError(configGetStatorCurrentLimit(allConfigs.statorCurrLimit, timeoutMs));
554        allConfigs.motorCommutation = configGetMotorCommutation(timeoutMs);
555        ec.NewError(getLastError());
556        allConfigs.absoluteSensorRange = AbsoluteSensorRange.valueOf((int)configGetParameter(ParamEnum.eAbsSensorRange, 0, timeoutMs));
557        ec.NewError(getLastError());
558        allConfigs.integratedSensorOffsetDegrees = configGetParameter(ParamEnum.eMagnetOffset, 0, timeoutMs);
559        ec.NewError(getLastError());
560        allConfigs.initializationStrategy = SensorInitializationStrategy.valueOf((int)configGetParameter(ParamEnum.eSensorInitStrategy, 0, timeoutMs));
561        ec.NewError(getLastError());
562
563        return ec._worstError;
564    }
565    /**
566     * Gets all persistant settings (overloaded so timeoutMs is 50 ms).
567     *
568         * @param allConfigs        Object with all of the persistant settings
569     *
570     * @return Error Code generated by function. 0 indicates no error.
571     */
572    public ErrorCode getAllConfigs(TalonFXConfiguration allConfigs) {
573        int timeoutMs = 50;
574        return getAllConfigs(allConfigs, timeoutMs);
575    }
576}