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, busId: 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:

busId – The bus ID.

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

Constructs a PowerDistribution object.

Parameters:
  • busId – The bus ID.

  • module – The CAN ID of the PDP/PDH

  • moduleType – The type of module

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 canWarning

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

property channel0BreakerFault

Breaker fault on channel 0.

property channel10BreakerFault

Breaker fault on channel 10.

property channel11BreakerFault

Breaker fault on channel 12.

property channel12BreakerFault

Breaker fault on channel 13.

property channel13BreakerFault

Breaker fault on channel 14.

property channel14BreakerFault

Breaker fault on channel 15.

property channel15BreakerFault

Breaker fault on channel 16.

property channel16BreakerFault

Breaker fault on channel 17.

property channel17BreakerFault

Breaker fault on channel 18.

property channel18BreakerFault

Breaker fault on channel 19.

property channel19BreakerFault

Breaker fault on channel 20.

property channel1BreakerFault

Breaker fault on channel 1.

property channel20BreakerFault

Breaker fault on channel 21.

property channel21BreakerFault

Breaker fault on channel 22.

property channel22BreakerFault

Breaker fault on channel 23.

property channel23BreakerFault

Breaker fault on channel 24.

property channel2BreakerFault

Breaker fault on channel 2.

property channel3BreakerFault

Breaker fault on channel 3.

property channel4BreakerFault

Breaker fault on channel 4.

property channel5BreakerFault

Breaker fault on channel 5.

property channel6BreakerFault

Breaker fault on channel 6.

property channel7BreakerFault

Breaker fault on channel 7.

property channel8BreakerFault

Breaker fault on channel 8.

property channel9BreakerFault

Breaker fault on channel 9.

getBreakerFault(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 hardwareFault

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 canBusOff

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

property canWarning

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

property channel0BreakerFault

Breaker fault on channel 0.

property channel10BreakerFault

Breaker fault on channel 10.

property channel11BreakerFault

Breaker fault on channel 12.

property channel12BreakerFault

Breaker fault on channel 13.

property channel13BreakerFault

Breaker fault on channel 14.

property channel14BreakerFault

Breaker fault on channel 15.

property channel15BreakerFault

Breaker fault on channel 16.

property channel16BreakerFault

Breaker fault on channel 17.

property channel17BreakerFault

Breaker fault on channel 18.

property channel18BreakerFault

Breaker fault on channel 19.

property channel19BreakerFault

Breaker fault on channel 20.

property channel1BreakerFault

Breaker fault on channel 1.

property channel20BreakerFault

Breaker fault on channel 21.

property channel21BreakerFault

Breaker fault on channel 22.

property channel22BreakerFault

Breaker fault on channel 23.

property channel23BreakerFault

Breaker fault on channel 24.

property channel2BreakerFault

Breaker fault on channel 2.

property channel3BreakerFault

Breaker fault on channel 3.

property channel4BreakerFault

Breaker fault on channel 4.

property channel5BreakerFault

Breaker fault on channel 5.

property channel6BreakerFault

Breaker fault on channel 6.

property channel7BreakerFault

Breaker fault on channel 7.

property channel8BreakerFault

Breaker fault on channel 8.

property channel9BreakerFault

Breaker fault on channel 9.

property firmwareFault

The firmware on the device has malfunctioned.

getBreakerFault(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 hardwareFault

The hardware on the device has malfunctioned.

property hasReset

The device has rebooted.

class Version

Bases: pybind11_object

Version and device data received from a PowerDistribution device

clearStickyFaults() None

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

getAllCurrents() list[float]

Query all currents of the PDP.

Returns:

The current of each channel in Amperes

getCurrent(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

getFaults() 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.

getModule() int

Gets module number (CAN ID).

getNumChannels() int

Gets the number of channels for this power distribution object.

Returns:

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

getStickyFaults() 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.

getSwitchableChannel() 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

getTemperature() float

Query the temperature of the PDP.

Not supported on the Rev PDH and returns 0.

Returns:

The temperature in degrees Celsius

getTotalCurrent() float

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

Returns:

The total current drawn from all channels in Amperes

getTotalEnergy() 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

getTotalPower() 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

getType() wpilib._wpilib.PowerDistribution.ModuleType

Gets module type.

getVersion() wpilib._wpilib.PowerDistribution.Version
getVoltage() float

Query the input voltage of the PDP/PDH.

Returns:

The input voltage in volts

initSendable(builder: wpiutil._wpiutil.SendableBuilder) None
kDefaultModule = -1
resetTotalEnergy() None

Reset the total energy drawn from the PDP.

Not supported on the Rev PDH and does nothing.

@see PowerDistribution#GetTotalEnergy

setSwitchableChannel(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