:py:mod:`phoenix6.hardware.talon_fx`
====================================

.. py:module:: phoenix6.hardware.talon_fx

Module Contents
---------------


.. py:class:: TalonFX(device_id: int, canbus: str | phoenix6.canbus.CANBus = '')


   Bases: :py:obj:`phoenix6.hardware.core.core_talon_fx.CoreTalonFX`, :py:obj:`wpiutil.Sendable`

   Constructs a new Talon FX motor controller object.

   :param device_id: ID of the device, as configured in Phoenix Tuner.
   :type device_id: int
   :param 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

   :type canbus: str | CANBus, optional

   .. py:method:: close()


   .. py:method:: set(speed: float)

      Common interface for setting the speed of a motor controller.

      :param speed: The speed to set. Value should be between -1.0 and 1.0.
      :type speed: float


   .. py:method:: setVoltage(volts: wpimath.units.volts)

      Common interface for seting the direct voltage output of a motor controller.

      :param volts: The voltage to output.
      :type volts: units.volts


   .. py:method:: get() -> float

      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.
      :rtype: float


   .. py:method:: disable()

      Common interface for disabling a motor controller.


   .. py:method:: stopMotor()

      Common interface to stop motor movement until set is called again.


   .. py:method:: setNeutralMode(neutralMode: phoenix6.signals.NeutralModeValue, timeout_seconds: wpimath.units.seconds = 0.1) -> phoenix6.status_code.StatusCode

      Sets the mode of operation when output is neutral or disabled.
      This is equivalent to setting the MotorOutputConfigs.neutral_mode
      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.

      :param neutralMode: The state of the motor controller bridge
                          when output is neutral or disabled
      :type neutralMode: signals.NeutralModeValue
      :param timeout_seconds: Maximum amount of time to wait when
                              performing configuration
      :type timeout_seconds: units.seconds
      :returns: Status of refreshing and applying the neutral mode config
      :rtype: StatusCode


   .. py:method:: initSendable(builder: wpiutil.SendableBuilder)

      Initializes this Sendable object.

      :param builder: sendable builder


   .. py:method:: getDescription() -> str

      :returns: Description of motor
      :rtype: str


   .. py:method:: feed()


   .. py:method:: setExpiration(expirationTime: wpimath.units.seconds)

      Set the expiration time for the corresponding motor
      safety object.

      :param expirationTime: The timeout value in seconds.
      :type expirationTime: units.seconds


   .. py:method:: getExpiration() -> wpimath.units.seconds

      Retrieve the timeout value for the corresponding motor
      safety object.

      :returns: the timeout value in seconds.
      :rtype: units.seconds


   .. py:method:: isAlive() -> bool

      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
      :rtype: bool


   .. py:method:: setSafetyEnabled(enabled: bool)

      Enable/disable motor safety for this device.

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

      :param enabled: True if motor safety is enforced for this object.
      :type enabled: bool


   .. py:method:: isSafetyEnabled() -> bool

      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
      :rtype: bool