:py:mod:`phoenix6.hardware` =========================== .. py:module:: phoenix6.hardware Subpackages ----------- .. toctree:: :titlesonly: :maxdepth: 3 core/index.rst traits/index.rst Submodules ---------- .. toctree:: :titlesonly: :maxdepth: 1 cancoder/index.rst candi/index.rst candle/index.rst canrange/index.rst device_identifier/index.rst parent_device/index.rst pigeon2/index.rst talon_fx/index.rst talon_fxs/index.rst Package Contents ---------------- .. py:class:: ParentDevice(device_id: int, model: str, canbus: phoenix6.canbus.CANBus) Bases: :py:obj:`phoenix6.hardware.traits.common_device.CommonDevice` Base class of Phoenix devices. This holds the base information for the devices, and can be used as a generic type to hold onto a collection of multiple devices. Constructor for a device :param deviceId: ID of the device :type deviceId: int :param model: Model of the device :type model: str :param canbus: CANbus the device is on :type canbus: CANBus .. py:property:: device_id :type: int Gets the ID of this device. :returns: ID of this device :rtype: int .. py:property:: network :type: phoenix6.canbus.CANBus Gets the network this device is on. :returns: The network this device is on :rtype: CANBus .. py:property:: device_hash :type: int Gets a number unique for this device's hardware type and ID. This number is not unique across networks. This can be used to easily reference hardware devices on the same network in collections such as maps. :returns: Hash of this device :rtype: int .. py:property:: control_request :type: SupportsSendRequest Get the latest applied control. :returns: Latest applied control :rtype: SupportsSendRequest .. py:property:: has_reset_occurred :type: bool Check if the device has reset since the previous call to this routine :returns: True if device has reset :rtype: bool .. py:property:: is_connected :type: bool Returns whether the device is still connected to the robot. This is equivalent to refreshing and checking the latency of the Version status signal. :param max_latency_seconds: The maximum latency of the Version status signal before the device is reported as disconnected :type max_latency_seconds: float :returns: True if the device is connected :rtype: bool .. py:method:: get_reset_occurred_checker() -> Callable[[], bool] Get a lambda that checks for device resets. :returns: A lambda that checks for device resets :rtype: Callable[[], bool] .. py:method:: optimize_bus_utilization(optimized_freq_hz: phoenix6.units.hertz = 4.0, timeout_seconds: phoenix6.units.second = 0.1) -> phoenix6.status_code.StatusCode Optimizes the device's bus utilization by reducing the update frequencies of its status signals. All status signals that have not been explicitly gven an update frequency using BaseStatusSignal.set_update_frequency will be slowed down. Note that if other status signals in the same frame have been given an update frequency, the update frequency will be honored for the entire frame. This function only needs to be called once on this device in the robot program. Additionally, this method does not necessarily need to be called after setting the update frequencies of other signals. To restore the default status update frequencies, call reset_signal_frequencies. Alternatively, remove this method call, redeploy the robot application, and power-cycle the device on the bus. The user can also override individual status update frequencies using BaseStatusSignal.set_update_frequency. :param optimized_freq_hz: The update frequency to apply to the optimized status signals. A frequency of 0 Hz will turn off the signals. Otherwise, the minimum supported signal frequency is 4 Hz (default). :type optimized_freq_hz: hertz, optional :param timeout_seconds: Maximum amount of time to wait for each status frame when performing the action :type timeout_seconds: second, optional :returns: Status code of the first failed update frequency set call, or OK if all succeeded. :rtype: StatusCode .. py:method:: optimize_bus_utilization_for_all(*devices: phoenix6.hardware.traits.common_device.CommonDevice | list[phoenix6.hardware.traits.common_device.CommonDevice], optimized_freq_hz: phoenix6.units.hertz = 4.0) -> phoenix6.status_code.StatusCode :staticmethod: Optimizes the bus utilization of the provided devices by reducing the update frequencies of their status signals. All status signals that have not been explicitly given an update frequency using BaseStatusSignal.set_update_frequency will be slowed down. Note that if other status signals in the same status frame have been given an update frequency, the update frequency will be honored for the entire frame. This function only needs to be called once in the robot program for the provided devices. Additionally, this method does not necessarily need to be called after setting the update frequencies of other signals. To restore the default status update frequencies, call reset_signal_frequencies_for_all. Alternatively, remove this method call, redeploy the robot application, and power-cycle the devices on the bus. The user can also override individual status update frequencies using BaseStatusSignal.set_update_frequency. This will wait up to 0.100 seconds (100ms) for each status frame. :param devices: Devices for which to optimize bus utilization. :type devices: tuple[CommonDevice | list[CommonDevice], ...] :param optimized_freq_hz: The update frequency to apply to the optimized status signals. A frequency of 0 Hz will turn off the signals. Otherwise, the minimum supported signal frequency is 4 Hz (default). This must be specified using a named parameter at the end of the parameter list. :type optimized_freq_hz: hertz, optional :returns: Status code of the first failed optimize call, or OK if all succeeded :rtype: StatusCode .. py:method:: reset_signal_frequencies(timeout_seconds: phoenix6.units.second = 0.1) -> phoenix6.status_code.StatusCode Resets the update frequencies of all the device's status signals to the defaults. This restores the default update frequency of all status signals, including status signals explicitly given an update frequency using BaseStatusSignal.set_update_frequency and status signals optimized out using optimize_bus_utilization. :param timeout_seconds: Maximum amount of time to wait for each status frame when performing the action :type timeout_seconds: second, optional :returns: Status code of the first failed update frequency set call, or OK if all succeeded. :rtype: StatusCode .. py:method:: reset_signal_frequencies_for_all(*devices: phoenix6.hardware.traits.common_device.CommonDevice | list[phoenix6.hardware.traits.common_device.CommonDevice]) -> phoenix6.status_code.StatusCode :staticmethod: Resets the update frequencies of all the devices' status signals to the defaults. This restores the default update frequency of all status signals, including status signals explicitly given an update frequency using BaseStatusSignal.set_update_frequency and status signals optimized out using optimize_bus_utilization_for_all. This will wait up to 0.100 seconds (100ms) for each status frame. :param devices: Devices for which to restore default update frequencies. :type devices: tuple[CommonDevice | list[CommonDevice], ...] :returns: Status code of the first failed restore call, or OK if all succeeded :rtype: StatusCode .. py:class:: TalonFX(device_id: int, canbus: phoenix6.canbus.CANBus | str = CANBus()) Bases: :py:obj:`phoenix6.hardware.core.core_talon_fx.CoreTalonFX`, :py:obj:`wpiutil.Sendable` Constructs a new Talon FX motor controller object. .. versionchanged:: 2026 Constructing devices with a CAN bus string is deprecated for removal in the 2027 season. Construct devices using a CANBus instance instead. :param device_id: ID of the device, as configured in Phoenix Tuner :type device_id: int :param canbus: 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: CANBus | str, 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 .. py:class:: CANcoder(device_id: int, canbus: phoenix6.canbus.CANBus | str = CANBus()) Bases: :py:obj:`phoenix6.hardware.core.core_cancoder.CoreCANcoder`, :py:obj:`wpiutil.Sendable` Constructs a new CANcoder object. .. versionchanged:: 2026 Constructing devices with a CAN bus string is deprecated for removal in the 2027 season. Construct devices using a CANBus instance instead. :param device_id: ID of the device, as configured in Phoenix Tuner :type device_id: int :param canbus: 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: CANBus | str, optional .. py:method:: close() .. py:method:: initSendable(builder: wpiutil.SendableBuilder) Initializes this Sendable object. :param builder: sendable builder .. py:class:: Pigeon2(device_id: int, canbus: phoenix6.canbus.CANBus | str = CANBus()) Bases: :py:obj:`phoenix6.hardware.core.core_pigeon2.CorePigeon2`, :py:obj:`wpiutil.Sendable` Constructs a new Pigeon 2 sensor object. .. versionchanged:: 2026 Constructing devices with a CAN bus string is deprecated for removal in the 2027 season. Construct devices using a CANBus instance instead. :param device_id: ID of the device, as configured in Phoenix Tuner :type device_id: int :param canbus: 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: CANBus | str, optional .. py:method:: close() .. py:method:: reset() Resets the Pigeon 2 to a heading of zero. This can be used if there is significant drift in the gyro, and it needs to be recalibrated after it has been running. .. py:method:: getRotation2d() -> wpimath.geometry.Rotation2d Returns the heading of the robot as a Rotation2d. The angle increases as the Pigeon 2 turns counterclockwise when looked at from the top. This follows the NWU axis convention. The angle is continuous; that is, it will continue from 360 to 361 degrees. This allows for algorithms that wouldn't want to see a discontinuity in the gyro output as it sweeps past from 360 to 0 on the second time around. :returns: The current heading of the robot as a Rotation2d :rtype: Rotation2d .. py:method:: getRotation3d() -> wpimath.geometry.Rotation3d Returns the orientation of the robot as a Rotation3d created from the quaternion signals. :returns: The current orientation of the robot as a Rotation3d :rtype: Rotation3d .. py:method:: initSendable(builder: wpiutil.SendableBuilder) Initializes this Sendable object. :param builder: sendable builder .. py:class:: TalonFXS(device_id: int, canbus: phoenix6.canbus.CANBus | str = CANBus()) Bases: :py:obj:`phoenix6.hardware.core.core_talon_fxs.CoreTalonFXS`, :py:obj:`wpiutil.Sendable` Constructs a new Talon FXS motor controller object. .. versionchanged:: 2026 Constructing devices with a CAN bus string is deprecated for removal in the 2027 season. Construct devices using a CANBus instance instead. :param device_id: ID of the device, as configured in Phoenix Tuner :type device_id: int :param canbus: 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: CANBus | str, 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 TalonFXSConfiguration 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 .. py:class:: CANrange(device_id: int, canbus: phoenix6.canbus.CANBus | str = CANBus()) Bases: :py:obj:`phoenix6.hardware.core.core_canrange.CoreCANrange`, :py:obj:`wpiutil.Sendable` Constructs a new CANrange object. .. versionchanged:: 2026 Constructing devices with a CAN bus string is deprecated for removal in the 2027 season. Construct devices using a CANBus instance instead. :param device_id: ID of the device, as configured in Phoenix Tuner :type device_id: int :param canbus: 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: CANBus | str, optional .. py:method:: close() .. py:method:: initSendable(builder: wpiutil.SendableBuilder) Initializes this Sendable object. :param builder: sendable builder .. py:class:: CANdi(device_id: int, canbus: phoenix6.canbus.CANBus | str = CANBus()) Bases: :py:obj:`phoenix6.hardware.core.core_candi.CoreCANdi`, :py:obj:`wpiutil.Sendable` Constructs a new CANdi object. .. versionchanged:: 2026 Constructing devices with a CAN bus string is deprecated for removal in the 2027 season. Construct devices using a CANBus instance instead. :param device_id: ID of the device, as configured in Phoenix Tuner :type device_id: int :param canbus: 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: CANBus | str, optional .. py:method:: close() .. py:method:: initSendable(builder: wpiutil.SendableBuilder) Initializes this Sendable object. :param builder: sendable builder .. py:class:: CANdle(device_id: int, canbus: phoenix6.canbus.CANBus | str = CANBus()) Bases: :py:obj:`phoenix6.hardware.core.core_candle.CoreCANdle`, :py:obj:`wpiutil.Sendable` Constructs a new CANdle object. .. versionchanged:: 2026 Constructing devices with a CAN bus string is deprecated for removal in the 2027 season. Construct devices using a CANBus instance instead. :param device_id: ID of the device, as configured in Phoenix Tuner :type device_id: int :param canbus: 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: CANBus | str, optional .. py:method:: close() .. py:method:: initSendable(builder: wpiutil.SendableBuilder) Initializes this Sendable object. :param builder: sendable builder