Class TalonFX

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

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

  • Constructor Details

    • TalonFX

      public TalonFX(int deviceId)
      Constructs a new Talon FX motor controller object.

      Constructs the device using the default CAN bus for the system (see CANBus()).

      Parameters:
      deviceId - ID of the device, as configured in Phoenix Tuner
    • TalonFX

      @Deprecated(since="2026", forRemoval=true) public TalonFX(int deviceId, String canbus)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Constructing devices with a CAN bus string is deprecated for removal in the 2027 season. Construct devices using a CANBus instance instead.
      Constructs a new Talon FX motor controller object.
      Parameters:
      deviceId - ID of the device, as configured in Phoenix Tuner
      canbus - Name of the CAN bus this device is on. Possible CAN bus strings are:
      • "rio" for the native roboRIO CAN bus
      • CANivore name or serial number
      • SocketCAN interface (non-FRC Linux only)
      • "*" for any CANivore seen by the program
      • empty string (default) to select the default for the system:
        • "rio" on roboRIO
        • "can0" on Linux
        • "*" on Windows
    • 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

    • close

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

      public final void set(double speed)
      Common interface for setting the speed of a motor controller.
      Parameters:
      speed - The speed to set. Value should be between -1.0 and 1.0.
    • setVoltage

      public final void setVoltage(double volts)
      Common interface for seting the direct voltage output of a motor controller.
      Parameters:
      volts - The voltage to output.
    • get

      public final double get()
      Common interface for getting the current set speed of a motor controller.
      Returns:
      The current set speed. Value is between -1.0 and 1.0.
    • setControlPrivate

      Overrides:
      setControlPrivate in class ParentDevice
    • disable

      public final void disable()
      Common interface for disabling a motor controller.
    • stopMotor

      public final void stopMotor()
      Common interface to stop motor movement until set is called again.
    • setNeutralMode

      public final StatusCode setNeutralMode(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
    • setNeutralMode

      public final StatusCode setNeutralMode(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
    • initSendable

      public void initSendable(SendableBuilder builder)
      Specified by:
      initSendable in interface Sendable
    • getDescription

      Returns:
      Description of motor controller
    • 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