Valkyrie 2026
Loading...
Searching...
No Matches
valor::PowerDistribution Class Reference

#include <valkyrie/PowerDistribution.h>

Inheritance diagram for valor::PowerDistribution:

Public Types

enum class  ModuleType { kCTRE_PDP , kCTRE_PDP2_0 , kRev }

Public Member Functions

 PowerDistribution ()
 PowerDistribution (int module, ModuleType moduleType)
int GetNumChannels () const
units::volt_t GetVoltage () const
units::celsius_t GetTemperature () const
units::ampere_t GetCurrent (int channel) const
std::vector< units::ampere_t > GetAllCurrents () const
units::ampere_t GetTotalCurrent () const
units::watt_t GetTotalPower () const
units::joule_t GetTotalEnergy () const
constexpr ModuleType GetType () const
void InitSendable (wpi::SendableBuilder &builder) override

Detailed Description

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

The PDP 2.0 does not communicate with the RoboRIO. As a result, the only function that returns meaningful data for the PDP 2.0 is GetVoltage(), which returns the RoboRIO detected battery voltage. All other functions that would normally query PDP telemetry return default values or perform no operation.

Member Enumeration Documentation

◆ ModuleType

Power distribution module type.

Enumerator
kCTRE_PDP 

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

kCTRE_PDP2_0 

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

kRev 

REV Power Distribution Hub (PDH).

Constructor & Destructor Documentation

◆ PowerDistribution() [1/2]

valor::PowerDistribution::PowerDistribution ( )

Constructs a PowerDistribution object.

Detects the connected PDP/PDH using the default CAN ID (0 for CTRE PDP and 1 for REV). If battery voltage is unreasonable (< 1 volt), it is assumed to be PDP 2.0 as the PDP 2.0 has no communication with the RIO

◆ PowerDistribution() [2/2]

valor::PowerDistribution::PowerDistribution ( int module,
ModuleType moduleType )
inline

Constructs a PowerDistribution object.

Parameters
moduleThe CAN ID of the PDP/PDH (doesn't matter for the PDP 2.0)
moduleTypeThe type of module

Member Function Documentation

◆ GetAllCurrents()

std::vector< units::ampere_t > valor::PowerDistribution::GetAllCurrents ( ) const

Query all currents of the PDP. Not supported on the PDP 2.0 and returns a vector with all zeroes.

Returns
The current of each channel in Amperes

◆ GetCurrent()

units::ampere_t valor::PowerDistribution::GetCurrent ( int channel) const
inline

Query the current of a single channel of the PDP/PDH. Not supported on the PDP 2.0 and retursn 0.

Parameters
channelthe channel to query (0-15 for PDP, 0-23 for PDH)
Returns
The current of the channel in Amperes

◆ GetNumChannels()

int valor::PowerDistribution::GetNumChannels ( ) const

Gets the number of channels for this power distribution object.

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

◆ GetTemperature()

units::celsius_t valor::PowerDistribution::GetTemperature ( ) const
inline

Query the temperature of the PDP.

Not supported on the Rev PDH and returns 0. Not supported on the PDP 2.0 and returns 0.

Returns
The temperature in degrees Celsius

◆ GetTotalCurrent()

units::ampere_t valor::PowerDistribution::GetTotalCurrent ( ) const
inline

Query the total current of all monitored PDP/PDH channels. Not supported on the PDP 2.0 and returns 0.

Returns
The total current drawn from all channels in Amperes

◆ GetTotalEnergy()

units::joule_t valor::PowerDistribution::GetTotalEnergy ( ) const
inline

Query the total energy drawn from the monitored PDP channels.

Not supported on the Rev PDH and returns 0. Not supported on the PDP 2.0 and returns 0.

Returns
The total energy drawn in Joules

◆ GetTotalPower()

units::watt_t valor::PowerDistribution::GetTotalPower ( ) const
inline

Query the total power drawn from all monitored PDP channels.

Not supported on the Rev PDH and returns 0. Not supported on the PDP 2.0 and returns 0.

Returns
The total power drawn in Watts

◆ GetType()

ModuleType valor::PowerDistribution::GetType ( ) const
inlineconstexpr

Gets module type.

◆ GetVoltage()

units::volt_t valor::PowerDistribution::GetVoltage ( ) const

Query the input voltage of the PDP/PDH. Defaults to the RIO detected battery voltage on the PDP 2.0

Returns
The input voltage in volts

The documentation for this class was generated from the following file: