Class TalonUtils

java.lang.Object
com.ctre.phoenix6.configs.TalonUtils

public class TalonUtils extends Object
A generic utility class for TalonFX and TalonFXS.
  • Method Summary

    Modifier and Type
    Method
    Description
    static 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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 the StatusCode 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.