Package com.ctre.phoenix6.configs
Class TalonUtils
java.lang.Object
com.ctre.phoenix6.configs.TalonUtils
A generic utility class for TalonFX and TalonFXS.
-
Method Summary
Modifier and TypeMethodDescriptionstatic com.ctre.phoenix6.configs.TalonFXConfiguration
getTalonFXConfiguration
(com.ctre.phoenix6.hardware.TalonFX fx) Gets the current configuration of the given TalonFX.static com.ctre.phoenix6.configs.TalonFXSConfiguration
getTalonFXSConfiguration
(com.ctre.phoenix6.hardware.TalonFXS fxs) Gets the current configuration of the given TalonFXS.static boolean
retryUntilOk
(Supplier<com.ctre.phoenix6.StatusCode> applierFunction, int numMaxTries, String desc) Tries to apply the given function until a valid Ok status code is reached, or until the maximum number of tries is exceeded.
-
Method Details
-
getTalonFXConfiguration
public static com.ctre.phoenix6.configs.TalonFXConfiguration getTalonFXConfiguration(com.ctre.phoenix6.hardware.TalonFX fx) Gets the current configuration of the given TalonFX.- Parameters:
fx
- The TalonFX to get the configuration from.- Returns:
- The current configuration of the TalonFX.
-
getTalonFXSConfiguration
public static com.ctre.phoenix6.configs.TalonFXSConfiguration getTalonFXSConfiguration(com.ctre.phoenix6.hardware.TalonFXS fxs) Gets the current configuration of the given TalonFXS.- Parameters:
fxs
- The TalonFXS to get the configuration from.- Returns:
- The current configuration of the TalonFXS.
-
retryUntilOk
public static boolean retryUntilOk(Supplier<com.ctre.phoenix6.StatusCode> applierFunction, int numMaxTries, String desc) Tries to apply the given function until a valid Ok status code is reached, or until the maximum number of tries is exceeded. The logged values can be checked from theStatusCode
enum.- Parameters:
applierFunction
- The function interacts with hardware and returns the status code.numMaxTries
- The maximmum number of tries before canceling.desc
- The description of the hardware interaction. For example:"Applying the configuration to elevator motor #1"
- Returns:
- True if an Ok status code was reached within the given attempts, false otherwise.
-