Class TalonFX

All Implemented Interfaces:
CommonDevice, CommonTalon, CommonTalonWithFOC, HasTalonControls, HasTalonSignals, SupportsFOC, SupportsMusic, AutoCloseable

public class TalonFX extends CoreTalonFX implements AutoCloseable
WPILib-integrated version of CoreTalonFX.
  • Field Details

  • Constructor Details

    • TalonFX

      public TalonFX(int deviceId, CANBus canbus)
      Constructs a new Talon FX motor controller object.
      Parameters:
      deviceId - ID of the device, as configured in Phoenix Tuner
      canbus - The CAN bus this device is on
  • Method Details

    • none

      public static TalonFX none()
      Constructs a stubbed-out TalonFX, where all status signals, controls, configs, etc. perform no action and immediately return OK. This can be used to silence error messages for devices that have been completely removed from the robot.
      Returns:
      Stubbed-out TalonFX
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • setControlPrivate

      Overrides:
      setControlPrivate in class ParentDevice
    • setThrottle

      public final void setThrottle(double throttle)
      Sets the throttle of the motor controller.
      Parameters:
      throttle - The throttle where -1 indicates full reverse and 1 indicates full forward.
    • setVoltage

      public final void setVoltage(double voltage)
      Sets the direct voltage output of the motor controller.

      Compensates for the current bus voltage to ensure that the desired voltage is output even if the battery voltage is below 12V - highly useful when the voltage outputs are "meaningful" (e.g. they come from a feedforward calculation).

      Parameters:
      voltage - The voltage.
    • setVoltage

      public final void setVoltage(org.wpilib.units.measure.Voltage voltage)
      Sets the direct voltage output of the motor controller.

      Compensates for the current bus voltage to ensure that the desired voltage is output even if the battery voltage is below 12V - highly useful when the voltage outputs are "meaningful" (e.g. they come from a feedforward calculation).

      Parameters:
      voltage - The voltage.
    • getThrottle

      public final double getThrottle()
      Gets the throttle of the motor controller.
      Returns:
      The throttle where -1 represents full reverse and 1 represents full forward.
    • disable

      public final void disable()
      Disables the motor controller.
    • configNeutralMode

      public final StatusCode configNeutralMode(NeutralModeValue neutralMode)
      Sets the mode of operation when output is neutral or disabled. This is equivalent to setting the MotorOutputConfigs.NeutralMode when applying a TalonFXConfiguration to the motor.

      Since neutral mode is a config, this API is blocking. We recommend that users avoid calling this API periodically.

      This will wait up to 0.100 seconds (100ms) by default.

      Parameters:
      neutralMode - The state of the motor controller bridge when output is neutral or disabled
      Returns:
      Status of refreshing and applying the neutral mode config
    • configNeutralMode

      public final StatusCode configNeutralMode(NeutralModeValue neutralMode, double timeoutSeconds)
      Sets the mode of operation when output is neutral or disabled.

      Since neutral mode is a config, this API is blocking. We recommend that users avoid calling this API periodically.

      Parameters:
      neutralMode - The state of the motor controller bridge when output is neutral or disabled
      timeoutSeconds - Maximum amount of time to wait when performing configuration
      Returns:
      Status of refreshing and applying the neutral mode config
    • feed

      public final void feed()
      Feed the motor safety object.

      Resets the timer on this object that is used to do the timeouts.

    • setExpiration

      public final void setExpiration(double expirationTime)
      Set the expiration time for the corresponding motor safety object.
      Parameters:
      expirationTime - The timeout value in seconds.
    • getExpiration

      public final double getExpiration()
      Retrieve the timeout value for the corresponding motor safety object.
      Returns:
      the timeout value in seconds.
    • isAlive

      public final boolean isAlive()
      Determine of the motor is still operating or has timed out.
      Returns:
      a true value if the motor is still operating normally and hasn't timed out.
    • setSafetyEnabled

      public final void setSafetyEnabled(boolean enabled)
      Enable/disable motor safety for this device.

      Turn on and off the motor safety option for this object.

      Parameters:
      enabled - True if motor safety is enforced for this object.
    • isSafetyEnabled

      public final boolean isSafetyEnabled()
      Return the state of the motor safety enabled flag.

      Return if the motor safety is currently enabled for this device.

      Returns:
      True if motor safety is enforced for this device
    • stopMotor

      public final void stopMotor()
      Called to stop the motor when the timeout expires.
    • getDescription

      Returns:
      Description of the motor controller