WPILibC++ 2023.4.3-108-ge5452e3
frc::sim::BatterySim Class Reference

A utility class to simulate the robot battery. More...

#include <frc/simulation/BatterySim.h>

Static Public Member Functions

static units::volt_t Calculate (units::volt_t nominalVoltage, units::ohm_t resistance, std::span< const units::ampere_t > currents)
 Calculate the loaded battery voltage. More...
 
static units::volt_t Calculate (units::volt_t nominalVoltage, units::ohm_t resistance, std::initializer_list< units::ampere_t > currents)
 Calculate the loaded battery voltage. More...
 
static units::volt_t Calculate (std::span< const units::ampere_t > currents)
 Calculate the loaded battery voltage. More...
 
static units::volt_t Calculate (std::initializer_list< units::ampere_t > currents)
 Calculate the loaded battery voltage. More...
 

Detailed Description

A utility class to simulate the robot battery.

Member Function Documentation

◆ Calculate() [1/4]

static units::volt_t frc::sim::BatterySim::Calculate ( std::initializer_list< units::ampere_t >  currents)
inlinestatic

Calculate the loaded battery voltage.

Use this with RoboRioSimSetVInVoltage(double) to set the simulated battery voltage, which can then be retrieved with the RobotController::GetBatteryVoltage() method. This function assumes a nominal voltage of 12V and a resistance of 20 milliohms (0.020 ohms).

Parameters
currentsThe currents drawn from the battery.
Returns
The battery's voltage under load.

◆ Calculate() [2/4]

static units::volt_t frc::sim::BatterySim::Calculate ( std::span< const units::ampere_t >  currents)
inlinestatic

Calculate the loaded battery voltage.

Use this with RoboRioSimSetVInVoltage(double) to set the simulated battery voltage, which can then be retrieved with the RobotController::GetBatteryVoltage() method. This function assumes a nominal voltage of 12V and a resistance of 20 milliohms (0.020 ohms).

Parameters
currentsThe currents drawn from the battery.
Returns
The battery's voltage under load.

◆ Calculate() [3/4]

static units::volt_t frc::sim::BatterySim::Calculate ( units::volt_t  nominalVoltage,
units::ohm_t  resistance,
std::initializer_list< units::ampere_t >  currents 
)
inlinestatic

Calculate the loaded battery voltage.

Use this with RoboRioSim::SetVInVoltage(double) to set the simulated battery voltage, which can then be retrieved with the RobotController::GetBatteryVoltage() method.

Parameters
nominalVoltageThe nominal battery voltage. Usually 12v.
resistanceThe forward resistance of the battery. Most batteries are at or below 20 milliohms.
currentsThe currents drawn from the battery.
Returns
The battery's voltage under load.

◆ Calculate() [4/4]

static units::volt_t frc::sim::BatterySim::Calculate ( units::volt_t  nominalVoltage,
units::ohm_t  resistance,
std::span< const units::ampere_t >  currents 
)
inlinestatic

Calculate the loaded battery voltage.

Use this with RoboRioSim::SetVInVoltage(double) to set the simulated battery voltage, which can then be retrieved with the RobotController::GetBatteryVoltage() method.

Parameters
nominalVoltageThe nominal battery voltage. Usually 12v.
resistanceThe forward resistance of the battery. Most batteries are at or below 20 milliohms.
currentsThe currents drawn from the battery.
Returns
The battery's voltage under load.

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