PowerDistribution

class wpilib.PowerDistribution(*args, **kwargs)

Bases: Sendable

Class for getting voltage, current, temperature, power and energy from the CTRE Power Distribution Panel (PDP) or REV Power Distribution Hub (PDH).

Overloaded function.

  1. __init__(self: wpilib._wpilib.PowerDistribution, bus_id: typing.SupportsInt | typing.SupportsIndex) -> None

Constructs a PowerDistribution object.

Detects the connected PDP/PDH using the default CAN ID (0 for CTRE and 1 for REV).

Parameters:

bus_id – The bus ID.

  1. __init__(self: wpilib._wpilib.PowerDistribution, bus_id: typing.SupportsInt | typing.SupportsIndex, module: typing.SupportsInt | typing.SupportsIndex, module_type: wpilib._wpilib.PowerDistribution.ModuleType) -> None

Constructs a PowerDistribution object.

Parameters:
  • bus_id – The bus ID.

  • module – The CAN ID of the PDP/PDH

  • module_type – The type of module

DEFAULT_MODULE = -1
class Faults

Bases: pybind11_object

Faults for a PowerDistribution device. These faults are only active while the condition is active.

property brownout

The input voltage is below the minimum voltage.

property can_warning

A warning was raised by the device’s CAN controller.

property channel0_breaker_fault

Breaker fault on channel 0.

property channel10_breaker_fault

Breaker fault on channel 10.

property channel11_breaker_fault

Breaker fault on channel 12.

property channel12_breaker_fault

Breaker fault on channel 13.

property channel13_breaker_fault

Breaker fault on channel 14.

property channel14_breaker_fault

Breaker fault on channel 15.

property channel15_breaker_fault

Breaker fault on channel 16.

property channel16_breaker_fault

Breaker fault on channel 17.

property channel17_breaker_fault

Breaker fault on channel 18.

property channel18_breaker_fault

Breaker fault on channel 19.

property channel19_breaker_fault

Breaker fault on channel 20.

property channel1_breaker_fault

Breaker fault on channel 1.

property channel20_breaker_fault

Breaker fault on channel 21.

property channel21_breaker_fault

Breaker fault on channel 22.

property channel22_breaker_fault

Breaker fault on channel 23.

property channel23_breaker_fault

Breaker fault on channel 24.

property channel2_breaker_fault

Breaker fault on channel 2.

property channel3_breaker_fault

Breaker fault on channel 3.

property channel4_breaker_fault

Breaker fault on channel 4.

property channel5_breaker_fault

Breaker fault on channel 5.

property channel6_breaker_fault

Breaker fault on channel 6.

property channel7_breaker_fault

Breaker fault on channel 7.

property channel8_breaker_fault

Breaker fault on channel 8.

property channel9_breaker_fault

Breaker fault on channel 9.

get_breaker_fault(channel: SupportsInt | SupportsIndex) bool

Gets whether there is a breaker fault at a specified channel.

Parameters:

channel – Channel to check for faults.

Returns:

If there is a breaker fault. @throws A ChannelIndexOutOfRange error if the given int is outside of the range supported by the hardware.

property hardware_fault

The hardware on the device has malfunctioned.

class ModuleType(value: SupportsInt | SupportsIndex)

Bases: pybind11_object

Power distribution module type.

Members:

CTRE : CTRE (Cross The Road Electronics) CTRE Power Distribution Panel (PDP).

REV : REV Power Distribution Hub (PDH).

CTRE = <ModuleType.CTRE: 1>
REV = <ModuleType.REV: 2>
PowerDistribution.ModuleType.name -> str
property value
class StickyFaults

Bases: pybind11_object

Sticky faults for a PowerDistribution device. These faults will remain active until they are reset by the user.

property brownout

The input voltage is below the minimum voltage.

property can_bus_off

The device’s CAN controller experienced a “Bus Off” event.

property can_warning

A warning was raised by the device’s CAN controller.

property channel0_breaker_fault

Breaker fault on channel 0.

property channel10_breaker_fault

Breaker fault on channel 10.

property channel11_breaker_fault

Breaker fault on channel 12.

property channel12_breaker_fault

Breaker fault on channel 13.

property channel13_breaker_fault

Breaker fault on channel 14.

property channel14_breaker_fault

Breaker fault on channel 15.

property channel15_breaker_fault

Breaker fault on channel 16.

property channel16_breaker_fault

Breaker fault on channel 17.

property channel17_breaker_fault

Breaker fault on channel 18.

property channel18_breaker_fault

Breaker fault on channel 19.

property channel19_breaker_fault

Breaker fault on channel 20.

property channel1_breaker_fault

Breaker fault on channel 1.

property channel20_breaker_fault

Breaker fault on channel 21.

property channel21_breaker_fault

Breaker fault on channel 22.

property channel22_breaker_fault

Breaker fault on channel 23.

property channel23_breaker_fault

Breaker fault on channel 24.

property channel2_breaker_fault

Breaker fault on channel 2.

property channel3_breaker_fault

Breaker fault on channel 3.

property channel4_breaker_fault

Breaker fault on channel 4.

property channel5_breaker_fault

Breaker fault on channel 5.

property channel6_breaker_fault

Breaker fault on channel 6.

property channel7_breaker_fault

Breaker fault on channel 7.

property channel8_breaker_fault

Breaker fault on channel 8.

property channel9_breaker_fault

Breaker fault on channel 9.

property firmware_fault

The firmware on the device has malfunctioned.

get_breaker_fault(channel: SupportsInt | SupportsIndex) bool

Gets whether there is a sticky breaker fault at the specified channel.

Parameters:

channel – Index to check for sticky faults.

Returns:

True if there is a sticky breaker fault at the channel, otherwise false. @throws A ChannelIndexOutOfRange error if the provided channel is outside of the range supported by the hardware.

property hardware_fault

The hardware on the device has malfunctioned.

property has_reset

The device has rebooted.

class Version

Bases: pybind11_object

Version and device data received from a PowerDistribution device

clear_sticky_faults() None

Remove all of the fault flags on the PDP/PDH.

get_all_currents() list[float]

Query all currents of the PDP.

Returns:

The current of each channel in Amperes

get_current(channel: SupportsInt | SupportsIndex) float

Query the current of a single channel of the PDP/PDH.

Parameters:

channel – the channel to query (0-15 for PDP, 0-23 for PDH)

Returns:

The current of the channel in Amperes

get_faults() wpilib._wpilib.PowerDistribution.Faults

Returns the power distribution faults.

On a CTRE PDP, this will return an object with no faults active.

Returns:

The power distribution faults.

get_module() int

Gets module number (CAN ID).

get_num_channels() int

Gets the number of channels for this power distribution object.

Returns:

Number of output channels (16 for PDP, 24 for PDH).

get_sticky_faults() wpilib._wpilib.PowerDistribution.StickyFaults

Returns the power distribution sticky faults.

On a CTRE PDP, this will return an object with no faults active.

Returns:

The power distribution sticky faults.

get_switchable_channel() bool

Gets whether the PDH switchable channel is turned on or off. Returns false with the CTRE PDP.

Returns:

The output state of the PDH switchable channel

get_temperature() float

Query the temperature of the PDP.

Not supported on the Rev PDH and returns 0.

Returns:

The temperature in degrees Celsius

get_total_current() float

Query the total current of all monitored PDP/PDH channels.

Returns:

The total current drawn from all channels in Amperes

get_total_energy() float

Query the total energy drawn from the monitored PDP channels.

Not supported on the Rev PDH and returns 0.

Returns:

The total energy drawn in Joules

get_total_power() float

Query the total power drawn from all monitored PDP channels.

Not supported on the Rev PDH and returns 0.

Returns:

The total power drawn in Watts

get_type() wpilib._wpilib.PowerDistribution.ModuleType

Gets module type.

get_version() wpilib._wpilib.PowerDistribution.Version
get_voltage() float

Query the input voltage of the PDP/PDH.

Returns:

The input voltage in volts

init_sendable(builder: wpiutil._wpiutil.SendableBuilder) None
reset_total_energy() None

Reset the total energy drawn from the PDP.

Not supported on the Rev PDH and does nothing.

@see PowerDistribution#GetTotalEnergy

set_switchable_channel(enabled: bool) None

Sets the PDH switchable channel on or off. Does nothing with the CTRE PDP.

Parameters:

enabled – Whether to turn the PDH switchable channel on or off